Complex integration using the residue theorem $\int_{-\infty}^\infty \frac{x\sin(x)}{x^4+1}\,dx$ I've beat my head against a wall with this one for the last couple days. Evaluate:
$$\int_{-\infty}^\infty \frac{x\sin(x)}{x^4+1}\,dx$$
I factored the denominator using Euler's identity such that the roots are $$x=\frac{1+i}{\sqrt2}, \frac{1-i}{\sqrt2}, \frac{-1-i}{\sqrt2}, \frac{-1+i}{\sqrt2}$$
I know that we can apply the residue theorem and calculate and sum the residues in the top half of $\mathbb{C}$ to get our solution to the integral. I set
$$H(z)=\frac{ze^{iz}}{(z-(\frac {-1-i}{\sqrt2}))(z-(\frac{1-i}{\sqrt2}))}$$
and $$f(z)=\frac{H(z)}{(z-(\frac{-1+i}{\sqrt2}))(z-(\frac{1+i}{\sqrt2}))}$$
But when I try to proceed from here to take the residue I am not sure that I have the right setup and quickly get lost in the algebra, could someone please let me know if I am at least on the right path?
 A: In terms of $z_\pm:=\tfrac{\pm1+i}{2}$ your integral is $\Im I$ with$$I:=\int_{\Bbb R}\frac{xe^{ix}dx}{x^4+1}=2\pi i\sum_\pm\lim_{z\to z_\pm}\frac{z(z-z_\pm)e^{iz}}{z^4+1}.$$By L'Hôpital's rule,$$I=2\pi i\sum_\pm\left.\frac{(iz^2+(2-iz_\pm)z-z_\pm)e^{iz}}{4z^3}\right|_{z_\pm}=\frac{\pi i}{2}\sum_\pm\frac{e^{iz_\pm}}{z_\pm^2}.$$So your integral is$$\frac{\pi}{2}\Re\left[\frac{e^{(-1+i)/\sqrt{2}}}{i}+\frac{e^{(-1-i)/\sqrt{2}}}{-i}\right]=\pi e^{-1\sqrt{2}}\sin\frac{1}{\sqrt{2}}.$$
A: If $g(z)=\dfrac{ze^{iz}}{z^4+1}$, then$$\operatorname{res}_{z=\frac{1+i}{\sqrt2}}\bigl(g(z)\bigr)=\frac{\left(\frac{1+i}{\sqrt2}\right)\exp\left(\frac{1+i}{\sqrt2}i\right)}{4\left(\frac{1+i}{\sqrt2}\right)^3}=-\frac14ie^{-\frac{1-i}{\sqrt{2}}}$$and$$\operatorname{res}_{z=\frac{-1+i}{\sqrt2}}\bigl(g(z)\bigr)=\frac{\left(\frac{-1+i}{\sqrt2}\right)\exp\left(\frac{-1+i}{\sqrt2}i\right)}{4\left(\frac{-1+i}{\sqrt2}\right)^3}=\frac{1}{4} i e^{-\frac{1+i}{\sqrt{2}}}.$$So, and since $\exp\left(-\frac1{\sqrt2}\pm\frac i{\sqrt2}\right)=\exp\left(-\frac1{\sqrt2}\right)\left(\cos\left(\pm\frac1{\sqrt2}\right)+\sin\left(\pm\frac1{\sqrt2}\right)i\right)$, the sum of the residues is\begin{multline}\require{cancel}-\frac14i\exp\left(-\frac1{\sqrt2}+\frac i{\sqrt2}\right)+\frac14i\exp\left(-\frac1{\sqrt2}+\frac i{\sqrt2}\right)=\\=\frac{\exp\left(-\frac1{\sqrt2}\right)}4\left(\sin\left(\frac1{\sqrt2}\right)-\cancel{\cos\left(\frac1{\sqrt2}\right)i}+\sin\left(\frac1{\sqrt2}\right)+\cancel{\cos\left(\frac1{\sqrt2}\right)i}\right)=\\=\frac12e^{-\frac{1}{\sqrt2}}\sin\left(\frac1{\sqrt2}\right)\end{multline}and therefore$$\int_{-\infty}^\infty\frac{xe^{ix}}{x^4+1}\,\mathrm dx=\pi ie^{-\frac{1}{\sqrt2}}\sin\left(\frac1{\sqrt2}\right).$$So,\begin{align}\int_{-\infty}^\infty\frac{x\sin(x)}{x^4+1}\,\mathrm dx&=\operatorname{Im}\left(\pi ie^{-\frac{1}{\sqrt2}}\sin\left(\frac1{\sqrt2}\right)\right)\\&=\pi e^{-\frac{1}{\sqrt2}}\sin\left(\frac1{\sqrt2}\right).\end{align}
