Integral $\int_{-\infty}^{\infty}\frac{x^2\cos(x)}{x^4-1}dx$ I want to compute  $$\int_{-\infty}^{\infty}\frac{x^2\cos(x)}{x^4-1}dx$$ by using Residue Theorem. The poles are given by $A:=\{-i,i,1,-1\}$. Now, it seems to me that semicircle contour won't work, because $1,-1\in[-R, R], R>1.$ Or does it help me if I make a curve around $-1,1$ with my cycle? I also thought about using the integrand $f(z)=\frac{z^2e^{i z}}{z^4-1}$ and taking the real part in the end.
 A: Integral exists - if we understand it in the principal value sense (integrating symmetrically near every singular points on the axis $X$; in our case near $z=-1$ and $z=1$). If we want to use complex integration to get the answer, we have to create a closed contour. For example, we can add small semi-circles around $z=\pm1$ (clockwise) and a big semi-circle in the upper half-plane (counter-clockwise).

Let $a\geqslant 0$, and let's denote
$$\int_{-\infty}^{\infty}\frac{x^2\cos(ax)}{x^4-1}dx=\Re\,\int_{-\infty}^{\infty}\frac{x^2e^{iax}}{(x-1)(x+1)(x+i)(x-i)}dx=\Re\,I(a)$$
Considering the integral in the complex plane along the chosen closed contour, we have
\begin{align*}\oint\frac{z^2e^{iaz}}{(z-1)(z+1)(z+i)(z-i)}dz&=I(a)+I_{1r}+I_{2r}+I_R\\\newcommand{\res}{\operatorname*{Res}}&=2\pi i\res\frac{z^2e^{iaz}}{(z-1)(z+1)(z+i)(z-i)}\end{align*}
where $I_{1r}, I_{2r}$ are the integrals along small semi-circles, $I_R$ - the integral along  a big circle, and we evaluate the residues inside the contour.
It is not difficult to show that $I_R\to 0$ at $R\to\infty$. Evaluation of $I_{1,2r}$ gives $-\pi i\res\frac{z^2e^{iaz}}{(z-1)(z+1)(z+i)(z-i)}$ in the points $z=\pm1$ at $r\to 0$.
Therefore, we get
$$I(a)=2\pi i\res_{z=i}\frac{z^2e^{iaz}}{(z-1)(z+1)(z+i)(z-i)}+\pi i\res_{z=\pm1}\frac{z^2e^{iaz}}{(z-1)(z+1)(z+i)(z-i)}$$
$$=\frac{\pi}{2}e^{-a}-\frac{\pi}{2}\sin a$$
$$\int_{-\infty}^{\infty}\frac{x^2\cos(ax)}{x^4-1}dx=\Re\,I(a)=\frac{\pi}{2}e^{-a}-\frac{\pi}{2}\sin a$$
Quick check: at $a=0$
$$\int_{-\infty}^{\infty}\frac{x^2}{x^4-1}dx=\int_{-\infty}^{\infty}\frac{x^2}{(x^2-1)(x^2+1)}dx=\frac{1}{2}\int_{-\infty}^{\infty}\Big(\frac{1}{1+x^2}+\frac{1}{x^2-1}\Big)dx$$
$$=\frac{\pi}{2}+\frac{1}{4}\int_{-\infty}^{\infty}\Big(\frac{1}{x-1}-\frac{1}{x+1}\Big)dx=\frac{\pi}{2}$$
