Calculate the integral $\int_0^\pi \frac{1}{1+\sin^2(t)} \,dt$ Calculate the integral $$\int_0^\pi \frac{1}{1+\sin^2(t)} \,dt$$ I tried to solve with the help of the identity $$\sin (t)=\frac{\tan(t)}{\sec(t)}$$ and  $$u=\tan(t)$$ then $$dt=\frac{du}{\sec^2(t)}$$ got $$\int_0^\pi \frac{1}{1+\sin^2(t)} \,dt= \arctan(\sqrt{2} \tan(t))|_0^\pi = 0.$$ But I want to use the identity $$\sin(t)=\frac {e^{it}-e^{-it}}{2}$$ with $$z=e^{it}$$ while $$|z|=1$$ I got as a result $$\int_{|z|=1} \frac{z^2}{(z-1)^2(z+1)^2 }\frac{1}{iz} \,dz$$
 A: Your result is incorrect due to issues with symmetry. This is an easy fix however, as $$J=\int_0^\pi\frac{dx}{1+\sin^2x}=2\int_0^{\pi/2}\frac{dx}{1+\sin^2x}.$$
Then use $\sin^2+\cos^2=1$ to get
$$J=2\int_0^{\pi/2}\frac{dx}{2-\cos^2(x)}.$$
We see then that 
$$\frac{1}{a^2-u^2}=\frac1{2a}\left(\frac{1}{a+u}+\frac{1}{a-u}\right).$$
With this, we use $a=\sqrt2$ and $u=\cos x$ to get
$$J=\frac1{\sqrt2}\int_0^{\pi/2}\frac{dx}{\sqrt2+\cos x}+\frac1{\sqrt2}\int_0^{\pi/2}\frac{dx}{\sqrt2-\cos x}.$$
For this, set $$f(a,q)=\int_0^{\pi/2}\frac{dx}{a+q\cos x},$$
and use $t=\tan(x/2)$ to get $$f(a,q)=2\int_0^1\frac{1}{a+q\frac{1-t^2}{1+t^2}}\frac{dt}{1+t^2}=\frac{2}{a-q}\int_0^1\frac{dt}{\frac{a+q}{a-q}+t^2}.$$
Then we have
$$f(a,q)=\frac{2}{\sqrt{a^2-q^2}}\arctan\sqrt{\frac{a-q}{a+q}}\, .$$
Hence
$$J=\sqrt{2}\arctan(\sqrt2+1)+\sqrt{2}\arctan(\sqrt2-1)=\frac\pi{\sqrt2}.$$
A: Your integral is not correct because of the singularities that cause a discontinuity at $x=\frac{\pi}{2}$. The real answer to that integral is
$$\frac{1}{\sqrt{2}}\arctan(\sqrt{2}\tan(t)) \Biggr|_0^{\frac{\pi^{-}}{2}} + \frac{1}{\sqrt{2}}\arctan(\sqrt{2}\tan(t)) \Biggr|_{\frac{\pi^+}{2}}^\pi$$ $$ = \frac{1}{\sqrt{2}}\left(\frac{\pi}{2} - 0 \right) + \frac{1}{\sqrt{2}}\left(0 - \frac{-\pi}{2}\right) = \frac{\pi}{\sqrt{2}}$$
