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}$$?
 A: 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}$. 
A: $\newcommand{\+}{^{\dagger}}%
 \newcommand{\angles}[1]{\left\langle #1 \right\rangle}%
 \newcommand{\braces}[1]{\left\lbrace #1 \right\rbrace}%
 \newcommand{\bracks}[1]{\left\lbrack #1 \right\rbrack}%
 \newcommand{\ceil}[1]{\,\left\lceil #1 \right\rceil\,}%
 \newcommand{\dd}{{\rm d}}%
 \newcommand{\down}{\downarrow}%
 \newcommand{\ds}[1]{\displaystyle{#1}}%
 \newcommand{\equalby}[1]{{#1 \atop {= \atop \vphantom{\huge A}}}}%
 \newcommand{\expo}[1]{\,{\rm e}^{#1}\,}%
 \newcommand{\fermi}{\,{\rm f}}%
 \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,}%
 \newcommand{\half}{{1 \over 2}}%
 \newcommand{\ic}{{\rm i}}%
 \newcommand{\iff}{\Longleftrightarrow}
 \newcommand{\imp}{\Longrightarrow}%
 \newcommand{\isdiv}{\,\left.\right\vert\,}%
 \newcommand{\ket}[1]{\left\vert #1\right\rangle}%
 \newcommand{\ol}[1]{\overline{#1}}%
 \newcommand{\pars}[1]{\left( #1 \right)}%
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\pp}{{\cal P}}%
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,#2\,}\,}%
 \newcommand{\sech}{\,{\rm sech}}%
 \newcommand{\sgn}{\,{\rm sgn}}%
 \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}}
 \newcommand{\ul}[1]{\underline{#1}}%
 \newcommand{\verts}[1]{\left\vert\, #1 \,\right\vert}$
$\ds{\int_{0}^{\infty}{{\pi^{2} \over 4}\cos^{2}\pars{x} \over
     \pars{{\pi^{2} \over 4} -x^{2}}^{2}}\,\dd x = {\pi \over 4}:\ {\large ?}}$

\begin{align}
\pp\int_{-\infty}^{\infty}{{\pi^{2} \over 4}\cos^{2}\pars{x} \over x^{2} - \mu}
\,\dd x&=
{\pi^{2} \over 8\root{\mu}}\,\pp\int_{-\infty}^{\infty}
\bracks{{\cos^{2}\pars{x} \over x - \root{\mu}}
        - {\cos^{2}\pars{x} \over x + \root{\mu}}}\,\dd x
\\[3mm]&=
{\pi^{2} \over 8\root{\mu}}\,\pp\int_{-\infty}^{\infty}
{\cos^{2}\pars{x + \root{\mu}} - \cos^{2}\pars{x - \root{\mu}} \over x}\,\dd x
\\[3mm]&=
{\pi^{2} \over 8\root{\mu}}\,\pp\int_{-\infty}^{\infty}
{-4\cos\pars{x}\cos\pars{\root{\mu}}\sin\pars{x}\sin\pars{\root{\mu}} \over x}\,\dd x
\\[3mm]&=
-\,{\pi^{2}\sin\pars{2\root{\mu}} \over 8\root{\mu}}\,\pp\int_{-\infty}^{\infty}
{\sin\pars{2x} \over x}\,\dd x
=
-\,{\pi^{3} \over 8}\,{\sin\pars{2\root{\mu}} \over \root{\mu}}
\end{align}

\begin{align}
\pp\int_{-\infty}^{\infty}
{{\pi^{2} \over 4}\cos^{2}\pars{x} \over \pars{x^{2} - \mu}^{2}}
\,\dd x&=
-\,{\pi^{3} \over 8}\,
\totald{}{\mu}\bracks{{\sin\pars{2\root{\mu}} \over \root{\mu}}}
=
-\,{\pi^{3} \over 8}\,
\bracks{{\cos\pars{2\root{\mu}} \over \mu} - {\sin\pars{2\root{\mu}} \over 2\mu^{3/2}}}
\end{align}

Set $\mu = \pi^{2}/4$:
\begin{align}
\int_{-\infty}^{\infty}
{{\pi^{2} \over 4}\cos^{2}\pars{x} \over \pars{x^{2} - \pi^{2}/4}^{2}}
\,\dd x&=
-\,{\pi^{3} \over 8}\,\pars{-1 \over \pi^{2}/4} = {\pi \over 2}
\end{align}

$$
\color{#00f}{\large\int_{0}^{\infty}{{\pi^{2} \over 4}\cos^{2}\pars{x} \over
     \pars{{\pi^{2} \over 4} -x^{2}}^{2}}\,\dd x}
=
\half\int_{-\infty}^{\infty}
{{\pi^{2} \over 4}\cos^{2}\pars{x} \over \pars{x^{2} - \pi^{2}/4}^{2}}
\,\dd x = \color{#00f}{\large{\pi \over 4}}
$$
