Closed form and limit of the integral of a rational function While trying to answer this question, I wondered whether there could be a way to:
(A) Find the closed form of the generalization of integrals $I$ and $J$, that is
$$I_n=\int_{-\infty}^{+\infty}\frac{dx}{x^{4n}+x^{2n}+1}$$
(B) Prove my own conjecture that
$$\lim_{n \to \infty}I_n = 2$$
Is there a clean way to do these?

EDIT: I have managed to find a closed form for the poles of the integrand that lie in the upper half-plane, which would be the ones lying within the usual semicircular contour:
$$\omega^+_n(j)=\exp\left(i\frac{\pi}{4n}\big(2j-1-(-1)^n\big)\right) \qquad 1 \leq j \leq 2n, \quad j \in \mathbb{N}$$
My integral would become
$$\def\res{\mathop{\text{Res}}}
\begin{align}
\oint_\Gamma \frac{dz}{z^{4n}+z^{2n}+1}&=\lim_{R\to\infty} \int_{-R}^{+R}\frac{dx}{x^{4n}+x^{2n}+1}+\lim_{R\to\infty}iR\int_{0}^{\pi}\frac{e^{i\theta}d\theta}{R^{4n}e^{i\theta4n}+R^{2n}e^{i\theta2n}+1} \\
&=2\pi i \sum_{j=1}^{2n} \res_{z=\omega^+_n(j)} \left(\frac{1}{z^{4n}+z^{2n}+1}\right)
\end{align}$$
The limit of the integral in $\theta$ is $0$, as one would expect, so my question reduces to:

Is there a way to express
  $$\sum_{j=1}^{2n}\res_{z=\omega^+_n(j)} \left(\frac{1}{z^{4n}+z^{2n}+1}\right)$$
  in terms of $n$ and $j$?

The answers to (A) and (B) above should follow from this in a relatively straightforward way.
 A: This exercise is so much easier when you simply get rid of the $n$'s in the denominator, i.e., through a substitution $x=u^{1/(2 n)}$.
Write
$$I_n = 2 \int_0^{\infty} \frac{dx}{x^{4 n}+x^{2 n}+1} = \frac1n \int_0^{\infty} du \,\frac{ u^{-(2 n-1)/(2 n)}}{u^2+u+1} $$
Now consider the following contour integral
$$\oint_C dz \frac{z^a}{z^2+z+1} $$
where $a=-(2 n-1)/(2 n)$ and $C$ is a keyhole contour of outer radius $R$ and inner radius $\epsilon$ about the positive real axis.  Letting $R \to \infty$ and $\epsilon \to 0$, the contour integral is equal to
$$\left (1-e^{i 2 \pi a} \right ) \int_0^{\infty} dx \frac{x^a}{x^2+x+1} $$
By the residue theorem, the contour integral is also equal to
$$i 2 \pi \left (\frac{e^{i 2 \pi a/3}}{i \sqrt{3}} + \frac{e^{i 4 \pi a/3}}{-i \sqrt{3}} \right ) $$
Thus,
$$\int_0^{\infty} dx \frac{x^a}{x^2+x+1} = \frac{2 \pi}{\sqrt{3}} \frac{\displaystyle\sin{\left (\frac{\pi a}{3} \right )}}{\sin{(\pi a)}} = \frac{\displaystyle\pi \sin{\left (\frac{a \pi}{3} \right )}}{\sin{(a \pi)} \sin{\left (\frac{\pi}{3} \right )}} $$
Now, letting $a=1/(2 n)-1$, we find that

$$I_n = \frac{2 \pi}{\sqrt{3}} \frac{\displaystyle \sqrt{3}\cos{\left (\frac{\pi }{6 n} \right )} - \sin{\left (\frac{\pi }{6 n} \right )}}{2 n \sin{\left (\frac{\pi }{2 n} \right )}} $$

and, indeed,
$$\lim_{n \to \infty} I_n = 2$$
A: $\newcommand{\angles}[1]{\left\langle\,{#1}\,\right\rangle}
 \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{\half}{{1 \over 2}}
 \newcommand{\ic}{\mathrm{i}}
 \newcommand{\iff}{\Leftrightarrow}
 \newcommand{\imp}{\Longrightarrow}
 \newcommand{\ol}[1]{\overline{#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}$
With $\ds{x \equiv y^{1/6n}}$:
\begin{align}
\color{#f00}{I_{n}} & =
\int_{-\infty}^{\infty}{\dd x \over x^{4n} + x^{2n} + 1} =
2\int_{0}^{\infty}{\dd x \over x^{4n} + x^{2n} + 1} =
{1 \over 3n}
\int_{0}^{\infty}{y^{1/\pars{6n} - 1} \over y^{2/3} + y^{1/3} + 1}\,\dd y
\\[3mm] & =
{1 \over 3n}
\int_{0}^{\infty}{y^{1/\pars{6n} - 2/3} - y^{1/\pars{6n} - 1}\over y + 1}\,\dd y  =
{1 \over 3n}\mathrm{f}\pars{{1 \over 6n} - {2 \over 3},{1 \over 6n} - 1}
\\[3mm] &\mbox{where}\quad\mathrm{f}\pars{a,b} \equiv
\lim_{\Lambda \to\ \infty}\bracks{%
\int_{0}^{\Lambda}{y^{a} - 1 \over y - 1}\,\dd y -
\int_{0}^{\Lambda}{y^{b} - 1 \over y - 1}\,\dd y}
\end{align}

Note that
\begin{align}
\int_{0}^{\Lambda}{y^{\mu} - 1 \over y - 1}\,\dd y & =
\int_{0}^{1}{y^{\mu} - 1 \over y - 1}\,\dd y +
\int_{1}^{\Lambda}{y^{\mu} - 1 \over y - 1}\,\dd y
\\[3mm] & =
\int_{0}^{1}{1 - y^{\mu} \over 1 - y}\,\dd y +
\int_{1}^{1/\Lambda}{y^{-\mu} - 1 \over 1/y - 1}\,\pars{-1 \over y^{2}}\,\dd y
\\[3mm] & =
\int_{0}^{1}{1 - y^{\mu} \over 1 - y}\,\dd y +
\int_{1/\Lambda}^{1}{y^{-\mu - 1} - y^{-1} \over 1 - y}\,\dd y
\end{align}
Then,
\begin{align}
\mathrm{f}\pars{a,b} & =
\int_{0}^{1}{1 - y^{a} \over 1 - y}\,\dd y -
\int_{0}^{1}{1 - y^{b} \over 1 - y}\,\dd y +
\int_{0}^{1}{1 - y^{-b - 1} \over 1 - y}\,\dd y -
\int_{0}^{1}{1 - y^{-a - 1} \over 1 - y}\,\dd y
\\[3mm] & =
\Psi\pars{a + 1} - \Psi\pars{b + 1} + \Psi\pars{-b} - \Psi\pars{-a}
\\[3mm] & = -\pi\cot\pars{\pi a} + \pi\cot\pars{\pi b} 
\end{align}

$$
\color{#f00}{I_{n}} =
\color{#f00}{{\pi \over 3n}\braces{\cot\pars{\pi \over 6n} -
\cot\pars{{\pi \over 6n} - {2\pi \over 3}}}}
\quad\imp\quad\color{#f00}{\lim_{n \to \infty}I_{n}} = \color{#f00}{2}
$$


The 'limiting situation' is clearly seen by rewriting $\color{#f00}{I_{n}}$ in the following way:
  $$
I_{n} = \color{#f00}{\large 2}\
\underbrace{{\pi/\pars{6n} \over \sin\pars{\pi/\bracks{6n}}}}_{\ds{\to 1}}\
\underbrace{\cos\pars{\pi \over 6n}}_{\ds{\to\ 1}}\ -\
\underbrace{{\pi \over 3n}\,\cot\pars{{\pi \over 6n} - {2\pi \over 3}}}
_{\ds{\to 0}}
$$

