Evaluation of the integral $\int_0^\infty \left(\frac{\pi^2}{4}-x^2\right)^{-2}\cdot\frac{\pi^2}{4}\cos^2 x\,dx$ What are the steps to evaluate the following definite integral? (Answer provided)
$$\int_0^\infty {{\pi^2\over 4}\cos^2x\over\left({\pi^2\over4}-x^2 \right)^2} dx={\pi\over 4}$$?

Contour integration is how I would approach this integral.
$$
\begin{align}
\int_0^\infty {{\pi^2\over 4}\cos^2x\over\left({\pi^2\over4}-x^2 \right)^2}\;\mathrm{d}x
&=\frac{1}{2}\int_{-\infty}^\infty {{\pi^2\over 4}\cos^2x\over\left({\pi^2\over4}-x^2 \right)^2} \;\mathrm{d}x\tag{1}\\
&=\frac{\pi^2}{2}\int_{-\infty}^\infty\frac{e^{2ix}+2+e^{-2ix}}{(\pi^2-4x^2)^2}\mathrm{d}x\tag{2}\\
&=\frac{\pi^2}{2}\int_{-\infty-i\epsilon}^{\infty-i\epsilon}\frac{e^{2ix}+2+e^{-2ix}}{(\pi^2-4x^2)^2}\mathrm{d}x\tag{3}\\
&=\frac{\pi^2}{2}\oint_{\gamma^+}\frac{e^{2ix}+1}{(\pi^2-4x^2)^2}\mathrm{d}x\\
&+\frac{\pi^2}{2}\oint_{\gamma^-}\frac{e^{-2ix}+1}{(\pi^2-4x^2)^2}\mathrm{d}x\tag{4}\\
&=\frac{\pi^2}{2}\oint_{\gamma^+}\frac{e^{2ix}+1}{(\pi^2-4x^2)^2}\mathrm{d}x\tag{5}\\
\end{align}
$$


*

*make the path a bit nicer. Since the integrand is even, let's duplicate the domain of integration and divide by two

*expand $\cos^2(x)=\dfrac{e^{2ix}+2+e^{-2ix}}{4}$

*move the path of integration. We cross no non-removable singularities and the connections near $+\infty$ and $-\infty$ vanish.

*break up the integral into two contours: $\gamma^+$ which passes from $-\infty-i\epsilon$ to $+\infty-i\epsilon$ and then circles back counter-clockwise around the upper half-plane, and $\gamma^-$ which passes from $-\infty-i\epsilon$ to $+\infty-i\epsilon$ and then circles back clockwise around the lower half-plane.

*$\gamma^-$ circles no singularities, so its integral is $0$.
Account for the residues of the singularities in $(5)$.
$$
\small\begin{array}{c}
\text{singularity}&&\text{integrand}&&\text{first order}&&\text{residue}\\
x=\frac{\pi}{2}&:&\frac{1-e^{2i(x-\pi/2)}}{(-2(x-\pi/2)(2\pi+2(x-\pi/2)))^2}&\to&\frac{-2i(x-\pi/2)}{16\pi^2(x-\pi/2)^2}&\to&\frac{1}{4\pi}\\
x=-\frac{\pi}{2}&:&\frac{1-e^{2i(x+\pi/2)}}{(2(x+\pi/2)(2\pi-2(x+\pi/2)))^2}&\to&\frac{-2i(x+\pi/2)}{16\pi^2(x+\pi/2)^2}&\to&\frac{1}{4\pi}
\end{array}
$$
Thus, the sum of the residues is $\frac{1}{2\pi}$. Including the $\frac{\pi^2}{2}$ yields an integral of $\frac{\pi}{4}$. 
