<s>[INST] 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.
 [/INST] 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?
</s>