13

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?

me_ravi_
  • 1,076
Chris
  • 1,075

5 Answers5

14

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)$

Kamal Saleh
  • 6,497
robjohn
  • 345,667
9

The integral is equal to

$$\begin{align}2 \int_0^{\infty} dx\, e^{-x} \frac{\cos{x}}{1+e^{-2 x}} &= 2\sum_{k=0}^{\infty} (-1)^k \int_0^{\infty} dx \, e^{-(2 k+1) x} \cos{x} \\ &= 2\operatorname{Re} \sum_{k=0}^{\infty}\frac{(-1)^k}{2 k+1-i}\\ &= 2\sum_{k=0}^{\infty} (-1)^k \frac{2 k+1}{(2 k+1)^2+1}\\ &= \sum_{k=-\infty}^{\infty} (-1)^k \frac{2 k+1}{(2 k+1)^2+1}\\ &=-\pi \sum_{\pm} \operatorname*{Res}_{z=\frac{-1\pm i}{2}}\frac{(2 z+1) \csc{\pi z}}{(2 z+1)^2+1} \\ &= \frac{\pi}{2} \left [ \frac1{\sin{\left ( \frac{\pi}{2} - \frac{\pi i}{2}\right )}} + \frac1{\sin{\left ( \frac{\pi}{2} + \frac{\pi i}{2}\right )}}\right ]\\ &= \frac{\pi}{2 \cosh{(\pi/2)}}\end{align}$$

Ron Gordon
  • 138,521
  • 1
    You appear to be using residues. Doesn't this entail contour integration? – MPW May 10 '15 at 16:14
  • I think something funny's happened to your $k=0$ term when you extend the sum. Indeed, the summand is not symmetric, so I think more detail is probably needed there. Secondly, you haven't really avoided contour integration here. :) – Chappers May 10 '15 at 16:14
  • If one wants to avoid the last step with Residue calculus, one could just notice that the series could be interpreted as a certain Fourier series at a certain point. – mickep May 10 '15 at 16:20
  • @Chappers: the sum is indeed symmetric. And yes, I did a lousy job of avoiding contour integration. But as it is Mother's Day here, I'll leave it to another genius to evaluate the sum another way. – Ron Gordon May 10 '15 at 16:21
  • i think the sum could be rewritten in terms digamma functions, using their corresponding refelection formula should bring us to the result. – tired May 10 '15 at 16:37
  • @tired See below. It's rather grim in the actual execution... – Chappers May 10 '15 at 17:02
9

Expand $ \operatorname{sech}{x} $ in an infinite series in $e^{-x}$: $$ \frac{2}{e^x(1+e^{-2x})} = 2 \sum_{k=0}^{\infty} (-1)^k e^{-(2k+1)x} $$ Interchange the order of integration, and you are left with integrals of the form $$ \int_0^{\infty} e^{-\alpha x} \cos{x} \, dx, $$ which can be done using integration by parts, to avoid complex numbers totally, with the result $ \alpha/(1+\alpha^2) $. Hence the integral is equal to $$ \sum_{k=0}^{\infty} (-1)^k \frac{1+2k}{1+2k+2k^2}. $$

Okay, and now it is time once again for "Special Functions and Pray". Using the usual tricks, one can express infinite sums in terms of the digamma function as follows: first, write the summand in partial fractions as $$ \frac{1+2k}{1+2k+2k^2} = \frac{1}{2} \left( \frac{1}{k+a} + \frac{1}{k+a^*} \right), $$ where $a$ is the complex root of the denominator, $(1+i)/2$. Now we have the identity $$ \sum_{k=0}^{K} \frac{1}{k+a} = \psi(K+a+1)-\psi(a+1), $$ where $\psi = (\log{\Gamma})'$ as usual. However, this is not good enough: we have to deal with the $(-1)^k$. This we do by splitting into the even and odd cases: some algebra shows the result we want is $$ \sum_{k=0}^K \frac{(-1)^k}{k+a} = \frac{1}{2} (-1)^K \psi{\left(\frac{a}{2}+\frac{K}{2}+1\right)} -\frac{1}{2} (-1)^K \psi{\left(\frac{a}{2}+\frac{K}{2}+\frac{1}{2}\right)} -\frac{1}{2}\psi{\left(\frac{a}{2}\right)} +\frac{1}{2} \psi{\left(\frac{a}{2}+\frac{1}{2}\right)}. $$

Now, this sum actually converges by comparison with the alternating harmonic series, the details of which I omit. Hence we can take the limit as $k \to \infty$. The problem is what happens to the terms $$ \frac{1}{2} (-1)^K \left( \psi{\left(\frac{a}{2}+\frac{K}{2}+1\right)} - \psi{\left(\frac{a}{2}+\frac{K}{2}+\frac{1}{2}\right)} \right), $$ but a slight abuse of Stirling's approximation shows that this term is $O(\log{n}-\log{(n+1/2)})=o(1)$, so in fact we can just ditch it. Hence the answer is $$ -\frac{1}{4}\psi{\left(\frac{a}{2}\right)} +\frac{1}{4} \psi{\left(\frac{a}{2}+\frac{1}{2}\right)} + c.c., $$ because we have a half in the partial fractions. Then we need to compute $$-\frac{1}{4} \psi{\left(\frac{1}{4}+\frac{i}{4}\right)} +\frac{1}{4} \psi{\left(\frac{3}{4}+\frac{i}{4}\right)} -\frac{1}{4} \psi{\left(\frac{1}{4}-\frac{i}{4}\right)} +\frac{1}{4} \psi{\left(\frac{3}{4}-\frac{i}{4}\right)},$$ but staring at this for long enough, you can pair the terms so that you can apply the identity $$ \psi(z)-\psi(1-z) = -\pi \cot{\pi z}, $$ which gives you $$ \frac{1}{4} \pi \cot \left(\left(\frac{1}{4}+\frac{i}{4}\right) \pi \right)+\frac{1}{4} i \pi \coth \left(\left(\frac{1}{4}+\frac{i}{4}\right) \pi \right), $$ and applying some trigonometric identities eventually settles this into the form $$ \tfrac{1}{2}\pi \operatorname{sech}{\tfrac{1}{2}\pi}, $$ which is thankfully the right answer.

Chappers
  • 67,606
  • 1
    Nice! After thinking a little bit, i guess it would be easier to just use a Mittag-Leffler expansion of $1/sin(z)$ which can for example found on wikipedia – tired May 10 '15 at 18:26
8

We have \begin{align} I & = \int_0^{\infty} \dfrac{\cos(x)}{\left(\dfrac{e^x+e^{-x}}2 \right)}dx = \int_0^{\infty}2e^{-x} \cdot \dfrac{\cos(x)}{1+e^{-2x}}dx = \sum_{k=0}^{\infty}2(-1)^k\int_0^{\infty}e^{-(2k+1)x}\cos(x)dx\\ & = 2\sum_{k=0}^{\infty}(-1)^k f_k \end{align} where \begin{align} f_k & = \int_0^{\infty}e^{-(2k+1)x}\cos(x)dx = \sum_{l=0}^{\infty}\dfrac{(-1)^l}{(2l)!} \int_0^{\infty} e^{-(2k+1)x}x^{2l}dx = \sum_{l=0}^{\infty}\dfrac{(-1)^l}{(2l)!} \int_0^{\infty} e^{-t}\dfrac{t^{2l}dt}{(2k+1)^{2l+1}}\\ & = \sum_{l=0}^{\infty}\dfrac{(-1)^l}{(2l)!} \cdot \dfrac{\Gamma(2l+1)}{(2k+1)^{2l+1}} = \dfrac1{2k+1} \sum_{l=0}^{\infty} \left(-\dfrac1{(2k+1)^2}\right)^l = \dfrac1{2k+1} \cdot \dfrac1{1+\dfrac1{(2k+1)^2}}\\ & = \dfrac{(2k+1)}{(2k+1)^2+1} \end{align} Hence, we have $$I = 2\sum_{k=0}^{\infty}(-1)^k \dfrac{(2k+1)}{(2k+1)^2+1} = \dfrac{\pi}{2\text{cosh}(\pi/2)}$$

Adhvaitha
  • 20,259
  • 1
    Presumably the OP would like to see how the sum is evaluated without complex analysis as well. – Chappers May 10 '15 at 16:59
  • 2
    @Chappers: What exactly would you consider complex analysis here? – Alex M. May 10 '15 at 17:16
  • @AlexM. I suppose, without contour integration would be a standard assumption. I am curious as to whether one can avoid complex numbers totally in the calculation, since they do not appear in the integrand, but I doubt it. – Chappers May 10 '15 at 19:06
5

You may prove through differential equations that $\frac{1}{\cosh x}$ is almost a fixed point of the Fourier transform, meaning that $$ \mathscr{F}\left(\frac{1}{\cosh x}\right) = \sqrt{\frac{\pi}{2}}\,\frac{1}{\cosh\frac{\pi s}{2}}$$ according to Mathematica's standard choice of normalization constants.
Similarly, in the sense of distributions $$ \mathscr{F}\left(\cos x\right) = \sqrt{\frac{\pi}{2}}\,\left[\delta(s-1)+\delta(s+1)\right]$$ hence, by parity, it follows that $$ \int_{0}^{+\infty}\frac{\cos x}{\cosh x}\,dx = \frac{1}{2}\int_{\mathbb{R}}\frac{\cos x}{\cosh x}\,dx = \frac{\pi}{2}\cdot\left.\frac{1}{\cosh\frac{\pi s}{2}}\right|_{s=1} = \frac{\pi}{2\cosh\frac{\pi}{2}} = \frac{\pi e^{\pi/2}}{e^\pi-1}.$$

Jack D'Aurizio
  • 353,855