# How to calculate $\int_{-\infty}^{\infty}\frac{x^2}{\cosh(x)}\mathrm{d}x$ [duplicate]

I know the poles are $z=i\pi/2+i n\pi$ and therefor I got an rectangular contour for the integration which wasn't so useful. I also know with change of variables I can get to $\int_{0}^{\infty}\frac{\log(x)^2}{1+x^2}\mathrm{d}x$ but I don't want to use this I want to evaluate the original integral.

• math.stackexchange.com/questions/696953/… – Random Variable Jan 15 '16 at 15:49
• In general, $~\displaystyle\int_{-\infty}^\infty\frac{x^{2k}}{\cosh(x)}~dx ~=~ 2~\bigg(\dfrac\pi2\bigg)^{2k+1}~a_k,~$ where $a_k$ are the so-called zig numbers. See also alternating permutation for more information. – Lucian Jan 15 '16 at 16:37
• Ca you explain where this comes from?! @lucian – john Jan 15 '16 at 16:50
• Also, $~\displaystyle\int_{-\infty}^\infty\frac{x^{2k-1}}{\sinh(x)}~dx ~=~ 2~\bigg(\dfrac\pi2\bigg)^{2k}~b_k,~$ where $b_k$ are the so-called zag numbers. – Lucian Jan 15 '16 at 16:58

Consider the integral

$$\oint_C dz \frac{z^2}{\cosh{z}}$$

where $C$ is the rectangle having vertices $-R$, $R$, $R+ i \pi$, $-R + i \pi$. This contour integral is equal to

$$\int_{-R}^R dx \frac{x^2}{\cosh{x}} + i \int_0^{\pi} dy \frac{(R+i y)^2}{\cosh{(R+i y)}} \\ + \int_R^{-R} dx \frac{(x+i \pi)^2}{\cosh{(x+i \pi)}} + i \int_{\pi}^0 dy \frac{(-R+i y)^2}{\cosh{(-R+i y)}}$$

As $R \to \infty$, the second and fourth integrals vanish. (Why?) By the residue theorem, the contour integral is equal to $i 2 \pi$ times the residue at the pole $z=i \pi/2$. Thus, we have in the limit

$$2 \int_{-\infty}^{\infty} dx \frac{x^2}{\cosh{x}} + i 2 \pi \int_{-\infty}^{\infty} dx \frac{x}{\cosh{x}} - \pi^2 \int_{-\infty}^{\infty} \frac{dx}{\cosh{x}} = i 2 \pi \frac{(i \pi/2)^2}{\sinh{(i \pi/2)}}$$

The second integral is zero. The third integral may be done similarly, i.e., by considering

$$\oint_C \frac{dz}{\cosh{z}} = 2 \int_{-\infty}^{\infty} \frac{dx}{\cosh{x}} = i 2 \pi \frac{1}{\sinh{(i \pi/2)}} = 2 \pi$$

Thus,

$$2 \int_{-\infty}^{\infty} dx \frac{x^2}{\cosh{x}} - \pi^3 = 2 \pi \left (-\frac{\pi^2}{4} \right )$$

or

$$\int_{-\infty}^{\infty} dx \frac{x^2}{\cosh{x}} = \frac{\pi^3}{4}$$

• We-he-hell! I solved the problem very similarly in the duplicated post. My apologies for the senility. – Ron Gordon Jan 15 '16 at 22:41