Cauchy P.V. Of an improper inegral the poles are $x=+1,-1,i,-i$
we should take only the upper have of axis
so we should take residue of $1$ and $i$? right 
in this problem the book took only $x= i$.
I don't know why !! please help
 A: Denoting by $a$ and $b$ the relevant poles ($\Im a>0, \; \Im b>0 $), we have:
$$a= (1+i)/\sqrt{2}, \quad b= (-1+i)/\sqrt{2}$$
$$\bar{a}= (1-i)/\sqrt{2}, \quad \bar{b}= (-1-i)/\sqrt{2}$$
$$ a - \bar{a} = i\sqrt{2}, \quad a - b = \sqrt{2}, \quad a - \bar{b} = (1+i)\sqrt{2}$$
$$ b - \bar{b} = i\sqrt{2}, \quad b - a = -\sqrt{2}, \quad b - \bar{a} = (1-i)\sqrt{2}$$
$${\rm Res} \left(\frac{z^2+1}{z^4+1}; a\right) = \frac{i+1}{2i\sqrt{2}(1+i)}=\frac{1}{2i\sqrt{2}}$$
$${\rm Res} \left(\frac{z^2+1}{z^4+1}; b\right) = \frac{-i+1}{-2i\sqrt{2}(1-i)}=\frac{1}{2i\sqrt{2}}$$
So:
$$1/2\cdot {\rm p.v.}\int_{-\infty}^{\infty}\frac{x^2+1}{x^4+1}\; dx = \pi i\left({\rm Res} \left(\frac{z^2+1}{z^4+1}; a\right) +{\rm Res} \left(\frac{z^2+1}{z^4+1}; b\right)\right)= \frac{\pi}{\sqrt{2}}$$
Edit: 
As per Ron Gordon's comment, as $\deg (x^4+1)-\deg (x^2+1)\geq 2$, improper integral 
$$ \int_{-\infty}^{\infty}\frac{x^2+1}{x^4+1}\; dx = \int_{-\infty}^{0}\frac{x^2+1}{x^4+1}\; dx + \int_{0}^{\infty}\frac{x^2+1}{x^4+1}\; dx$$
already exists and it is finite, so its principal value doesn't need to be taken. Note that:
$$\int\frac{x^2+1}{x^4+1}\; dx = \left(\arctan (\sqrt{2}x+1) - \arctan (-\sqrt{2}x+1) \right)/\sqrt{2} + {\cal C},$$
gives a a direct way of computing the improper integral.
