# To Find $\int_0^{\pi} \frac{\sin(x)}{1+\sin(x)}$ why the substitution of $\sin(x)=t$ Gives wrong answer?

To find out this basic integral $$\int_0^{\pi} \frac{\sin(x)}{1+\sin(x)} \,\mathrm{d}x$$ I though of two methods :

Method 1:

I started by multiplying and dividing by $1-\sin(x)$ and then manipulating it one easily gets - $$\int_0^{\pi} {(\sec(x)\tan(x) - (\tan(x))^2})\,\mathrm{d}x$$ Which is quite easy to calculate and gives value of $\pi-2$ I do not have any problem with this method , even though it took me some time to solve it.

Method 2 : This was first thing I had thought of :

To let $\sin(x)=t$ and then when I tried to change the limits of integral I found that this substitution makes both upper and lower limits as $t=0$ which would give The value of above integral = 0 , according to the property $\int_a^a f(x)\,\mathrm{d}x = 0$.

But the previous method gives answer of $\pi-2$ then what is wrong with the method 2 . Is that substitution incorrect ? But how and why ?

• This because a valid substitution is given by a diffeomorphism, not just a differentiable map. – Jack D'Aurizio Mar 2 '17 at 15:29
• @Jack D'Aurizio Sorry but I do not quite get your second comment . Can you explain it simple words . I am just learning calculus basics and don't know this much . – Freelancer Mar 2 '17 at 15:33
• He's basically saying that to perform a u-substitution, you need to check what you are substituting and the bounds, or else you'll get...overlaps in the integral, per se. – Simply Beautiful Art Mar 2 '17 at 15:39
• @Jack D'Aurizio Thank you , I see that my simple substitution would have basically meant for any function $f(x)$ any integral $\int_0^{\pi} f(x)$ would become equal to zero with the substitution $\ sin(x)=t$. I think your comments only answered the question. While the answer given below don't really answer the question . Would have accepted the comments as answer if I could. – Freelancer Mar 2 '17 at 15:57
• @Freelancer: I am going to collect them, forge them into an answer, then remove my comments. – Jack D'Aurizio Mar 2 '17 at 16:00

The sine function is not an injective function over the interval $(0,\pi)$. If you want to apply the substitution $\sin(x)\mapsto z$, you have to break the integration range in halves: this because a valid substitution is given by a diffeomorphism, not just a differentiable map.

In simple words, you are allowed to state that $$\int_{a}^{b}f(x)\,dx = \int_{g^{-1}(a)}^{g^{-1}(b)} f(g(s))\,g'(s)\,ds$$ only if $g$ is an injective function over the involved integration range, and $\sin(x)$ is not injective over $(0,\pi)$. Otherwise you would get $\int_{0}^{\pi}\sin(x)\,dx=0$ and that is clearly wrong.

A possible way to go is: since the $\sin(x)$ function is symmetric with respect to the point $x=\pi/2$, $$\int_{0}^{\pi}\frac{\sin(x)\,dx}{1+\sin(x)}=2\int_{0}^{\pi/2}\frac{\sin(x)\,dx}{1+\sin(x)}=2\int_{0}^{1}\frac{t\,dt}{(1+t)\sqrt{1-t^2}}.$$

That is correct, even if not the most efficient way for computing such integral.
A more efficient way is to set $x=2\arctan\frac{t}{2}$ (aka Weierstrass substitution) to get $$16\int_{0}^{+\infty}\frac{t\,dt}{(4+t^2)(2+t)^2}$$ that can be tackled through partial fraction decomposition.

Method 2 fails since on $[0,\pi]$, $\sin(x)$ is not monotone, so we don't have a good inverse to apply. We need to break the interval into intervals on which $\sin(x)$ is monotone. For example, $\left[0,\frac\pi2\right]$ and $\left[\frac\pi2,\pi\right]$. In fact, using the substitution $x\mapsto\pi-x$, we get $$\int_0^{\pi/2}\frac{\sin(x)}{1+\sin(x)}\,\mathrm{d}x=\int_{\pi/2}^\pi\frac{\sin(x)}{1+\sin(x)}\,\mathrm{d}x$$ so that \begin{align} \int_0^\pi\frac{\sin(x)}{1+\sin(x)}\,\mathrm{d}x &=2\int_0^{\pi/2}\frac{\sin(x)}{1+\sin(x)}\,\mathrm{d}x\\ &=2\int_0^1\frac{t}{1+t}\,\mathrm{d}\arcsin(t)\\ &=2\int_0^1\frac{t}{1+t}\frac{\mathrm{d}t}{\sqrt{1-t^2}}\\ &=2\int_0^1\left(1-\frac1{1+t}\right)\frac{\mathrm{d}t}{\sqrt{1-t^2}}\\ &=\pi-2\int_0^1\frac1{1+t}\frac{\mathrm{d}t}{\sqrt{1-t^2}}\\ &=\pi-2\left[-\sqrt{\frac{1-t}{1+t}}\,\right]_0^1\\[6pt] &=\pi-2 \end{align}

• Rob, did I make a mistake below? Thank you in advance. – Math-fun Mar 2 '17 at 17:31
• I haven't looked, but the question was not how to evaluate the integral; it was why was Method 2 failing. The OP already evaluated the integral using an alternate method. – robjohn Mar 2 '17 at 18:06

Hint: set $$t=\tan(x/2)$$ and then we have $$\sin(x)=\frac{2t}{1+t^2}$$

• Sorry But I don't understand how this answers my question of why the substitution of $\sin(x)=t$ does not work. – Freelancer Mar 2 '17 at 15:40

While the tangent half angle substitution (Weierstrass sub) is a general approach that works, as suggested by Sonnhard, it can be avoided here since you may not be familiar with that tool of integration, so here is another approach by FIRST rewriting and splitting the numerator: $$\frac{sinx}{1+sinx}=\frac{1+sinx-1}{sinx+1}=1-\frac{1}{1+sinx}$$ The latter can be integrated by multiplying top an bottom by $1-sinx$. It then becomes really easy. As Jack suggested, be a little careful with those limits...Give it try

\begin{align} \frac{\sin x}{1+\sin x}&=1-\frac{1}{1+\sin x}\\ &=1-\frac{1}{\left(\cos \frac x2+\sin \frac x2\right)^2}\\ &=1-\frac{\cos^2 \frac x2+\cos \frac x2 \sin \frac x2+ \sin^2\frac x2-\cos \frac x2 \sin\frac x2}{\left(\cos \frac x2+\sin \frac x2\right)^2}\\ &=1-\frac{\cos \frac x2\left(\cos \frac x2+ \sin \frac x2\right)-2 \sin\frac x2\left(-\frac12\sin\frac x2+\frac12\cos \frac x2 \right)}{\left(\cos \frac x2+\sin \frac x2\right)^2}\\ &=\frac{d}{dx}\left(x-\frac{2\sin \frac x2}{\cos \frac x2+\sin \frac x2}\right) \end{align} Hence \begin{align} \color{red}{\int_0^{\pi}\frac{\sin x}{1+\sin x}dx=\pi-2}. \end{align}

• Not Trying to be rude or anything , But Honestly This answer was not necessary. – Freelancer Mar 2 '17 at 18:17