Calculus – Solve Integral of Cosine over Hyperbolic Cosine without Complex Integration

calculusdefinite integralsimproper-integralsintegration

Solve $$\int \limits_{0}^{\infty} \frac{\cos(x)}{\cosh(x)} dx$$ without complex integration.

This integral can be very easily solved with contour integration, but how can you solve it without taking a tour in the complex plane?

Best Answer

Integration by parts twice yields $$ \begin{align} \int_0^\infty\cos(x)e^{-ax}\,\mathrm{d}x &=a\int_0^\infty\sin(x)e^{-ax}\,\mathrm{d}x\\ &=a-a^2\int_0^\infty\cos(x)e^{-ax}\,\mathrm{d}x\\ &=\frac{a}{a^2+1}\tag{1} \end{align} $$ where the last line is mean of the original integral and the third integral weighted by $a^2$ and $1$. $$ \begin{align} \int_0^\infty\frac{\cos(x)}{\cosh(x)}\,\mathrm{d}x &=2\int_0^\infty\cos(x)\sum_{k=0}^\infty(-1)^ke^{-(2k+1)x}\,\mathrm{d}x\tag{2}\\ &=2\sum_{k=0}^\infty(-1)^k\frac{2k+1}{(2k+1)^2+1}\tag{3}\\ &=\sum_{k=1}^\infty(-1)^k\left(\frac1{2k+1+i}+\frac1{2k+1-i}\right)\tag{4}\\ &=\frac12\sum_{k=0}^\infty(-1)^k\left(\frac1{k+\frac{1+i}2}-\frac1{-k-1+\frac{1+i}2}\right)\tag{5}\\ &=\frac12\sum_{k=0}^\infty\frac{(-1)^k}{k+\frac{1+i}2}+\frac12\sum_{k=-\infty}^{-1}\frac{(-1)^k}{k+\frac{1+i}2}\tag{6}\\ &=\frac12\sum_{k=-\infty}^\infty\frac{(-1)^k}{k+\frac{1+i}2}\tag{7}\\ &=\frac\pi2\csc\left(\pi\frac{1+i}2\right)\tag{8}\\[6pt] &=\frac\pi2\mathrm{sech}\left(\frac\pi2\right)\tag{9} \end{align} $$ Explanation:
$(2)$: $\frac2{\large e^x+e^{-x}}=2\sum\limits_{k=0}^\infty(-1)^ke^{-(2k+1)x}$
$(3)$: apply $(1)$
$(4)$: partial fractions
$(5)$: bring the $\frac12$ out front and rewrite the second term
$(6)$: reindex the second sum
$(7)$: combine the sums
$(8)$: use equation $(7)$ from this answer and $\pi\csc(\pi x)=\pi\cot(\pi x/2)-\pi\cot(\pi x)$
$(9)$: $\sin(\frac\pi2+\frac\pi2i)=\sin(\frac\pi2)\cosh(\frac\pi2)+i\cos(\frac\pi2)\sinh(\frac\pi2)=\cosh(\frac\pi2)$