I want to calculate the following integral using residue theorem: $$\int_{-\infty}^{\infty} \frac{x^2}{x^4+1} $$ When I conisder the singularities, I get:
$ \text{Rez}(f, z_k)=\frac{1}{4z_k}$ with $z_k=e^{i \pi (\frac{2k+1}{4})} $ I only have to consider $k=0$ and $k=1$. But when I put that in my formula, I only get something not real. Did I do something wrong?
If $z_0$ is a zero of $z^4+1$, then$$\operatorname{res}_{z=z_0}\frac{z^2}{z^4+1}=\frac{{z_0}^2}{4{z_0}^3}=\frac1{4z_0}.$$You are right: you only have to consider the cases $z_0=\exp\left(\frac{\pi i}4\right)$ and $z_0=\exp\left(\frac{3\pi i}4\right)$. So\begin{align}\int_{-\infty}^\infty\frac{x^2}{x^4+1}\,\mathrm dx&=2\pi i\left(\frac1{4\exp\left(\frac{\pi i}4\right)}+\frac1{4\exp\left(\frac{3\pi i}4\right)}\right)\\&=\frac{\pi i}2\left(\exp\left(-\frac{\pi i}4\right)+\exp\left(-\frac{3\pi i}4\right)\right)\\&=\frac{\pi i}2\times\left(-\sqrt2i\right)\\&=\frac\pi{\sqrt2}.\end{align}