Calculate $\int_0^{\infty} \frac{\cos 3x}{x^4+x^2+1} dx$ Calculate $$\int_0^{\infty} \frac{\cos 3x}{x^4+x^2+1} dx$$
I think that firstly I should use Taylor's theorem, so I have:$$\int_0^\infty \frac{1-\frac{x^2}{2!}+\frac{x^4}{4!}-\dots}{(x^2+1)^2}dx$$
However I don't know what I can do the next.
 A: Let $f(x)=\frac{\cos(3x)}{x^4+x^2+1}$.  Inasmuch as $f$ is an even function, we can write
$$\begin{align}
\int_0^\infty \frac{\cos(3x)}{x^4+x^2+1}\,dx&=\frac12 \int_{-\infty}^\infty \frac{e^{i3x}}{x^4+x^2+1}\,dx\\\\
&=\pi i \left(\text{Res}\left(\frac{e^{i3z}}{z^4+z^2+1}, z=e^{i\pi/3}\right)+\text{Res}\left(\frac{e^{i3z}}{z^4+z^2+1}, z=e^{i2\pi/3}\right)\right)
\end{align}$$
where we have used the Residue Theorem.
Can you finish now?
A: Note that $I(a) = \int_0^\infty \frac{\sin at} {t(t^2+1)}dt
= \frac\pi2 (1-e^{-a}) $, which can be obtain by solving
$$I’’(a)-I(a) = -\int_0^\infty \frac{\sin at}t dt= -\frac\pi2$$
Then
\begin{align}
\int_{0}^{\infty}\frac{\cos 3x}{x^4+x^2+1} dx
= &\frac14\int_{-\infty}^{\infty}
 \overset{x=\frac{\sqrt3}2 t-\frac12}{\frac{(1+x)\cos 3x}{x^2+x+1}} +\overset{x= \frac{\sqrt3}2 t +\frac12}{\frac{(1-x)\cos 3x}{x^2-x+1}} d x\\
=& \frac1{\sqrt3}\cos\frac3{2} \int_{0}^{\infty} \frac{\cos \frac {3\sqrt3}{2}t}{t^2+1} dt + \sin\frac3{2} \int_{0}^{\infty} \frac{t\sin\frac {3\sqrt3}{2}t}{t^2+1} dt \\
=& \frac1{\sqrt3}\cos\frac3{2}\cdot I’(\frac {3\sqrt3}{2})
-\sin\frac3{2}\cdot I’’(\frac {3\sqrt3}{2})\\
=&\frac\pi2 e^{-\frac {3\sqrt3}{2} }\left( \frac1{\sqrt3}\cos\frac32+ \sin\frac32\right)
  =\frac\pi{\sqrt3}e^{-\frac {3\sqrt3}{2} }\sin\left(\frac\pi6+\frac32\right)
\end{align}
