Answer not matching for calculating the value of an integral Consider the following integral $$\int_ {-\infty}^{\infty} \frac{x^2 - x + 2 }{x^4 + 10x^2 + 9} dx \!$$

I need to find its value using residue calculus. So, I considered the complex function $$\int_ {-\infty}^{\infty} \frac{z^2 - z + 2 }{z^4 + 10z^2 + 9} dz \!$$ 

The poles of above rational function are at $i , -i, 3i , -3i$. Now I calculated the residues at each singularity. In order to get the value of the integral I used $$\int_{\delta D}f(z)dz = 2 \pi i \sum_{j=1}^{m}Res[f(z), z_j]$$ where $z_j $'s are the isolated singularities and $\delta D$ is a piecewise smooth boundary. Using the above formula when I am summing up all the residues (and multiplying by $2 \pi i$) I am not getting the answer given in the book. Instead the answer given in the book has been calculated by adding just the residues at $z =i$ and $z = 3i$. I don't understand this. Why the sigularities which are in upper half plane are only considered? 

Also I have a second question - How will the value of integral changes on changing the integral limits as $0$ to $\infty$ ?
It's about choosing the right piecewise smooth boundary $\delta D$.

Let $\delta D_r = \{z =re^{it}, t\in [0,\pi] \}\cup [-r,r]$ the boundary of an upper half-disk. With $r$ sufficiently large (i.e. $r&gt;3$), we have that $$\int_{\delta D_r}f(z)dz = 2\pi i \sum_{z_j: \Re (z_j)  &gt; 0}\operatorname{Res}(f,z_j).$$

Furthermore, $$\int_{\delta D_r}f(z)dz = \int_{\{z =re^{it}, t\in [0,\pi] \}}f(z)dz + \int_{[-r,r]}f(z)dz.$$

The left hand side summand (the integral over the upper arc) vanishes as $r\rightarrow \infty$ (why?) and the other summand converges to your real integral (why?).
How are you calculating the residues?
The residue at 3i is  $$ \frac{1}{16} - \frac{7i }{48} $$
The residue at i is  $$ -\frac{1}{16} - \frac{i }{16} $$
[In class, verify these by showing your work.]
Add these to obtain $$ -\frac{5i }{24} $$
These yield the integral value using the Res Theorem.

You should get the same answer if you perform the integration using Partial Fractions.