# How to find $\int_{-1}^1 \frac{\cos x}{a^x+1}\mathrm dx$

Evaluate $$\int_{-1}^1 \frac{\cos x}{a^x+1}\mathrm dx$$ where $a$ is a real parameter $a\geq1$.

I can easily find the definite integral for $a=1$. It is $\sin(1)$.

In wolframalpha.com when I put $\displaystyle\int_{-1}^1 \frac{\cos x}{a^x+1}\text{d}x$ it shows me a very complicated formula with complex numbers and functions I didn't study but it says that definite integral is $= 0.841471\ldots$.

How can I find that integral?


• That's cheating! :) +1 – Bruno Joyal Dec 16 '14 at 19:53
• @BrunoJoyal Thanks. You can recognize there the usual Fermi-Dirac distribution function. – Felix Marin Dec 16 '14 at 20:47

One of the first observations we can make is that you're integrating a function over an interval that is symmetric around $0$, i.e. it can be written as $[-c,c]$. I have a trick for you, whenever you find similar definite integrals start by writing the function you're integrating as a sum of an even function and an odd function. In fact, it can be proven that for every function $f$, there exists two functions such that $f=f_{\mathrm e}+f_{\mathrm o}$ and $f_{\mathrm e}$ is even and $f_{\mathrm o}$ is odd. Specifically $$f_{\mathrm e}(x)=\dfrac{f(x)+f(-x)}{2}\qquad f_{\mathrm o}(x)=\dfrac{f(x)-f(-x)}{2}.$$ You may ask yourself: “Why bother? It seems we're just making a complicated expression to look more intimidating.” But just wait, you'll see the usefulness of this process in a bit. Let's get back to our integral, applying the property we've just discussed for the function $f\colon x\mapsto\tfrac{\cos (x)}{a^x+1}$

\eqalign{ \int_{-1}^1 \frac{\cos x}{a^x+1}\mathrm dx&=\int_{-1}^1 \big[f_{\mathrm o}(x)+f_{\mathrm e}(x)\big]\mathrm dx\\ &=\int_{-1}^1 f_{\mathrm o}(x)\,\mathrm dx+\int_{-1}^1 f_{\mathrm e}(x)\,\mathrm dx\\ &=\int_{-1}^1f_{\mathrm e}(x)\,\mathrm dx.}

Since

$$\int_{-c}^c(\text{odd function})(x)\,\mathrm dx=0.\tag{\forall c\in\Bbb R}$$

Now if you calculate $f_{\mathrm e}$ you'll find that it has the ridiculously simple form:

\require{cancel}\eqalign{f_{\mathrm e}(x)&=\dfrac{f(x)+f(-x)}{2}\\&=\dfrac{\frac{\cos (x)}{a^x+1}+\frac{\cos(-x)}{a^{-x}+1}}{2}\\&=\dfrac{\frac{\cos (x)}{a^x+1}+\frac{\cos(x)}{a^{-x}+1}}{2}\\&=\dfrac{\cos x}{2}\left(\dfrac{1}{a^x+1}+\dfrac1{a^{-x}+1}\right)\\&=\dfrac{\cos x}2{\left(\dfrac{2+a^{-x}+a^x}{a^{-x}a^x+a^x+a^{-x}+1}\right)}\\&=\dfrac{\cos x}{2}, } which is way simpler to integrate than the original function. We thus get $$\int_{-1}^1 \frac{\cos x}{a^x+1}\mathrm dx=\int_{-1}^1\frac{\cos x}2\mathrm dx=\int_0^1\cos x\,\mathrm dx=\sin1.\tag{\forall a\geqslant1}$$

We can even give the following generalization:

$$\int_{-c}^c\frac{\cos x}{a^x+1}\mathrm dx=\int_{-c}^c\frac{\cos x}2\mathrm dx=\int_0^c\cos x\,\mathrm dx=\sin c.$$

Let $$I=\int_{-1}^1 \frac{\cos (x)}{a^x+1}\mathrm dx\tag1$$ Using identity $$\int_a^bf(x)\;\mathrm dx=\int_a^bf(a+b-x)\;\mathrm dx$$ we get $$I=\int_{-1}^1 \frac{\cos (-x)}{a^{-x}+1}\mathrm dx=\int_{-1}^1 \frac{a^{x}\cos (x)}{1+a^{x}}\mathrm dx\tag2$$ Adding $(1)$ and $(2)$, we get $$2I=\int_{-1}^1\cos x\;\mathrm dx=\sin x\,\Bigg|_{-1}^1=2\sin 1\qquad\implies\qquad I=\bbox[8pt,border:3px #FF69B4 solid]{\color{red}{\large\sin 1}}$$ Note that, $\cos(-x)=\cos(x)$ and $\sin(-x)=-\sin(x)$. You might be interested in seeing even and odd functions.