Computing the integral $\int_{-\infty}^{\infty}\frac{z^4}{1+z^8}dz$ I need help to compute the following integral:
$$\int_{-\infty}^{\infty}\frac{z^4}{1+z^8}dz$$
I need to use Cauchy's residue theorem. 
I can write that $z^8+1=z^8-i^2=(z^4-i)(z^4+i)$. How do I proceed?
Please give a methodological answer so that I can solve other questions too. 
Thanks
 A: At first, let us find the roots of the denominator:
\begin{align}
&z_{k}^8= -1 = e^{(2k+1)\pi i}\\
&z_k=\exp{2k+1\over8}\pi i.
\end{align}
(see also Wolfram Alpha)
The roots with the positive image part are $z_{0\dots3}.$ Using the Residue theorem and L'Hospital's Rule, one can get
\begin{align}
&\int_\limits{-\infty}^\infty{z^4\over1+z^8} = 2\pi i\sum_{k=0}^3\mathrm{Res}\left({z^4\over1+z^8},z_k\right) = 2\pi i\sum_{k=0}^3\lim\limits_{z\to z_k}{z^4(z-z_k)\over1+z^8} = 2\pi i\sum_{k=0}^3{5z_k^4-4z_k^4\over8z_k^7}\\
&\quad= -{\pi i\over4}\sum\limits_{k=o}^3z_k^5 = -{\pi i\over4}\left(\exp{5\pi i\over8}+\exp{15\pi i\over8}+\exp{25\pi i\over8}+\exp{35\pi i\over8}\right)\\
&\quad = -{\pi i\over4}\exp{20\pi i\over8}\left(\exp\left(-{15\pi i\over8}\right)+\exp\left(-{5\pi i\over8}\right)+\exp{5\pi i\over8}+\exp{15\pi i\over8}\right)\\
&\quad = {\pi\over4}\left(\exp{\pi i\over8}+\exp\left(-{5\pi i\over8}\right)+\exp{5\pi i\over8}+\exp\left(-{\pi i\over8}\right)\right)\\
&\quad= {\pi\over2}\left(\cos{\pi\over8}+\cos{5\pi\over8}\right) = {\pi\over2}\left(\cos{\pi\over8}-\sin{\pi\over8}\right) = {\pi\sqrt2\over2}\left(\cos{\pi\over8}\cos{\pi\over4}-\sin{\pi\over8}\sin{\pi\over4}\right)\\
&\quad = {\pi\sqrt2\over2}\cos{3\pi\over8}.\\
\end{align}
A: The idea when applying the residue theorem to a definite integral is to do the following:


*

*Turn the integrand into a meromorphic function $f(z)$.

*Choose a contour $\gamma$ such that the desired integral can be related to $\int_{\gamma}f(z)dz$.

*Evaluate the integral $\int_{\gamma}f(z)dz$ by finding the poles of $f$ and the residues at these poles, and then using the residue theorem.


In your case you naturally have
$$
f(z)=\frac{z^4}{1+z^8}.
$$
A common contour to use when evaluating an integral from $-\infty$ to $\infty$ is a semicircle of radius $R$ in the upper half-plane, centered at the origin. By diving this contour into two parts, you see that the contour integral will be the integral
$$
\int_{-R}^R\frac{x^4}{1+x^8{{}}}dx
$$
plus $\int_{C}f(z)dz$, where $C$ is the upper half of the circle of radius $R$ (centered at the origin). Can you show that as $R\to\infty$, the integral over the top half of the circle goes to $0$?
Now you know that your desired integral equals the limit of the contour integral $\int_{\gamma}f(z)dz$ as $R\to\infty$. In order to find the poles of $f$ within this contour, you should determine where $1+z^8=0$. Can you finish the problem from here?
A: $\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,}
 \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
 \newcommand{\dd}{\mathrm{d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
 \newcommand{\ic}{\mathrm{i}}
 \newcommand{\mc}[1]{\mathcal{#1}}
 \newcommand{\mrm}[1]{\mathrm{#1}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
 \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$

$\ds{\int_{-\infty}^{\infty}{z^{4} \over z^{8} + 1}\,\dd z =
{1 \over 4}\,\pi\sec\pars{\pi \over 8} \approx 0.8501:\ {\large ?}}$.   Integrand poles are given by
  $\ds{z_{n} = \exp\pars{{2n + 1 \over 8}\,\pi\ic}}$ where
  $\ds{n = 0,1,\ldots,7}$.


I'll perform an integration along a 'pizza-slice contour' which is depicted in the above picture:


*

*The contribution from the arc vanishes out in the $\ds{R \to \infty}$ limit such that, by simplicity, I omitted it in the following evaluation.

*The contour encloses $\underline{just\ one\
pole}$: $\ds{z_{0} = \expo{\pi\ic/8}}$. This fact is the 'real benefit' of integrating along the piza-slice contour.

*It turns out that
$\ds{2\int_{0}^{\infty}{z^{4} \over z^{8} + 1}\,\dd z}$ is equal to
$$
2\bracks{2\pi\ic\,\,\mrm{res}\pars{z^{4} \over z^{8} + 1}}
_{\ z\ =\ z_{0}\ = \exp\pars{\pi\ic/8}}\ -\
\pars{~\substack{%
\mbox{the integral from the upper point}\ \ds{P}
\\[1mm]
\mbox{to the coordinates origin.}}~}
$$


That is which is shown below:

\begin{align}
\int_{-\infty}^{\infty}{z^{4} \over 1 + z^{8}}\,\dd z & =
2\int_{0}^{\infty}{z^{4} \over z^{8} + 1}\,\dd z
\\[5mm] & =
2\pars{2\pi\ic}\lim_{z \to z_{0}}
\bracks{\pars{z - z_{0}}{z^{4} \over z^{8} + 1}} -
2\int_{\infty}^{0}{\pars{z\expo{2\pi\ic/8}}^{4} \over \pars{z\expo{2\pi\ic/8}}^{8} + 1}\,\expo{2\pi\ic/8}\dd z
\\[5mm] & =
4\pi\ic\,
\pars{5\,z_{0}^{4} - 4\,z_{0}^{4}\over 8z_{0}^{7}}
_{\ z_{0}\ \equiv\ \exp\pars{\pi\ic/8}} -
\expo{\pi\ic/4}\int_{-\infty}^{\infty}{z^{4} \over 1 + z^{8}}\,\dd z
\\[1cm]
\implies &
\int_{-\infty}^{\infty}{z^{4} \over 1 + z^{8}}\,\dd z =
-\,{1 \over 2}\,\pi\ic\,{\expo{5\pi\ic/8} \over 1 + \expo{\pi\ic/4}`} =
-\,{1 \over 2}\,\pi\ic\,{\expo{4\pi\ic/8} \over \expo{-\pi\ic/8} + \expo{\pi\ic/8}}
\\[5mm] & =
-\,{1 \over 2}\,\pi\ic\,{\ic \over 2\cos\pars{\pi/8}} =
\bbx{{1 \over 4}\,\pi\sec\pars{\pi \over 8}} \approx 0.8501
\end{align}
