Show $ I = \int_0^{\pi} \frac{\mathrm{d}x}{1+\cos^2 x} = \frac{\pi}{\sqrt 2}$ Show  $$ I = \int_0^{\pi} \frac{\mathrm{d}x}{1+\cos^2 x} = \frac{\pi}{\sqrt 2}$$
 A: In case KV's solution seems a bit magical, it may be reassuring to know that there's a systematic way to integrate rational functions of trigonometric functions, the Weierstraß substitution.
With $\cos x=(1-t^2)/(1+t^2)$ and $\mathrm dx=2/(1+t^2)\mathrm dt$,
$$
\begin{eqnarray}
\int_0^\pi \frac{\mathrm dx}{1+\cos^2 x}
&=&
\int_0^\infty\frac2{1+t^2} \frac1{1+\left(\frac{1-t^2}{1+t^2}\right)^2}\mathrm dt
\\
&=&
\int_0^\infty \frac{2(1+t^2)}{(1+t^2)^2+(1-t^2)^2}\mathrm dt
\\
&=&
\int_0^\infty \frac{1+t^2}{1+t^4}\mathrm dt\;.
\end{eqnarray}
$$
Here's where it gets a bit tedious. The zeros of the denominator are the fourth roots of $-1$, and assembling the conjugate linear factors into quadratic factors yields
$$
\begin{eqnarray}
\int_0^\infty \frac{1+t^2}{1+t^4}\mathrm dt
&=&
\int_0^\infty \frac{1+t^2}{(t^2+\sqrt2t+1)(t^2-\sqrt2t+1)}\mathrm dt
\\
&=&
\frac12\int_0^\infty \frac1{(t^2+\sqrt2t+1)}+\frac1{(t^2-\sqrt2t+1)}\mathrm dt
\\
&=&
\frac12\left[\sqrt2\arctan(1+\sqrt2t)-\sqrt2\arctan(1-\sqrt2t)\right]_0^\infty
\\
&=&
\frac\pi{\sqrt2}\;.
\end{eqnarray}
$$
A: If we make the standard "Weierstrass" $t=\tan(x/2)$ substitution, we get $\cos t=\frac{1-t^2}{1+t^2}$ and $dx=\frac{2\,dt}{1+t^2}$. We end up quickly with
$$\int_0^\infty \frac{1+t^2}{1+t^4}\,dt.$$
But $1+t^4=(1-\sqrt{2}t+t^2)(1+\sqrt{2}t +t^2)$, so by partial fractions our integrand is 
$$\frac{1}{2-2\sqrt{2}t+2t^2} +\frac{1}{2+2\sqrt{2}t+2t^2}.$$
Completing the squares, we end up with the integrand
$$\frac{1}{1+(\sqrt{2}t-1)^2}+\frac{1}{1+(\sqrt{2}t+1)^2}.$$
The substitutions $u=\sqrt{2} t-1$ and $u=\sqrt{2}t+1$ give
$$\int_{-1}^\infty \frac{1}{\sqrt{2}}\frac{du}{1+u^2}+\int_{1}^\infty \frac{1}{\sqrt{2}}\frac{du}{1+u^2}.$$
The first integral is $(1/\sqrt{2})(3\pi/4)$ and the second is $(1/\sqrt{2})(\pi/4)$. Add. We get $\pi/\sqrt{2}$.
A: First notice that the function $\displaystyle{\frac{1}{1+\cos^2 x}}$ is an even function, and therefore 
$$ \int_0^{\pi} \frac{\mathrm{d}x}{1+\cos^2 x} = 2 \int_0^{\frac{\pi}{2}} \frac{\mathrm{d}x}{1+\cos^2 x}$$
$$ \begin{align*} 
2 \int_0^{\frac{\pi}{2}} \frac{1}{1+\cos^2 x} \,\mathrm{d}x &= 2 \int_0^{\frac{\pi}{2}} \frac{\frac{1}{\cos^2 x}}{\left(\frac{1}{\cos^2 x}+1\right)}\mathrm{d}x \\
&=  2 \int_0^{\frac{\pi}{2}} \frac{\sec^2 x}{\sec^2 x+1} \mathrm{d}x \\
&= 2 \int_0^{\frac{\pi}{2}} \frac{\sec^2 x}{(\tan^2 x+1)+1} \mathrm{d}x & (\text{because} \hspace{4pt} \sec^2 x=\tan^2 x+1)\\
&=  \int_0^{\frac{\pi}{2}} \frac{{\small{2}} \sec^2 x}{\tan^2 x+2} \mathrm{d}x \\
&=  \int_0^{\frac{\pi}{2}} \frac{\sec^2 x}{\left(\frac{\tan x}{\sqrt 2}\right)^2+1}\mathrm{d}x 
 \end{align*} 
$$ 
Now substitute 
$$\frac{\tan x}{\sqrt 2} = t \Longrightarrow  \sec^2 x \; \mathrm{d}x = \sqrt 2 \; \mathrm{d}t \hspace{5pt}$$ 
applying the new limits, the integral gets simplfied to 
$$ 
\begin{align*}
\sqrt 2 \int_0^\infty \frac{\mathrm{d}t}{t^2+1} &= \sqrt 2 \left( \left. \tan^{-1} t \right|_0^\infty \right) \\
&= \sqrt 2 \left(\frac{\pi}{2}\right) = \frac{\pi}{\sqrt{2}}
\end{align*}
$$
A: Based on KV Raman,$\displaystyle{\frac{1}{1+\cos^2 x}}$ is even function.
$$\int_0^{\pi} \frac{\mathrm{d}x}{1+\cos^2 x} = 2 \int_0^{\frac{\pi}{2}} \frac{\mathrm{d}x}{1+\cos^2 x}$$
$$
\begin{align*} 
\int_0^{\frac{\pi}{2}} \frac{1}{1+\cos^2 x} \,\mathrm{d}x &=\int_0^{\frac{\pi}{2}}\frac{\mathrm{d}x}{\sin^2 x+2\cos^2 x}\\
&= \int_0^{\frac{\pi}{2}}\frac{\sec^2 x\mathrm{d}x}{\tan ^2 x+2}\\
&=\int_0^{\frac{\pi}{2}}\frac{\mathrm{d}\tan x}{\tan ^2 x +2}\\
 \end{align*}
$$
below is the same
