Residue Integral 
Verify the integral with the aid of residues:
  $$\int^{\infty}_0\frac{x^2+1}{x^4+1}dx=\frac{\pi}{\sqrt 2}$$

I got: 
$f(z)=\frac{z^2+1}{z^4+1}$ and now I must find the residues for $f(z)$ and I got that the poles are: $e^{i\frac{\pi}{4}}$ and $e^{i\frac{3\pi}{4}}$. But I do not know how to finish. 
 A: Note that $\int_0^\infty f(x) = \frac{1}{2} \int_{-\infty}^\infty f(x)$. You can use the punctured half-circle contour (like half of a CD, in the upper half plane) to integrate $f(z)$, then apply the residue theorem,  note that half of your contour is your integral, and take care of the other half by bounding it.
Like you said, $f(z)$ has poles in your contour at $p_1 = e^{i\pi/4}, p_2 = e^{i3\pi/4}$. It's a fact that these poles are simple, and that's not too hard to show. Hence $f = \frac{p}{q}$ implies that $\text{Res}_{p_i} f = \frac{p(p_i)}{q'(p_i)}$.
Now, call your CD contour $\gamma$ and the residue at $p_i$ as $r_i$. The residue theorem states that $\int_\gamma f = 2\pi i (r_1 + r_2)$. But if you let the circle part of $\gamma$ be $\gamma_C$ then $\int_\gamma f = 2*\int_0^R f + \int_{\gamma_C}f$, and $|\int_{\gamma_C} f| \leq \int_{\gamma_C} |f| \leq len(\gamma_C) * \frac{R^2 + 1}{R^4 + 1} = \frac{R^3 + R}{R^4 + 1} \to 0$ as $R \to \infty$, where $R$ is the radius of $\gamma$. Hence you can ignore the circle part and obtain the result.
Edit: The theorem about rational functions and simple poles. Suppose $f(z) = \frac{p(z)}{q(z)}$ and $f$ has a simple pole at $a$. Then the formula for residues says that $\text{Res}_a f = \lim_{z \to a} (z-a)f(z) = \lim_{z \to a} \frac{p(z)}{\frac{q(z)}{z-a}} = \lim_{z \to a} \frac{p(z)}{\frac{q(z) - (a)}{z-a}} = \frac{p(a)}{q'(a)}$ where I used the fact that $a$ is a pole, which says that $q(a) = 0$.
A: This answer, which uses residues, says that
$$
\frac{\pi}{m}\csc\left(\pi\frac{n+1}{m}\right)=\int_0^\infty\frac{x^n}{1+x^m}\,\mathrm{d}x
$$
Using $m=4$ and $n=0$ and $n=2$ yields
$$
\begin{align}
\int_0^\infty\frac{x^2+1}{z^4+1}\,\mathrm{d}x
&=\frac\pi4\csc\left(\frac14\pi\right)+\frac\pi4\csc\left(\frac34\pi\right)\\
&=\frac\pi4\sqrt2+\frac\pi4\sqrt2\\
&=\frac\pi{\sqrt2}
\end{align}
$$

The Long Way
Using the curve $\gamma$ which runs from $-R$ to $+R$ along the real axis then circles counter-clockwise from $+R$ to $-R$ through the upper half-plane, we get
$$
\begin{align}
\int_0^\infty\frac{x^2+1}{x^4+1}\,\mathrm{d}x
&=\frac12\int_{-\infty}^\infty\frac{x^2+1}{x^4+1}\,\mathrm{d}x\\
&=\frac12\int_\gamma\frac{z^2+1}{z^4+1}\,\mathrm{d}z\\
&=\frac{2\pi i}2\left(\frac{e^{2\pi i/4}+1}{4e^{3\pi i/4}}+\frac{e^{6\pi i/4}+1}{4e^{9\pi i/4}}\right)\\
&=\frac{2\pi i}2\left(\frac{e^{\pi i/4}+e^{-\pi i/4}}{4e^{2\pi i/4}}+\frac{e^{\pi i/4}+e^{-\pi i/4}}{4e^{2\pi i/4}}\right)\\
&=\pi\cos\left(\frac\pi4\right)\\
&=\frac\pi{\sqrt2}
\end{align}
$$
Since the residue at the singularities inside the contour $z=e^{\pi i/4}$ and $z=e^{3\pi i/4}$ is $\dfrac{z^2+1}{4z^3}$.
A: An easy way to get the solution is just to use partial fractions in Calculus. Here is the solution:
\begin{eqnarray*}
\int_0^\infty\frac{x^2+1}{x^4+1}dx&=&\int_0^\infty\frac{x^2+1}{(x^2+\sqrt{2}x+1)(x^2-\sqrt{2}x+1)}dx\\
&=&\frac{1}{2}\int_0^\infty\frac{1}{x^2+\sqrt{2}x+1}dx+\frac{1}{2}\int_0^\infty\frac{1}{x^2-\sqrt{2}x+1}dx\\
&=&\frac{1}{2}\int_0^\infty\frac{1}{(x+\frac{\sqrt{2}}{2})^2+\frac{1}{2}}dx+\frac{1}{2}\int_0^\infty\frac{1}{(x-\frac{\sqrt{2}}{2})^2+\frac{1}{2}}dx\\
&=&\frac{1}{2}\sqrt{2}\left.\left(\arctan\frac{2x+\sqrt{2}}{\sqrt{2}}+ \arctan\frac{2x-\sqrt{2}}{\sqrt{2}}\right)\right|_{0}^{\infty}\\
&=&\frac{\pi}{\sqrt{2}}.
\end{eqnarray*}
