<s>[INST] Evaluating $\int_0^{\infty} {y^2 \cos^2(\frac{\pi y}{2}) \over (y^2-1)^2} dy$ I´m having trouble with the following integral
$$
\int_0^{\infty} {y^2 \cos^2(\frac{\pi y}{2}) \over (y^2-1)^2} dy
$$
I have tried lots of approaches and nothing works. Mathematica says it does not converge but that is not true. It appears in a Physical problem (it is the energy of a system) and the answer should be (by conservation of energy): $\frac{\pi^2}{8}$ but I cannot show it. 
 [/INST] Let $I$ denote the integral. Then
\begin{align*}
I &= \frac{1}{2} \int_{-\infty}^{\infty} \frac{y^2 \cos^{2} (\pi y/2)}{(y^{2} - 1)^{2}} \, dx \\
&= \frac{1}{4} \int_{-\infty}^{\infty} \frac{y^2 (1 + \cos \pi y)}{(y^{2} - 1)^{2}} \, dx \\
&= \frac{1}{4} \Re \mathrm{PV}\!\!\int_{-\infty}^{\infty} \frac{y^2 (1 + e^{i\pi y})}{(y^{2} - 1)^{2}} \, dx.
\end{align*}
Now considering an upper-semicircular contour with two vanishing upper-semicircular indents at $z = \pm 1$, it follows that
\begin{align*}
\mathrm{PV}\!\!\int_{-\infty}^{\infty} \frac{z^2 (1 + e^{i\pi z})}{(z^{2} - 1)^{2}} \, dz
&= \pi i \left( \mathrm{Res}_{z=-1} \frac{z^2 (1 + e^{i\pi z})}{(z^{2} - 1)^{2}} + \mathrm{Res}_{z=1} \frac{z^2 (1 + e^{i\pi z})}{(z^{2} - 1)^{2}} \right) \\
&= \pi i \left( -\frac{i\pi}{4} -\frac{i\pi}{4} \right) \\
&= \frac{\pi^{2}}{2}.
\end{align*}
Therefore the conclusion follows.
</s>