Evaluating $I(x)=\int_{0}^{\frac{\pi}{2}}{\frac{du}{x^2\cos^2u+\sin^2u}}$

alternative-proofcalculusintegrationreal-analysis

The following is from a national junior contest of an african country.

Find the integral $$I(x)=\int_{0}^{\frac{\pi}{2}}{\frac{du}{x^2\cos^2u+\sin^2u}}$$

$$\underline{\textbf{My attempt:}}$$

Rewrite the integral as $$I(x)=\int_{0}^{\frac{\pi}{2}}{\frac{1+\tan^2u}{x^2+\tan^2u}}du$$ then do the substitution $\tan u=\lambda x$, this gives:
$$I(x)=\int_{0}^{\alpha}{\frac{1+\lambda^2x^2}{x^2+\lambda^2x^2}\times\frac{xd\lambda}{1+\lambda^2x^2}}=\frac{1}{x}\int_{0}^{\alpha}{\frac{d\lambda}{1+\lambda^2}}.$$
The problem is the value of $\alpha$, it seems that:

If $x>0$ we have to choose $\alpha=\infty$, if not $\alpha=-\infty$. This yields:

If $x>0\quad I(x)=\frac{\pi}{2x}$

If $x<0\quad I(x)=-\frac{\pi}{2x}$

Thus $I(x)=\frac{\pi}{2|x|}$ if $x\ne 0$
Is this correct? Any alternative proof?

$\textbf{Addendum}$: I tried solve it
using Feynman Trick without issue. I’m pretty lsure that one can do it with that trick. Waiting to see someone solve with Feynman. Merci!!!

Best Answer

\begin{align}I(x)&=\int_{0}^{\frac{\pi}{2}}{\frac{du}{x^2\cos^2u+\sin^2u}}\,du\\ &=\int_{0}^{\frac{\pi}{2}}{\frac{du}{x^2+\tan^2u}}\times \dfrac{1}{\cos^2 u}\,du\\ \end{align}

The function is not defined for $x=0$.

Observe that, $I(-x)=I(x)$

Perform the change of variable $y=\tan u$,and $x>0$ \begin{align}I(x)&=\int_{0}^{\infty}{\frac{du}{x^2+u^2}}\,\\ &=\left[\dfrac{1}{x}\arctan\left(\dfrac{u}{x}\right)\right]_0^{\infty}\\ &=\dfrac{\pi}{2x} \end{align} Therefore, For $x\neq 0$, $\boxed{I(x)=\dfrac{\pi}{2\left|x\right|}}$