# Is there another way to solve this integral?

My way to solve this integral. I wonder is there another way to solve it as it's very long for me.

$$\int_{0}^{\pi}\frac{1-\sin (x)}{\sin (x)+1}dx$$

Let $$u=\tan (\frac{x}{2})$$ $$du=\frac{1}{2}\sec ^2(\frac{x}{2})dx$$

By Weierstrass Substitution

$$\sin (x)=\frac{2u}{u^2+1}$$

$$\cos (x)=\frac{1-u^2}{u^2+1}$$

$$dx=\frac{2du}{u^2+1}$$

$$=\int_{0}^{\infty }\frac{2(1-\frac{2u}{u^2+1})}{(u^2+1)(\frac{2u}{u^2+1}+1)}du$$

$$=\int_{0}^{\infty }\frac{2(u-1)^2}{u^4+2u^3+2u^2+2u+1}du$$

$$=2\int_{0}^{\infty }\frac{(u-1)^2}{u^4+2u^3+2u^2+2u+1}du$$

$$=2\int_{0}^{\infty }\frac{(u-1)^2}{(u+1)^2(u^2+1)}du$$

$$=2\int_{0}^{\infty }(\frac{2}{(u+1)^2}-\frac{1}{u^2+1})du$$

$$=-2\int_{0}^{\infty }\frac{1}{u^2+1}du+4\int_{0}^{\infty}\frac{1}{(u+1)^2}du$$

$$\lim_{b\rightarrow \infty }\left | (-2\tan^{-1}(u)) \right |_{0}^{b}+4\int_{0}^{\infty}\frac{1}{(u+1)^2}du$$

$$=(\lim_{b\rightarrow \infty}-2\tan^{-1}(b))+4\int_{0}^{\infty}\frac{1}{(u+1)^2}du$$

$$=-\pi+4\int_{0}^{\infty}\frac{1}{(u+1)^2}du$$

Let $$s=u+1$$

$$ds=du$$

$$=-\pi+4\int_{1}^{\infty}\frac{1}{s^2}ds$$

$$=-\pi+\lim_{b\rightarrow \infty}\left | (-\frac{4}{s}) \right |_{1}^{b}$$

$$=-\pi+(\lim_{b\rightarrow \infty} -\frac{4}{b}) +4$$

$$=4-\pi$$

$$\approx 0.85841$$

• I think multiplying top and bottom by bottom's conjugate was another way to proceed to get the integral all pretty like. – randomgirl Mar 17 '15 at 17:17
• You might not appreciate this but, now that you did all that work, you can just use the fundamental theorem of calculus to prove the result. – Zach466920 Mar 17 '15 at 17:18
• @Zach466920, it seems to me that Mathxx is using FTC (among other things, to justify $u$-substitutions and to evaluate the integral of $1/s^2$). What shorter usage of it did you have in mind? – LSpice Mar 17 '15 at 18:14
• @Jade NB the fundamental theorem states that the derivative is the inverse of integration and vice versa. So in theory if the derivative of a function F(x) equals the integrand. F(x) is the integral, no need for advanced techniques. In other words, it can formalize a guess for an integral. – Zach466920 Mar 17 '15 at 19:19
• @Zach466920, but, unless you are proposing the answer "$F(\pi) - F(0)$, where $F$ is an anti-derivative of $x \mapsto (1 - \sin(x))/(1 + \sin(x))$" (which seems hardly likely to satisfy, and certainly doesn't make it clear that the numerical value is $4 - \pi$), how does that help? – LSpice Mar 17 '15 at 20:18

Substitute $x=\pi/2-2t$ so the integral becomes $$-2\int_{\pi/4}^{-\pi/4}\frac{1-\cos 2t}{1+\cos 2t}\,dt= 2\int_{-\pi/4}^{\pi/4}\frac{1-\cos^2t}{\cos^2t}\,dt =2\Bigl[\tan t - t\Bigr]_{-\pi/4}^{\pi/4}$$

First use partial fractions to get rid of the sine in the numerator: $$\int_0^{\pi} \frac{1-\sin{x}-1+1}{1+\sin{x}} \, dx = \int_0^{\pi} \left( \frac{2}{1+\sin{x}} - 1 \right) \, dx = -\pi + \int_0^{\pi} \frac{2 \, dx}{1+\sin{x}}.$$ We have the identity $$1+\sin{x} = 2\sin^2{\left( \frac{x}{2} + \frac{\pi}{4} \right)}$$ (from $\cos{2\theta}=1-2\sin^2{\theta}$ and $\sin{\theta}=-\cos{(\theta+\pi/2)}$), so the remaining integral is $$\int_0^{\pi} \csc^2{\left( \frac{x}{2} + \frac{\pi}{4} \right)} \, dx = \left[ -2 \cot{\left( \frac{x}{2} + \frac{\pi}{4} \right)} \right]_0^{\pi} = -2(-1-1) = 4$$

• I wouldn't call that 'partial fractions' (which usually implies a factorisation of the denominator) so much as just 'fraction arithmetic'. – LSpice Mar 17 '15 at 18:13
• I suppose, although it's listed under the same heading in my brain. Not sure it has a specific name other than something like "turning into a proper fraction". – Chappers Mar 17 '15 at 20:10
• I think that 'proper fraction' itself has little meaning outside the setting of numeric fractions (i.e., elements of $\mathbb Q$) or, maybe, fractions with numerator and denominator drawn from a Euclidean domain (like $\mathbb Z$ or a polynomial ring). I would call your second fraction 'proper' in comparison to the first only in the sense that it allows one to compute the integral more easily. (Anyway, despite all the space I've just taken, the computation, which is certainly good, is more important than the specific terms used to describe it!) – LSpice Mar 17 '15 at 20:20
• There's a fair amount on the Internet about "proper rational functions", which are elements $f/g$, $f,g \in k[X]$, $g \neq 0$ with $\deg{f}<\deg{g}$. That's probably equivalent to what I was remembering from my school algebra. – Chappers Mar 17 '15 at 21:29

Multiply numerator and denominator by $1 - \sin x$. So that $\displaystyle\int_0^\pi \dfrac{1-\sin x}{1+\sin x} \cdot \dfrac{1-\sin x}{1-\sin x}dx$

$$= \displaystyle\int_0^\pi \dfrac{1-2\sin x+ \sin^2x}{\cos^2x}dx = \int_0^\pi \sec^2x - 2\dfrac{\sin x}{\cos^2x} + \tan^2x dx$$

We know that $\tan^2x + 1 = \sec^2x$. So the integral would look like: $$= \int_0^\pi 2\sec^2x -1 - 2\dfrac{\sin x}{\cos^2x}dx$$

We know the integral of $\sec^2x$ is just $\tan x$, and the last integrand can be solved by letting $u=\cos x$.

• Or for the last integrand, observing that $\frac{\sin x}{\cos^2 x} = \frac{\sin x}{\cos x} \cdot \frac{1}{\cos x} = \tan x \sec x$ which may be more recognisable as the derivative of $\sec x$. – Silverfish Mar 17 '15 at 21:26
• oh yeah, i didn't notice that! – cgo Mar 18 '15 at 2:15
• The most intuitive in my opinion. – michaelsnowden Mar 18 '15 at 17:06

Hint: Note that by symmetry our integral is twice the integral from $0$ to $\pi/2$. Then by symmetry replace $\sin x$ by $\cos x$. Then use the identities $\cos x=2\cos^2 (x/2)-1=1-2\sin^2(x/2)$.

\begin{align} A &= \int_{0}^{\pi}\left(\:\frac{1\:-\:\sin (x)}{\sin (x)\:+\:1}\:\right)dx \\ F(x) &= \int\left(\:\frac{1\:-\:\sin (x)}{\sin(x)\:+\:1 }\cdot\frac{\sin(x)\:-\:1}{\sin (x)\:-\:1 }\:\right)dx \\ &= \int\left(\:\frac{ -\sin^2(x) + 2\cdot sin(x)-1}{\sin^2(x)\:-\:1 }\:\right)dx \\ &= \int\left(\:\frac{ -(\sin^2(x) - 2\cdot sin(x)+1)}{-(1-\sin^2(x)) }\:\right)dx \\ &= \int\left(\:\frac{ (\sin^2(x) - 2\cdot sin(x)+1)}{(1-\sin^2(x)) }\:\right)dx \\ &= \int\left(\:\frac{\sin^2(x) - 2\cdot sin(x)+1}{\cos^2(x) }\:\right)dx \\ &= \int\left(\:\frac{\sin^2(x)}{\cos^2(x)}-\frac{ 2\cdot sin(x)}{\cos^2(x)}+\frac{1}{\cos^2(x)}\:\right)dx \\ &= \int\left(\:\frac{\sin^2(x)}{\cos^2(x)}\right)dx-\int\left(\frac{2\cdot sin(x)}{\cos^2(x)}\right)dx+\int\left(\frac{1}{\cos^2(x)}\:\right)dx \\ F(x) &= \tan(x) - x - 2\cdot\sec(x) + \tan(x)\\ A &= F(\pi) - F(0)\\ F(\pi) - F(0) &= (\tan(\pi) - \pi - 2\cdot\sec(\pi) + \tan(\pi))-(\tan(0) - 0 - 2\cdot\sec(0) + \tan(0))\\ &= (0 - \pi - 2\cdot-1 + 0)-(0 - 0 - 2\cdot1 + 0)\\ &= (-\pi + 2)-(-2)\\ &= -\pi + 2+2\\ &= 4-\pi\\ \end{align}

The question asked "is there another way", so here's another one. Start by removing the trig from the numerator:

$$\int_0^{\pi} \frac{1-\sin{x}}{1+\sin{x}} \, \mathrm{d}x = \int_0^{\pi} \frac{2 - (1 +\sin{x})}{1+\sin{x}} \, \mathrm{d}x = \int_0^{\pi} \left( \frac{2}{1+\sin{x}} - 1 \right) \, \mathrm{d}x = -\pi + \int_0^{\pi} \frac{2 \, \mathrm{d}x}{1+\sin{x}}$$

There are many ways to solve this but I would like to demonstrate the substitution $u = 1 + \sin x$. It would be much more convenient if the limits ran from $0$ to $\frac{\pi}{2}$, so that $x = \sin^{-1} (u-1)$ is a continuous, monotonic function from $[1,2]$ to $[0,\frac{\pi}{2}]$, and also because $\cos x$ and $\sin x$ are both positive for $0 \leq x \leq \frac{\pi}{2}$. The latter property is often useful so we can write $\cos x=\sqrt{1-\sin^2 x}$ and $\sin x=\sqrt{1-\cos^2 x}$. Fortunately symmetry considerations allow a change of limits:

$$\int_0^{\pi} \frac{2 \, \mathrm{d}x}{1+\sin{x}} = \int_0^{\pi/2} \frac{4 \, \mathrm{d}x}{1+\sin{x}}$$

We have $\frac{\mathrm{d}u}{\mathrm{d}x} = \cos x = \sqrt{1-\sin^2 x} = \sqrt{1-(u-1)^2} = \sqrt{2u - u^2}$ so the integral becomes:

$$\int_0^{\pi/2} \frac{4 \, \mathrm{d}x}{1+\sin{x}} = \int_1^2 \frac{4 \, \mathrm{d}u}{u \sqrt{2u - u^2}} = \int_1^2 \frac{4 \, \mathrm{d}u}{u \sqrt{-u(u-2)}}$$

This might look fearsome but is actually very amenable to the third Euler substitution, since we have a factorised quadratic expression inside the square root. The computation is very similar to this answer. In general the substitution is $\sqrt{au^2 + bu + c} = \sqrt{a(u-\alpha)(u-\beta)} = (u-\alpha)t$ which gives $u = \frac{a\beta-\alpha t^2}{a-t^2}$; in our case we can take $a=-1$, $b=2$, $c=0$, $\alpha=0$, and $\beta=2$ with $\sqrt{-u(u-2)} = ut$.

Since $u=\frac{(-1)(2)-0t^2}{-1-t^2}=2(t^2+1)^{-1}$ we obtain $\frac{\mathrm{d}u}{\mathrm{d}t} = -4t(t^2+1)^{-2}$ and to change the limits we set $t=\frac{\sqrt{-u(u-2)}}{u} = \sqrt{\frac{2-u}{u}}$. The remaining integral becomes:

$$\int_1^2 \frac{4 \, \mathrm{d}u}{u \sqrt{-u(u-2)}} = \int_1^0 \frac{4 (-4t)(t^2+1)^{-2} \, \mathrm{d}t}{u^2 t} = \int_0^1 \frac{4 (4t)(t^2+1)^{-2} \, \mathrm{d}t}{4(t^2+1)^{-2} t} = \int_0^1 4 \, \mathrm{d}t = 4$$

This was not the most straightforward way to find the result $4 - \pi$, but I just wanted to draw out the similarity between this integral and one the original poster had asked about before (the main differences being the trig in the numerator - which is easily removed - and the limits).

Contour integration is quite a good idea in this case. On the unit circle, we have

$$z=e^{ix}=\cos x + i \sin x$$ and therefore $$\sin x=\frac{z-z^{-1}}{2i}$$ and $$dz=iz\,dx$$ Substitution makes the integral

$$I=\int_C \frac{1}{zi}\frac{-z^2+2iz+1}{z^2+2iz-1}dz=-\int_C\frac{1}{zi}\frac{(z-i)^2}{(z+i)^2}dz=$$ $$=i\int_C\frac{1}{z}\left(\frac{z^2-1-2zi}{z^2+1}\right)^2dz$$ where the integration contour $C$ is the upper half of the unit arc (clockwise). Now you can consider integration around the upper half of the unit disc. The integration splits symbolically as

$$\text{residue}=\int_{-1}^1+\int_C$$ The residue unfortunately lies directly on the integration path, at $z=0$, and is equal to $\operatorname{Res}=i$. As the path is straight at the residue, you can take the Cauchy principal value of the integral and use half the residue:

$$I=\frac12 2\pi i (i)-i\int_{-1}^1 \frac{1}{z}\left(\frac{z^2-1-2zi}{z^2+1}\right)^2dz$$ $$=-\pi-i\int_{-1}^1 \frac{1}{z}\left(\frac{(z^2-1)^2-4z^2-4zi(z^2-1)}{(z^2+1)^2}\right)dz$$ We keep only the even terms under the integral (this is the "Cauchy principal value" step): $$I=-\pi-4\int_{-1}^1 \frac{(z^2-1)}{(z^2+1)^2}dz \quad (*)$$ $$I=-\pi-4\int_{-1}^1 \left(\frac{1}{z^2+1}-\frac{2}{(z^2+1)^2}\right)dz$$ These integrals are elementary (or tabulated in the case of the last term) and lead to the result $$I=-\pi-4(\pi/2-2\cdot 1/2(1+\pi/2)))=4-\pi$$

Essentially, the only integral to compute is the one marked $(*)$, the rest is just simplification of rational functions. The integral seems to be more trivial than it looks (splitting it as I have is apparently not the most optimal solution, as half of it cancels out). If anyone notices a clever trick to get $\int (x^2-1)/(1+x^2)^2dx=-x/(1+x^2)$ (apart from exclaiming "it's obvious now" when you see the result), let me know in the comments.

• Probably the simplest way is to split into the fractions $\frac{2x^2}{(1+x^2)^2}-\frac{1}{1+x^2}$, although this isn't very intuitive. As a rule, these rational functions tend not to yield easily: probably the safest way is to split off the $x^2$ term and integrate it by parts, which produces an integral that cancels the other one. – Chappers Mar 18 '15 at 10:36

Yet another way. Using $u=\tan(x)$, we get \begin{align} \int\frac{1-\sin(x)}{1+\sin(x)}\,\mathrm{d}x &=\int\lower{2pt}{\frac{1-\frac{u}{\sqrt{1+u^2}}}{1+\frac{u}{\sqrt{1+u^2}}}\frac{\mathrm{d}u}{1+u^2}}\\ &=\int\left(1-\raise{2pt}{\frac{u}{\sqrt{1+u^2}}}\right)^{\!\!2}\,\mathrm{d}u\\ &=\int\left(2-\raise{2pt}{\frac{2u}{\sqrt{1+u^2}}}-\frac1{1+u^2}\right)\,\mathrm{d}u\\[6pt] &=2u-2\sqrt{1+u^2}-\arctan(u)+C\\[14pt] &=2\tan(x)-2\sec(x)-x+C \end{align} Therefore, \begin{align} \int_0^\pi\frac{1-\sin(x)}{1+\sin(x)}\,\mathrm{d}x &=(2-\pi)-(-2)\\[6pt] &=4-\pi \end{align}

$\big[$Another (standard) method$\big]$

When we have integrals of the form: $\displaystyle \int \frac{dx}{a+b\sin (x) + c\cos (x)}$ we can perform the substitution: $t=\tan (x/2)$. Then, we have: $\displaystyle \sin(x) = \frac{2t}{1+t^2}$ , $\displaystyle \cos (x) = \frac{1-t^2}{1+t^2}$ , $\displaystyle dx= \frac{2dt}{1+t^2}$.

First we must remove the sine term from the numerator.

$\displaystyle \int_0^{\pi} \frac{1-\sin(x) -1 + 1}{\sin(x) + 1} dx = \int_0^{\pi} \frac{2}{\sin(x)+1} -1 dx$

Now we substitute. Also @$x=0 \rightarrow t=0$ and @$x=\pi \rightarrow t=\infty$. Thus:

$\displaystyle \int_0^{\infty} \Bigg( \frac{2}{\frac{2t}{1+t^2} +1} -1 \Bigg) \cdot \frac{2}{1+t^2} dt = \int_0^{\infty} \frac{4}{2t+1+t^2} - \frac{2}{1+t^2} dt =$

$\displaystyle = \int_0^{\infty} \frac{4}{(t+1)^2} dt - 2\tan^{-1}(t)\big|_0^{\infty} = 4 \left[ -\frac{1}{t+1} \right]_0^{\infty} -2\frac{\pi}{2} = -4 \left( \frac{1}{\infty} - \frac{1}{0+1} \right) -\pi = 4-\pi$