Evaluate the following integral using contour Integration $$I = \int_0^\infty\frac{1}{x^4+x^2+1}dx$$
I have evaluated the integral directly and know the result is $\frac{\pi}{2\sqrt3}$ but I must be messing up my residues or perhaps my path of integration when attempting the contour evaluation. When attempting contour I arrive at $\frac{\sqrt3\pi}{3}$
Edit: here is the way I did it to start.
$$J'=I; let\space x=1/y$$
A few algebraic steps and subbing back to x
$$J'=\int_0^1\frac{x^2}{x^4+x^2+1}dx$$
So that $I=\int_0^1\frac{x^2+1}{x^4+x^2+1}dx$ Which can be solved via trig.
I used some computer software to confirm the solution but I had an additional approach that was more careful which provided the same answer. My residue work was rather sloppy as I've done very little with contour integrations. I will post it as well if needed.
 A: Hint:
$$2I=\int_{-\infty}^{+\infty}\frac1{x^4+x^2+1}\ dx$$
Use a semi-circle contour and notice that
$$f(z)=\frac1{z^4+z^2+1}$$
$$\operatorname{Res}(f,e^{\pi i/3})=\frac1{12}(-3-i\sqrt3)$$
$$\operatorname{Res}(f,e^{2\pi i/3})=\frac1{12}(3-i\sqrt3)$$
A: The integral can also be evaluated using the result:
$$\int_0^{\infty}\frac{x^{-p}}{1+x}dx=\frac{\pi}{\sin(\pi p)}\tag{1}$$
which is an easily evaluated using a keyhole contour. Many integrals can be derived using this result, even if there is no straightforward substitution that leads to this integral. The integral in the problem can be written as:
$$I = \int_0^{\infty}\frac{1-x^2}{1-x^6}dx = \int_0^{\infty}\left(\frac{1}{1-x^6} - \frac{x^2}{1-x^6}\right)dx$$
Then the substitution $x^6 = y$ leads to something similar to (1) but with minus 1 instead of 1 in the denominator it looks like it's of no use. The two terms in the integrand have singularities that cancel, so it seems that treating the two terms separately would always have to involve a rather elaborate limiting procedure. But there is a way out of this problem that allows us to write down the result without doing much work. The substitution the substitution $x^6 = y$ leads to:
$$I = \frac{1}{6}\int_0^{\infty}\left(\frac{y^{-\frac{5}{6}}}{1-y} - \frac{y^{-\frac{1}{2}}}{1-y}\right)dy$$
To evaluate this, we consider the integral:
$$I(a) = \frac{1}{6}\int_0^{\infty}\left(\frac{y^{-\frac{5}{6}}}{1+ay} - \frac{y^{-\frac{1}{2}}}{1+ay}\right)dx$$
For positive $a$ we can evaluate this using (1) by making the substitution $a y = u$. This yields the result:
$$I(a) = \frac{\pi}{6}\left(2 a^{-\frac{1}{6}}-a^{-\frac{1}{2}}\right)\tag{2}$$
Even though this has been derived for positive $a$, the integral $I(a)$ is well defined for complex $a$, it is analytic in the complex plane minus a branch cut starting at the branch point at $a = 0$. We can therefore analytically continue the result (2) to the complex plane and then reach $a = -1$ starting from positive $a$ without ever bumping into singularities. This means that we need to avoid the branch cut, e.g. if we choose to put the branch cut along the positive imaginary axis in the complex plane, then we move to $a = -1$ via the lower half plane, if the branch cut is along the negative imaginary exist we would have to move to $a = -1$ via the upper half plane.
Since real positive $a$ must be represented by $a = |a|\exp(i\theta)$ with $\theta = 0$ to yield the correct real integral, we can put $a = \exp(i\pi)$ or $a = \exp(-i\pi)$ to get the answer of $I = \dfrac{\pi}{2\sqrt{3}}$.
