Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do you compute $$\int_{-\infty}^\infty \frac{\cos x }{e^x + e^{-x}} dx$$

share|cite|improve this question
Try learning the LaTeX sintax. It's a must on this website. Hint:$$\cos x = {e^{ix}+e^{-ix}\over2}$$ – Student Mar 6 '13 at 19:40
You don't solve integrals. You compute them. – Student Mar 6 '13 at 19:41
Look here. – Student Mar 6 '13 at 20:00
I am a newbee on this forum and not familiar with LaTeX. I was hoping for a menu on this website to get the mathematicsl scripts (Like the formula editor you can activate in Word). Otherwise is LaTeX something that needs to be downloaded on my PC ? – imranfat Mar 18 '13 at 17:17
Take a look at this tutorial. – Student Mar 18 '13 at 18:24

To use the residue theorem, consider

$$\oint_C dz \frac{e^{i z}}{\cosh{z}}$$

where $C$ is a semicircular contour in the upper half plane, along the real axis. The idea is to show that the integral around the semicircular piece that goes to infinity goes to zero, which in fact it does. (I leave a proof to the reader.) What's left is

$$\int_{-\infty}^{\infty} dx \frac{\cos{x}}{\cosh{x}}$$

which is $i 2 \pi$ times the sum of the residues of the poles of the integrand inside $C$. Note that there are poles at $z=i (n+1/2) \pi \;\; \forall n \ge 1$, $n \in \mathbb{N}$. The residue at the pole $z=i (n+1/2) \pi$ is $-i (-1)^n e^{-(n+1/2) \pi}$. Therefore:

$$\int_{-\infty}^{\infty} dx \frac{\cos{x}}{\cosh{x}} = 2 \pi \sum_{n=0}^{\infty} e^{-(n+1/2) \pi} = 2 \pi e^{-\pi/2} \frac{1}{1+e^{-\pi}} = \pi\, \text{sech}{\frac{\pi}{2}} $$

Therefore the stated integral is

$$\int_{-\infty}^\infty dx\: \frac{\cos x }{e^x + e^{-x}} = \frac{\pi}{2} \text{sech}{\frac{\pi}{2}} $$

share|cite|improve this answer
+1, I think you have forgotten a factor $2$ in the denominator because $e^x+e^{-x}=2\text{cosh }x$. – Américo Tavares Mar 6 '13 at 20:45
@AméricoTavares: no, I kept the factor of 2. Note that I said "consider" that integral. I see that I did say "what's left is the stated integral" which is incorrect, and that might have given you the impression that I left the factor of 2 out. I did not, but I will fix that statement. Thanks! – Ron Gordon Mar 6 '13 at 20:51
That's right! Thanks! – Américo Tavares Mar 6 '13 at 20:54
I do have the correct answer (that does contain e-powers) from the book but I couldn't calculate it myself. Your answer is in terms of hyperbolics, so let me examine your work to comprehend. Thanks for the prompt response. – imranfat Mar 7 '13 at 16:51
Hyperbolics are "e-powers," viz. $\text{sech}{x} = 2/(e^x + e^{-x})$. – Ron Gordon Mar 7 '13 at 17:01


$$ f(x) := \frac{2 e^{ix}}{e^x + e^{-x}} = \frac{e^{ix}}{\cosh x} $$

so that half of the integral of the real part of the function is the one in question. Further consider the contour $C$ which is a rectangle with vertices $-R, R, \frac{i\pi}{2}+R$ and $i-R$. Letting $R \to \infty$, the integrals along $R$ to $R+i\pi$ and $i\pi-R$ and $-R$ disappear.

Then by residue theorem the integral over $C$ equals

$$2 \pi i \operatorname*{Res}_{z=i\frac{\pi}{2}}f(z) = 2\pi i \frac{e^{i(i\frac{\pi}{2})}}{\sinh \left(i\frac{\pi}{2}\right)} = 2\pi e^{-\frac{\pi}{2}}$$

Then solving for the integral by using parametrized representations of the nonzero parts of the contour:

$$ 2\pi e^{-\frac{\pi}{2}} = \oint_C f(z)\, dz = \\ \int_{-\infty}^\infty f(z)\, dz - \int_{-\infty}^\infty f (z+i\pi)\, dz = \\ \int_{-\infty}^\infty \frac{e^{ix}}{\cosh x}\, dz + \int_{-\infty}^\infty \frac{e^{i(x+i\pi)}}{\cosh x}\, dz = \\ (1+e^{-\pi})\int_{-\infty}^\infty \frac{e^{ix}}{\cosh x} $$


$$ \int_{-\infty}^\infty f(z) = \frac{2\pi e^{-\frac{\pi}{2}}}{1+e^{-\pi}} = \frac{\pi}{\cosh \left(\frac{\pi}{2}\right)} $$

Divide that answer by two to get your integral.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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