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}$$

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*}
$$
