# calculate $\int_0^\pi\frac {dx}{1+\sin^2x}$

I need to calculate this integral:

$\int_0^\pi\frac {dx}{1+\sin^2x}$

I know how to solve $\int\frac {dx}{1+\sin^2x}$, I did it by substitute $t=\operatorname{cot}(x)$. But here in order to do the substitution I need to calculate the new limits by $t=\operatorname{cot}(0), t=\operatorname{cot}(\pi)$, but $\operatorname{cot}$ is not defined in $0$ and $\pi$ so I don't know how to find the new limits.

Any help will be appreciated!

• The limits should be the limit values of the endpoints, so $\infty$ to $-\infty$ – Jacob Apr 14 '18 at 20:31
• you can always use en.wikipedia.org/wiki/… followed, as a rule, by partial fractions. – Will Jagy Apr 14 '18 at 20:34
• You should replace $\int_0^\pi$ with $2\int_0^{\pi/2}$ to exploit a symmetry before you use substitution. – J.G. Apr 14 '18 at 21:09

Here's a very ridiculous and ill-advised approach; throughout, I'll sweep technical details under the rug, but rest assured Euler probably wouldn't care so maybe you shouldn't care too much either.

Expanding as a power series, we get $$\int_{0}^{\pi} \frac{1}{1+\sin^2 (x)} \, dx = \int_{0}^{\pi} \left(\sum_{k=0}^{\infty} (-1)^{k} \sin^{2k} (x) \right) \, dx = \sum_{k=0}^{\infty} (-1)^{k} \left( \int_{0}^{\pi} \sin^{2k} (x) \, dx \right) = \sum_{k=0}^{\infty} (-1)^k a_k$$ where we have set $a_{k} = \int_{0}^{\pi} \sin^{2k} (x) \,dx$.

Let us compute a generating function for this sequence $\{a_k\}$. The standard "power-reduction" formula (you can get it from integrating by parts) gives $$a_k = \frac{2k-1}{2k} a_{k-1} = \left(1 - \frac{1}{2k} \right) a_{k-1}$$

Define the function $$f(x) = \sum_{k=0}^{\infty} \frac{a_k}{k+1} x^{k+1}$$ Note that $f'(x) = \sum_{k=0}^{\infty} a_k x^k$, which is the usual generating function, and the value of the sum in question is $f'(-1)$. The recurrence gives us the relation $2(a_k - a_{k-1}) = -a_{k-1}/k$, so we have $$\frac{f(x)}{x} = \sum_{k=0}^{\infty} \frac{a_k}{k+1} x^k = \sum_{k=0}^{\infty} -2(a_{k+1} - a_k) x^k = 2\left( f'(x) - \frac{f'(x) - a_0}{x}\right)$$

Now, we have to solve the differential equation (since $a_0 = \pi$) $$f(x) = 2(\pi + xf'(x)-f'(x) ) \implies f(x) - 2\pi = 2(x-1)f'(x)$$ which we can solve easily by separation of variables. This yields (using the initial condition $f(0) = 0$) the function $$f(x) = 2\pi(1 - \sqrt{1-x})$$ In our final act of brazen recklessness, we ignore all issues of convergence and evaluate $$f'(-1) = \frac{\pi}{\sqrt{2}}$$ Miraculously, we have obtained the right answer (which you can check by evaluating the integral in a sane way, e.g. a trig sub).

• +1 For a very nonstandard approach. BTW: dis you put another funny (it is nothing against you) solutions here? It would be nice to see tham. :-) – Przemysław Scherwentke Apr 14 '18 at 21:45

The integral can still be evaluated with the substitution $x\mapsto\cot x$. First, multiply the numerator and denominator by $\csc^2x$ to get$$I=\int\limits_0^{\pi}dx\,\frac {\csc^2x}{\csc^2x+1}=\int\limits_0^{\pi}dx\,\frac {\csc^2x}{\cot^2x+2}$$Now substitute $x\mapsto\cot x$. The lower limit becomes $+\infty$ while the upper limit becomes $-\infty$. Hence\begin{align*}I & =-\int\limits_{\infty}^{-\infty}dx\,\frac 1{x^2+2}=\int\limits_0^{\infty}dx\,\frac 1{\left(\frac x{\sqrt2}\right)^2+1}\end{align*}The remaining integral can be evaluated in terms of the inverse tangent function, and the final answer comes out to be

$$I=\frac {\pi}{\sqrt2}$$

• This is the first time I see +-infinity as integral limits, we still didn't get to this, I guess. – Avishay28 Apr 14 '18 at 20:55
• @Avishay28 Oh it's fine then. I wouldn't worry too much about it just yet if you guys haven't gotten there yet. There might be a better way to evaluate this integral without the "infinity limits", I just haven't thought of it yet. – Crescendo Apr 14 '18 at 20:57
• @Avishay28 Also, does that mean you haven't learned about$$\int\limits_{0}^{\infty}\frac {dx}{1+x^2}=\frac {\pi}2$$? – Crescendo Apr 14 '18 at 20:57
• Yes I haven't. I guess the way to solve it is by substitute t=tan(x/2), it just become very complicated.. – Avishay28 Apr 14 '18 at 21:05

I don't know if you like residue method. In fact \begin{eqnarray} \int_0^\pi\frac{1}{1+\sin^2x}dx&=&\int_0^\pi\frac{1}{1+\frac{1-\cos(2x}{2}}dx\\ &=&\int_0^{\pi}\frac{2}{3-\cos(2x)}dx\\ &=&\int_0^{2\pi}\frac{1}{3-\cos(x)}dx\\ &=&\int_{|z|=1}\frac{1}{3-\frac{z+\frac1z}{2}}\frac{1}{iz}dz\\ &=&\frac1i\int_{|z|=1}\frac{2}{6z-z^2-1}dz\\ &=&\frac1i\cdot2\pi i\text{Re}(\frac{1}{6z-z^2-1},3-2\sqrt2)\\ &=&2\pi\cdot\frac2{4\sqrt2}\\ &=&\frac{\pi}{\sqrt2}. \end{eqnarray}

One way to avoid generalized integrals is to use the symmetry of cosine and sine more. This is done in the calculation below (in the step where the primitive is calculated, one could think of doing the substitution $u=\tan x$, in the last step we use the fact that $\arctan\sqrt{2}+\arctan(1/\sqrt{2})=\pi/2$). \begin{aligned} \int_0^\pi\frac{1}{1+\sin^2x}\,dx&=2\int_0^{\pi/2}\frac{1}{1+\sin^2x}\,dx\\ &=\int_0^{\pi/2}\biggl(\frac{1}{1+\sin^2x}+\frac{1}{1+\cos^2x}\biggr)\,dx\\ &=2\int_0^{\pi/4}\biggl(\frac{1}{1+\sin^2x}+\frac{1}{1+\cos^2x}\biggr)\,dx\\ &=2\biggl[\frac{1}{\sqrt{2}}\arctan(\tan(x)/\sqrt{2})+\frac{1}{\sqrt{2}}\arctan(\sqrt{2}\tan x)\biggr]_0^{\pi/4}\\ &=\frac{\pi}{\sqrt 2}. \end{aligned}

Symmetry and the substitution $s=\arctan u$ solve the problem almost instantly:

$$\int_{0}^{\pi}\frac{dx}{1+\sin^2 x}=2\int_{0}^{\pi/2}\frac{dx}{1+\sin^2 x}=2\int_{0}^{\pi/2}\frac{ds}{1+\cos^2 s}=2\int_{0}^{+\infty}\frac{du}{2+u^2}=\frac{\pi}{\sqrt{2}}.$$