5
$\begingroup$

How can I calculate the following integral using Mathematica? $$\int_{-\infty}^{\infty} \frac{\mathrm{d} x}{\left(1+x^2\right) \operatorname{ch} \frac{\pi x}{2}} = 2 \ln 2$$

I tried:

int1 = Assuming[Element[x, Reals], 
  Integrate[
   FullSimplify[1/((1 + x^2)*Cosh[(Pi*x)/2])], {x, -Infinity, 
    Infinity}, PrincipalValue -> True]]

int2 = Integrate[
  1/((1 + x^2)*Cosh[(Pi*x)/2]), {x, -Infinity, Infinity}, 
  Assumptions -> Element[x, Reals], GenerateConditions -> False]

int3 = Integrate`InverseIntegrate[
 1/((1 + x^2)*Cosh[(Pi*x)/2]), {x, -Infinity, Infinity}, 
 Assumptions -> Element[x, Reals]]

I can calculate it using the residue theorem, but this belongs to mathematics. Is it possible to directly solve this integral with Mathematica without using the residue theorem?

$\endgroup$
13
  • 2
    $\begingroup$ Isn't NIntegrate[1/((1 + x^2)*Cosh[(Pi*x)/2]), {x, -Infinity, Infinity}] enough? $\endgroup$
    – user64494
    Aug 29 at 8:50
  • 2
    $\begingroup$ @user64494 I want to get an analytical solution Log[4]. $\endgroup$
    – lotus2019
    Aug 29 at 8:54
  • 6
    $\begingroup$ @user64494 As you said, we use numerical integration to do integrals. Why do we still need to learn complex analysis and calculus? Can we just learn numerical methods? Because many people need to derive formulas, such as those majoring in physics. The advantage of mma is that it is good at symbolic computation, so I don't need to say more about it. $\endgroup$
    – lotus2019
    Aug 29 at 9:10
  • 1
    $\begingroup$ This is Gradshtein & Ruezhik, 3.522.8. They refer to Bierens de Hanaan D. Nouvelles tables.... Amsterdam, 1867. $\endgroup$
    – user64494
    Aug 29 at 9:50
  • 2
    $\begingroup$ Roman's answer prompted this reflection: If we're going to use math to do math, why not simply use the residue theorem? It can be done easily in Mma. -- This question is a bit of a strange question, of the sort, "I want to do it in this way which doesn't work? How do I that? I know I can use math to do it another way, but I don't want to do that." So I wonder which alternatives will be acceptable... $\endgroup$
    – Michael E2
    Aug 29 at 11:29

3 Answers 3

10
$\begingroup$

Use an integral representation of $\text{sech}(z)=1/\text{cosh}(z)$:

Assuming[Element[x, Reals],
  2/π Integrate[t^(I x)/(t^2 + 1), {t, 0, ∞}]]

(*    Sech[π x/2]    *)

The integral can thus be written as a double integral. With Fubini's theorem we can flip the integration order:

$$ \int_{-\infty}^{\infty}\frac{dx}{(1+x^2)\text{cosh}\frac{\pi x}{2}} =\int_{-\infty}^{\infty}dx\int_0^{\infty}dt\frac{2t^{i x}}{\pi(1+x^2)(1+t^2)}\\ =\int_0^{\infty}dt\int_{-\infty}^{\infty}dx\frac{2t^{i x}}{\pi(1+x^2)(1+t^2)}\\ =\int_0^{\infty}dt\frac{2e^{-|\ln t|}}{1+t^2} =2\ln2. $$

Using Mathematica:

Integrate[2/π t^(I x)/((1 + t^2) (1 + x^2)), {x, -∞, ∞}, {t, 0, ∞}]
(*    Integrate[Sech[π*x/2]/(1 + x^2), {x, -∞, ∞}]    *)

Integrate[2/π t^(I x)/((1 + t^2) (1 + x^2)), {t, 0, ∞}, {x, -∞, ∞}]
(*    Log[4]    *)
$\endgroup$
2
  • $\begingroup$ You mimic with MMA the math calculation done by hand. $\endgroup$
    – user64494
    Aug 29 at 16:06
  • 8
    $\begingroup$ @user64494 yes that’s how tools work. $\endgroup$
    – Roman
    Aug 29 at 16:42
4
$\begingroup$

The Log[2] comes from Dirichlet eta function at 1. We have partial fraction expansion for hyperbolic secant:

Sech[(π x)/2]==4/π Sum[(((2 n-1)/((2 n-1)^2+x^2)) (-1)^(n+1)),{n,1,∞}]
1/(x^2+1) Sech[(π x)/2]==Sum[(4/π 1/(x^2+1) ((2 n-1)/((2 n-1)^2+x^2)) (-1)^(n+1)),{n,1,∞}]

(* True *)
(* True *)

$$\text{sech}\left(\frac{\pi x}{2}\right)=\frac{4}{\pi}\sum _{n=1}^{\infty } \frac{(2 n-1) (-1)^{n+1}}{(2 n-1)^2+x^2}$$

$$\frac{1}{x^2+1}\text{sech}\left(\frac{\pi x}{2}\right)=\sum _{n=1}^{\infty } \frac{4}{\pi}\frac{1}{\left(x^2+1\right)}\frac{(2 n-1) (-1)^{n+1}}{(2 n-1)^2+x^2}$$

We integrate inside of the sum which will output explicit function.

(exp=Integrate[
  4/π 1/(x^2 + 1) ((2 n - 1)/((2 n - 1)^2 + x^2)) (-1)^(n + 1), 
  x]) == ((-1)^(
  1 + n) (-1 + 2 n) ((-1 + 2 n) ArcTan[x] + ArcTan[x/(1 - 2 n)]))/(
 n (1 - 3 n + 2 n^2) π)

(* True *)

$$exp=\int \frac{4}{\pi}\frac{1}{\left(x^2+1\right)}\frac{(2 n-1) (-1)^{n+1}}{(2 n-1)^2+x^2} \, dx=\frac{(-1)^{n+1} (2 n-1) \left(\tan ^{-1}\left(\frac{x}{1-2 n}\right)+(2 n-1) \tan ^{-1}(x)\right)}{\pi n \left(2 n^2-3 n+1\right)}$$

We compute limit of exp at x=∞ and x=-∞ and subtract them.

Limit[exp, x -> ∞], 
  Assumptions -> n \[Element] PositiveIntegers] == -((-1)^n/n)
Limit[exp, x -> -∞, 
  Assumptions -> n \[Element] PositiveIntegers] == (-1)^n/n

(* True *)
(* True *)

$$lim1-lim2=-2 \frac{(-1)^n}{n}$$

$$int=-2 \sum _{n=1}^{\infty}\frac{(-1)^n}{n}=2 \sum _{n=1}^{\infty}\frac{(-1)^{n+1}}{n}=2 \eta (1)=2 \ln 2$$

$\endgroup$
17
  • $\begingroup$ It is not so simple. The series Sum[(((2 n-1)/((2 n-1)^2+x^2)) (-1)^(n+1)),{n,1,∞}] converges only conditionally: SumConvergence[((2 n - 1)/((2 n - 1)^2 + x^2)) , n, Assumptions -> x >= 0] produces False. Therefore, the change of order of the integration and summation is built on the sand. $\endgroup$
    – user64494
    Aug 29 at 16:04
  • $\begingroup$ You have missing (-1)^n in your in your SumConvergence, the sum with it converges. It does not matter whether conditionally or not because I did not change order of summation of the sum. $\endgroup$ Aug 29 at 16:14
  • $\begingroup$ I consider the absolute convergence of the series Sum[(((2 n-1)/((2 n-1)^2+x^2)) (-1)^(n+1)),{n,1,∞}] as written in my comment. The absolute convergence implies the possibility of the replacing of the summation and integration, but the absolute convergence is false. Hope I am clear. $\endgroup$
    – user64494
    Aug 29 at 16:24
  • $\begingroup$ I think your calculations can be justified, but this needs some arguments. In any case, +1 from me. $\endgroup$
    – user64494
    Aug 29 at 16:42
  • $\begingroup$ I agree with @user64494 that you make some adventurous assumptions about the applicability of Fubini’s theorem here. $\endgroup$
    – Roman
    Aug 29 at 16:44
0
$\begingroup$

I propose the following way: Let us represent the Cosh[(Pi*x)/2]->(Exp[(Pi*x)/2]+Exp[-(Pi*x)/2])/2 as a sum of the exponents. Then the whole integral, int, can be represented as a sum of two terms:

int=int1+int2;

Here int1 only contains the converging parts of the integrals:

int1 = 1/
  2 (Inactive[Integrate][Exp[\[Pi]*x/2]/(
     1 + x^2), {x, -\[Infinity], 0}] + 
    Inactive[Integrate][Exp[-\[Pi]*x/2]/(
     1 + x^2), {x, 0, \[Infinity]}])

enter image description here

int1 // Activate // FullSimplify

(*  CosIntegral[\[Pi]/2]  *)

int2 contains all the rest:

int2 =1/2 ( Inactive[Integrate][Exp[\[Pi]*x/2]/(
   1 + x^2), {x, 0, \[Infinity]}] + 
  Inactive[Integrate][Exp[-\[Pi]*x/2]/(1 + x^2), {x, -\[Infinity], 0}])

enter image description here

Let us change variables in the first of these two integrals:

    int2 = 1/
   2 (IntegrateChangeVariables[
      Inactive[Integrate][Exp[\[Pi]*x/2]/(
       1 + x^2), {x, 0, \[Infinity]}], t, t == -x] + 
     Inactive[Integrate][Exp[-\[Pi]*x/2]/(
      1 + x^2), {x, -\[Infinity], 0}]) /. t -> x

enter image description here

Now everything is clear, but it is a pleasure to go to the end with the Mma tools. Let us use the following rule to fuse the inactive integrals:

rule = Inactive[Integrate][g1__, {x, a_, b_}] + 
    Inactive[Integrate][g2__, {x, a_, b_}] :> 
   Inactive[Integrate][Simplify[g1 + g2], {x, a, b}];

and now:

int2 /. rule // Activate

(*  0  *)

The result is CosIntegral[\[Pi]/2]. Why is it not 2ln2, I do not know. However,

NIntegrate[1/((1 + x^2)*Cosh[(Pi*x)/2]), {x, -Infinity, Infinity}]

(*  1.38629 *)

while

CosIntegral[\[Pi]/2] // N

(* 0.472001  *)

Something is evidently wrong in my solution.

$\endgroup$
1
  • 1
    $\begingroup$ The $\cosh(\pi x/2)$ is in the denominator but you expanded it in the numerator. $\endgroup$
    – Roman
    Aug 29 at 13:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.