$$ \int_{-\pi/2}^{\pi/2} \frac{\cos(x)}{1+e^x} dx$$

Using integration by parts

$$\int u v = u \int v - \int u' \int v$$

with $u(x) = \cos(x)$ and $v(x) = \frac{1}{1+e^x}$,

$$ u \int_{-\pi/2}^{\pi/2} v dx = \left[ \cos(x) \int_{-\pi/2}^{\pi/2} \frac{1}{1+e^x} dx \right]_{-\pi/2}^{\pi/2} = \left[ \cos(x) ( x - log(1+e^x) \right]_{-\pi/2}^{\pi/2} $$

$$ \int_{-\pi/2}^{\pi/2} u' \left( \int_{-\pi/2}^{\pi/2} v dx \right) dx = \int_{-\pi/2}^{\pi/2} -\sin(x) \int_{-\pi/2}^{\pi/2} \frac{1}{1+e^x} dx $$

$$ = \int_{-\pi/2}^{\pi/2} -\sin(x) \left[ ( x - log(1+e^x) \right]_{-\pi/2}^{\pi/2} $$

Short of continuing ad nauseam, is there a better way to determine the answer (given as $1$) ?

  • $\begingroup$ This is a special case of a more general fact, which was dealt with in the following question: math.stackexchange.com/questions/60045/… $\endgroup$
    – Zarrax
    Apr 27 '14 at 13:08
  • $\begingroup$ Your notation for integration by parts is highly non-standard. The correct notation is $$\int u~dv = uv - \int v~du$$ A longer form of the expression is $$\int u~\frac{dv}{dx}~dx = uv - \int v~\frac{du}{dx}~dx$$ $\endgroup$ Apr 27 '14 at 13:14
  • $\begingroup$ It's not really a duplicate because the other question is more general. $\endgroup$ Apr 27 '14 at 13:21
  • $\begingroup$ @amWhy The related question is indeed a general version of this question. But I was initially interested in solving my particular problem. Now, thanks to you and others, I see its general form and applicability. $\endgroup$
    – curryage
    Apr 27 '14 at 16:18

As $\displaystyle\int_a^bf(x)dx=\int_a^bf(a+b-x)dx$

if $\displaystyle f(x)=\frac{\cos x}{1+e^x}, f\left[\frac\pi2+\left(-\frac\pi2\right)-x\right]=\frac{\cos(-x)}{1+e^{-x}}=\frac{e^x\cos x}{1+e^x}$

$$I=\int_{-\frac\pi2}^{\frac\pi2}\frac{\cos x}{1+e^x}dx=\int_{-\frac\pi2}^{\frac\pi2}\frac{e^x\cos x}{1+e^x}dx$$

$$\implies I+I=\int_{-\frac\pi2}^{\frac\pi2}\cos x\ dx$$

  • $\begingroup$ Nice answer (+1). I don't see an obvious answer using integration by parts, though. $\endgroup$
    – robjohn
    Apr 27 '14 at 14:19

$$I=\int_{-\frac\pi2}^{\frac\pi2}\frac{\cos x}{1+e^x}dx$$

$$=\int_{-\frac\pi2}^0\frac{\cos x}{1+e^x}+\int_0^{\frac\pi2}\frac{\cos x}{1+e^x}dx$$

Setting $-x=y$ $$I_1=\int_{-\frac\pi2}^0\frac{\cos x}{1+e^x}=\int_\frac\pi2^0\frac{\cos(-y)}{1+e^{-y}}(-dy)$$ $$I_1=\int_0^{\frac\pi2}\frac{e^y\cos y}{1+e^y}dy\text{ as }\int_c^df(y)\ dy=-\int_d^cf(y)\ dy$$

$$\implies I_1=\int_0^{\frac\pi2}\frac{e^x\cos x}{1+e^x}dx$$

$$\implies I=\int_0^{\frac\pi2}\frac{e^x\cos x}{1+e^x}dx+\int_0^{\frac\pi2}\frac{\cos x}{1+e^x}dx=\cdots$$

  • $\begingroup$ @curryage, Another way $\endgroup$ Apr 27 '14 at 14:09
  • $\begingroup$ This looks pretty much the same. You are utilizing the symmetry of the domain and ignoring the odd part of the function. That is, using that the even part of $\frac1{1+e^x}$ is $\frac12$. $\endgroup$
    – robjohn
    Apr 27 '14 at 14:14
  • $\begingroup$ @robjohn, But my other answer is agnostic about odd/even things, right? $\endgroup$ Apr 27 '14 at 14:17
  • $\begingroup$ It seems that your other answer answer adds $f(x)=\frac1{1+e^x}$ and $f(-x)=\frac{e^x}{1+e^x}$ to get $1$ (twice the even part), and then divides by $2$. That is what prompted my previous comment. $\endgroup$
    – robjohn
    Apr 27 '14 at 14:22
  • $\begingroup$ @robjohn Agree with labbharracharjee here. The accepted answer uses a different property $\int_a^b f(x) dx = \int_a^b f(a+b-x) dx$ to arrive at the result. $\endgroup$
    – curryage
    Apr 27 '14 at 16:12

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