Use real integral to calculate $\int_R \frac{x^2 \cos (\pi x)}{(x^2 + 1)(x^2 + 2)}dx$ Problem :
Evaluate $$\int_{-\infty}^{\infty} \frac{x^2 \cos (\pi x)}{(x^2 + 1)(x^2 + 2)}dx$$
Use only real integral.

What I did : 
$$\int_{-\infty}^{\infty} \frac{x^2 \cos (\pi x)}{(x^2 + 1)(x^2 + 2)}dx$$
$$=2\int_{0}^{\infty} \frac{x^2 \cos (\pi x)}{(x^2 + 1)(x^2 + 2)}dx$$
$$=2\int_{0}^{\infty} \left( \frac{2\cos(\pi x)}{x^2+2} - \frac{\cos (\pi x)}{x^2 + 1}\right) dx$$
Any easy way to calculate this? or idea like differentiate under the integral sign?

Just A Bit of a Generalization
We may actually evaluate the integral 
$$J(a,b;t)=2\int_0^\infty \frac{x^2\cos(tx)dx}{(x^2+a^2)(x^2+b^2)}$$
for some $a, b>0$, $a\ne b$. We see that 
$$J(a,b;t)=\frac{2a^2}{a^2-b^2}f(a;t)+\frac{2b^2}{b^2-a^2}f(b;t)$$
where $$f(q;t)=\int_0^\infty \frac{\cos(tx)}{x^2+q^2}dx\, .$$
We take the Laplace transform of the remaining integral:
$$\begin{align}
\mathcal{L}\{f\}(s)&=\int_0^\infty e^{-st}\int_0^\infty \frac{\cos(tx)}{x^2+q^2}dxdt\\
&=\int_0^\infty \frac{1}{x^2+q^2}\int_0^\infty \cos(tx)e^{-st}dtdx\\
&=\int_0^\infty \frac{1}{x^2+q^2}\text{Re}\int_0^\infty e^{-(s-ix)t}dtdx\\
&=\int_0^\infty \frac{1}{x^2+q^2}\text{Re}\left[\frac1{s-ix}\right]dx\\
&=s\int_0^\infty \frac{dx}{(x^2+q^2)(x^2+s^2)}\\
&=\frac{s}{s^2-q^2}\left[\int_0^\infty \frac{dx}{x^2+q^2}-\int_0^\infty\frac{dx}{x^2+s^2}\right]\\
&=\frac{\pi}{2}\frac{s}{s^2-q^2}\left[\frac{1}{q}-\frac{1}{s}\right]\\
&=\frac{\pi}{2}\left[\frac{1}{q}\frac{s}{s^2-q^2}-\frac{1}{s^2-q^2}\right]\, .
\end{align}$$
Then we define 
$$C(z;s)=\int_0^\infty e^{-st}\cosh(zt)dt=\mathcal{L}\{\cosh(zt)\}(s)$$
$$S(z;s)=\int_0^\infty e^{-st}\sinh(zt)dt=\mathcal{L}\{\sinh(zt)\}(s)$$
So that 
$$C(z;s)+S(z;s)=\int_0^\infty e^{-(s-z)t}dt=\frac{s+z}{s^2-z^2}$$
and 
$$C(z;s)-S(z;s)=\int_0^\infty e^{-(s+z)t}dt=\frac{s-z}{s^2-z^2}\ .$$
Hence 
$$C(z;s)=\frac{s}{s^2-z^2}$$
$$S(z;s)=\frac{z}{s^2-z^2}$$
And 
$$\begin{align}
\mathcal{L}\{f\}(s)&=\frac{\pi}{2q}\left[\mathcal{L}\{\cosh(qt)\}(s)-\mathcal{L}\{\sinh(qt)\}(s)\right]\\
&=\frac{\pi}{2q}\mathcal{L}\{e^{-qt}\}(s)\, .
\end{align}$$
Therefore 
$$f(q;t)=\frac{\pi}{2q}e^{-qt}$$
and
$$J(a,b;t)=\frac{\pi}{a^2-b^2}\left[ae^{-at}-be^{-bt}\right]$$
and your integral is given by 
$$J(\sqrt{2},1;\pi)=\int_{-\infty}^\infty \frac{x^2\cos(\pi x)dx}{(x^2+2)(x^2+1)}=\pi\sqrt{2}e^{-\pi\sqrt{2}}-\pi e^{-\pi}$$
