<s>[INST] Integral with contour integration I want to evaluate the integral:
$$\int_{-\infty}^{0}\frac{2x^2-1}{x^4+1}\,dx$$
using contour integration.
I re-wrote it as: $\displaystyle \int_{0}^{\infty}\frac{2x^2-1}{x^4+1}\,dx$. I am considering of integrating on a semicircle contour with center at the origin. I considered the function $\displaystyle f(z)=\frac{2z^2-1}{z^4+1}$  which has $4$ simple poles but only two of them lie on the upper half plane and included in the contour which are: $\displaystyle z_1=\frac{1+i}{\sqrt{2}}, \;\; z_2=\frac{-1+i}{\sqrt{2}}$. 
The residue at $\displaystyle z_1$ equals $\displaystyle \mathfrak{Res}\left ( f; z_1 \right )=-\frac{2i-1}{2\sqrt{2}}$  while the residue at $z_2$ equals $\displaystyle -2\sqrt{2}i-2\sqrt{2}$. (if I have done the calculations right)
Now, I don't know how to continue. Should I find the residues at the other poles as well and the say $\displaystyle \oint_{C}f(z)=2\pi i \sum res$ where $C$ is the semicircle contour and then expand it? That is:
$$\oint_{C}f(z)\,dz=\int_{0}^{a} + \int_{{\rm arc}}$$
Then let $a \to +\infty$ then than arc integral would go to zero.
But I don't know how to proceed.

I had dealt with this integral with residues converting it into a minus infinity to infinity integral  but with contours I am having a bit of problem.
Therefore I'd like some help.
 [/INST] Let's try and hope I have not made any mistakes here.
We will calculate the integral: 
$$\int_{-\infty}^{0}\frac{2x^2-1}{x^4+1}\,dx$$
Since the integrand function is even we can rewritte it as:
$$\int_{-\infty}^{\infty}\frac{2x^2-1}{x^4+1}\,dx=2\int_{-\infty}^{0}\frac{2x^2-1}{x^4+1}\,dx$$
Considering the function $\displaystyle f(z)=\frac{2z^2-1}{z^4+1}$ we see that is has $4$ simple poles which are $\displaystyle z_1=\frac{1+i}{\sqrt{2}}, \; z_2=\frac{1-i}{\sqrt{2}}, \; z_3=\frac{-1+i}{\sqrt{2}}, \; z_4=\frac{-1-i}{\sqrt{2}}$ 
Only two of them lie on the upper plane (meaning they have positive imaginery part)
Those are $z_1, \;  z_3$. 
The residues at $z_1, \; z_3$ are:
$$\begin{aligned}
\mathfrak{Res}\left ( f; z_1 \right ) &=\lim_{z\rightarrow z_1}(z-z_1)f(z) \\ 
 &= \lim_{z\rightarrow \frac{1+i }{\sqrt{2}}}\left ( z-z_1 \right )\frac{2z^2-1}{(z-z_1)\left ( z-\frac{1-i}{\sqrt{2}} \right )\left ( z-\frac{-1+i}{\sqrt{2}} \right )\left ( z-\frac{-1-i}{\sqrt{2}} \right )}\\ 
 &= \cdots\\ 
 &= \frac{3\sqrt{2}}{8} -i \frac{\sqrt{2}}{8}\\ 
\end{aligned}$$
and 
$$\begin{aligned}
\mathfrak{Res}\left ( f; z_3\right ) &=\lim_{z\rightarrow z_3}(z-z_3)f(z) \\ 
 &= \lim_{z\rightarrow \frac{-1+i }{\sqrt{2}}}\left ( z-z_3 \right )\frac{2z^2-1}{\left ( z-\frac{1+i}{\sqrt{2}} \right )\left ( z-\frac{1-i}{\sqrt{2}} \right )\left ( z-z_3 \right )\left ( z-\frac{-1-i}{\sqrt{2}} \right )}\\ 
 &= \cdots\\ 
 &= -\frac{3\sqrt{2}}{8} -i \frac{\sqrt{2}}{8}\\ 
\end{aligned}$$
Now we are integrating on a semicircle contour with center at the origin and radius $R$. We know that $\displaystyle \oint_{\gamma}f(z)\,dz=2\pi i \left ( \frac{3\sqrt{2}}{8} -i \frac{\sqrt{2}}{8} -\frac{3\sqrt{2}}{8}-i\frac{\sqrt{2}}{8} \right )=\frac{\pi}{\sqrt{2}}$ . 
Expanding the contour integral we have that:
$$\oint_{\gamma}f(z)\,dz=\int_{-a}^{a}+\int _{{\rm arc}}$$
Letting $a \to +\infty$ we have that the arc integral goes to zero, therefore we get the value of the integral is $\dfrac{\pi}{\sqrt{2}}$ thus the original integral is $\dfrac{\pi}{2\sqrt{2}}$
</s>