Residue theorem for a rational function 
Evaluate 
  $$\int_{-\infty}^{\infty}\frac{x^4}{1+x^8}\mathrm{d} x.$$ 

My concern: One of the consequences of the residue theorem states that, given a polynomial of the form $P/Q$ such that the degree of $Q$ exceeds $P$ by at least two, the integral can then be expressed as $$\int fdz=2\pi i\sum_{U}{\mathrm{Res}\left ( f;z_{i} \right )}.$$ 
The zeros of $Q$ in the Upper half plane  is here given by $z=e^{\frac{i \pi}{8}\left ( 2n+1 \right )}$ for $n\in \left \{0,1,2,3\right \}$. The residue at $z_{n}$ is now given by $\frac{P(z_{n})}{Q´(z_{n})}$. 
Should I derive the polynomial or exponential function? 
 A: You are on the right track. By the Residue Theorem
$$\begin{align}\int_{-\infty}^{\infty}\frac{x^4}{1+x^8}dx&=
2\pi i\sum_{n=0}^3\left.\frac{z^4}{8z^7}\right|_{z=w_n}=\frac{\pi i}{4}\left(w_0^{-3}+w_1^{-3}+w_2^{-3}+w_3^{-3}\right)\\
&=\frac{\pi}{4}\left(\sin(3\pi/8)+\sin(9\pi/8)+\sin(15\pi/8)+\sin(21\pi/8)\right)\\&=\frac{\pi}{2}\left(\sin(3\pi/8)-\sin(\pi/8)\right)
=\frac{\pi}{\sqrt{2}}\sin(\pi/8)
\end{align}$$
where $w_n=z=e^{\frac{i \pi}{8}\left ( 2n+1 \right )}$.
P.S. Note that by the half-angle formula
$$\sin(\pi/8)=\sqrt{\frac{1-\cos(\pi/4)}{2}}=\sqrt{\frac{1-1/\sqrt{2}}{2}}.$$
A: You can use the following reasoning.
$$\frac{x^4}{x^8+1}=\frac{x^4}{(x^4+\sqrt2x^2+1)(x^4-\sqrt2x^2+1)}=$$
$$=\frac{1}{2\sqrt2}\left(\frac{x^2}{x^4-\sqrt2x^2+1}-\frac{x^2}{x^4+\sqrt2x^2+1}\right)=$$
$$=\frac{1}{2\sqrt2}\left(\tfrac{x^2}{\left(x^2+\sqrt{2-\sqrt2}x+1\right)\left(x^2-\sqrt{2-\sqrt2}x+1\right)}-\tfrac{x^2}{\left(x^2+\sqrt{2+\sqrt2}x+1\right)\left(x^2-\sqrt{2+\sqrt2}x+1\right)}\right)=...$$
A: You have a good answer already. But here is a slick way to do the integration.  First note that:
\begin{align} 
\int^\infty_{-\infty} \frac{x^4}{x^8+1}dx= \text{Re} \int^\infty_{-\infty} \frac{1}{x^4-i}dx
\end{align} 
Now you have reduced the problem with calculating 4 residues to just 2 residues. And in the upper half plane they are at $\exp({\frac{1}{8} i\pi}) $ and $\exp({\frac{5}{8} i\pi})$. Don't forget to take the real part after you have finished the calculation. 
A: 
Instead of choosing a contour that encloses all of the poles in the upper half plane, we choose here a "wedge" contour $\displaystyle C$ comprised of the (i) line segment from $\displaystyle z=0$ to $\displaystyle z=R$, (ii) circular arc from $\displaystyle z=R$ to $\displaystyle z=e^{i\pi/2}$, and (iii) line segment from $\displaystyle z=e^{i\pi/2}$ to $\displaystyle z=0$.  This contour encloses the two poles at $\displaystyle z=e^{i\pi/8}$ and $\displaystyle z=e^{i3\pi/8}$.

From the residue theorem, we find that for $R>1$
$$\begin{align}
\oint_C \frac{z^4}{1+z^8}\,dz&=(1-i)\int_0^R \frac{x^4}{1+x^8}\,dx+\int_0^{\pi/2}\frac{iR^5e^{i5\phi}}{1+R^8e^{i8\phi}}\,d\phi\\\\
&=2\pi i \text{Res}\left(\frac{z^4}{1+z^8}, z=e^{i\pi/8}, z=e^{i3\pi/8}\right)\\\\
&=2\pi i \left(\frac{1}{8e^{i3\pi/8}}+\frac{1}{8e^{i9\pi/8}}\right)\\\\
&=\frac\pi2 e^{-i\pi/4}\cos(3\pi/8)
\end{align}$$
Letting $R\to \infty$ and ecploiting even symmetry we find that
$$\bbox[5px,border:2px solid #C0A000]{\int_0^\infty \frac{x^4}{1+x^8}\,dx=\frac{\pi}{\sqrt 2}\cos(3\pi/8)}=\frac\pi{\sqrt2}\sin(\pi/8)$$
