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

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