An integral with residue theorem

definite integralsresidue-calculus

I would like to calculate the following integral with residue theorem $$\int_{-\infty}^{\infty}\frac{dx}{(1+e^x)(x^2+\pi^2)},$$
but I seems not to get it right!

I observe that the poles happen at $z=\pm (2k-1)\pi i$, hence I proceed with calculating the residues and summing them. In the end I obtain a $0$ which is annoying since the integral is not zero.

Could you please help me understand how to do this properly, or, given the comments below, help me know if this is at all possible to use the residue theorem here?


Let $f(z)=\frac{1}{(1+e^z)(z^2+\pi^2)}$. Here are the residues that I calculated:

at $z=i \pi$ we have $Res(f(z),z_0=i\pi)=-\frac{\pi i+1}{4\pi^2}$ and at $z=-i \pi$ we have $Res(f(z),z_0=-i\pi)=\frac{\pi i-1}{4\pi^2}$ and for $z_0=\pm (2k-1)i\pi $ with $k>1$ the residues turn out to be $$\frac{1}{(2k-1)^2-1}\frac{1}{\pi^2}.$$


As Ron Gordon mentioned, the integral can, of course, be evaluated without the residue theorem, but I was after a complex based evaluation. I just add it below:

\begin{align}
\int_{-\infty}^{\infty}\frac{dx}{(1+e^x)(x^2+\pi^2)}&=\int_{-\infty}^{0}\frac{dx}{(1+e^x)(x^2+\pi^2)}+\int_{0}^{\infty}\frac{dx}{(1+e^x)(x^2+\pi^2)}\\
&=\int_{0}^{\infty}\frac{dx}{(1+e^{-x})(x^2+\pi^2)}+\int_{0}^{\infty}\frac{dx}{(1+e^x)(x^2+\pi^2)}\\
&=\int_{0}^{\infty}\frac{dx}{x^2+\pi^2}=\frac12
\end{align}

Best Answer

Let us consider the following contour.

Fix $R>0$ a radius which is a ("big") multiple of $2\pi$, $R=R(n)=2\pi n$. Consider the closed contour $C=C(R)$ build from the two pieces

  • the segment (interval) $I=I(R)$ from $-R$ to $R$,
  • the halfcircle $H=H(R)$ from $R$ to $-R$ parametrized by $t\to Re^{it}$, $t\in[0,\pi]$.

A picture would be:

complex analysis contour integral controlling <span class=$1+e^x$ in the denominator">

and the unit is $\pi$. Then we have for the given meromorphic function $f(z)= (e^z+1)^{-1}(z^2+\pi^2)^{-1}$ $$ \begin{aligned} \int_{\Bbb R}f(x)\; dx & = \lim_{n\to\infty} \int_{-R(n)}^{+R(n)} f(z)\; dz = \lim_{n\to\infty} \int_{I(R(n))} f(z)\; dz \ , \\ 0&= \lim_{n\to\infty} \int_{C(R(n))} f(z)\; dz \\ \int_{I(R)} f(z)\; dz + \int_{H(R)} f(z)\; dz &= 2\pi i\sum_{a\text{ pole inside }C(R)} \operatorname{Residue}_{z=a}f(z) \ . \end{aligned} $$

The zero limit, when integrating on $C(R(n))$, $n\to\infty$ can be motivated as follows. The contour integral is a closed set, not passing through the poles. There is a minimal distance $\pi$ to the poles, which helps us to bound from below $|1+e^z|$, so from above $1/|1+e^z|$. Then the term $1/(x^2+\pi^2)$ is in $O(R^{-2})$, the contour length $(\pi R)$ in $O(R)$, so we land in $O(1)\cdot O(R^{-2})\cdot O(R^1)=O(R^{-1})$.

It remains to consider the sums of the residues of the poles in the upper half plane. We get: $$ \begin{aligned} \operatorname{Residue}_{z=i\pi}f(z) &= \operatorname{Residue}_{h=0\\z=i\pi+h} \frac 1{1+e^{i\pi}e^h}\cdot \frac 1{h+i\pi+i\pi}\cdot \frac 1{h+i\pi-i\pi} \\ &= \operatorname{($h^0$-Coefficient)}_{h=0} \frac 1{1-e^h}\cdot \frac 1{h+2\pi i} \\ &= \operatorname{($h^0$-Coefficient)}_{h=0} \frac 1{-h-\frac 12h^2+O(h^3)}\cdot \frac 1{2\pi i}\cdot \frac 1{1-(-h/(2\pi i))} \\ &= \operatorname{($h^0$-Coefficient)}_{h=0} -\frac 1h \left(1-\frac 12h+O(h^2)\right) \frac 1{2\pi i}\cdot \left(1-\frac h{2\pi i}+O(h^2)\right) \\ &= \operatorname{($h^0$-Coefficient)}_{h=0} -\frac 1{2\pi i}\cdot \frac 1h \left(1-\frac 12h-\frac h{2\pi i}+O(h^2)\right) \\ &= \frac 1{2\pi i}\cdot \left(\frac 12+\frac 1{2\pi i}\right) \end{aligned} $$ I really wanted to do this with bare hands, and use computer only for the check:

sage: var('z');
sage: f(z) = 1 / (1+exp(z)) / (z^2+pi^2)
sage: f(z).residue( z==i*pi )
-1/4*I/pi - 1/4/pi^2
sage: bool( f(z).residue( z==i*pi ) == 1/(2*pi*i) * (1/2 + 1/(2*pi*i)) )
True

It turns out, that all other residues (at poles in the upper half plane) are real. This time we let the computer give us some values:

sage: f.residue( z==3*pi*i )
z |--> 1/8/pi^2
sage: f.residue( z==5*pi*i )
z |--> 1/24/pi^2
sage: f.residue( z==7*pi*i )
z |--> 1/48/pi^2
sage: f.residue( z==9*pi*i )
z |--> 1/80/pi^2
sage: f.residue( z==11*pi*i )
z |--> 1/120/pi^2

and so on as in the OP, the denominators in the rational numbers appearing above (and touching $1/\pi^{2}$) are squares of odd integers, taken minus one.

Our integral is real, so we can forget all these values, getting thus: $$ \int_{\Bbb R} \frac{dx}{(1+e^x)(x^2+\pi^2)} = 2\pi i \left[ \frac 1{2\pi i} \left( \color{blue}{\frac 12}+\frac 1{2\pi i}\right) + \text{real number(s)}\right] \ , $$ and only the blue term survives to give us the "real answer".


Note: I was spending a lot of time trying to check / validate somehow this value numerically. This is the best i could get in pari/gp:

? \p 1000
   realprecision = 1001 significant digits (1000 digits displayed)
? intnum( x=-200, +100, 1 / (1+exp(x)) / (x^2+Pi^2) )
%19 = 0.49500041117264675924354715963413516...

(And we can tacitly control the piece from $[-\infty, -200)$ using $1/(x^2+\pi^2)$.)

Related Question