Evaluating Complex Integral. I am trying to evaluate the following integrals:
$$\int\limits_{-\infty}^\infty \frac{x^2}{1+x^2+x^4}dx $$
$$\int\limits_{0}^\pi \frac{d\theta}{a\cos\theta+ b} \text{ where }0<a<b$$
My very limited text has the following substitution:
$$\int\limits_0^\infty \frac{\sin x}{x}dx = \frac{1}{2i}\int\limits_{\delta}^R \frac{e^{ix}-e^{-ix}}{x}dx \cdots $$
Is the same of substitution available for the polynomial? Thanks for any help. I apologize in advance for slow responses, I have a disability that limits me to an on-screen keyboard.
 A: For the first one, write $\dfrac{x^2}{1+x^2+x^4}$ as $\dfrac{x}{2(1-x+x^2)} - \dfrac{x}{2(1+x+x^2)}$. Now
$$\dfrac{x}{(1-x+x^2)} = \dfrac{x-1/2}{\left(x-\dfrac12\right)^2 + \left(\dfrac{\sqrt3}2 \right)^2} + \dfrac{1/2}{\left(x-\dfrac12\right)^2 + \left(\dfrac{\sqrt3}2 \right)^2}$$
and
$$\dfrac{x}{(1-x+x^2)} = \dfrac{x+1/2}{\left(x+\dfrac12\right)^2 + \left(\dfrac{\sqrt3}2 \right)^2} - \dfrac{1/2}{\left(x+\dfrac12\right)^2 + \left(\dfrac{\sqrt3}2 \right)^2}$$
I trust you can take it from here.

For the second one, from Taylor series of $\dfrac1{(b+ax)}$, we have
$$\dfrac1{(b+a \cos(t))} = \sum_{k=0}^{\infty} \dfrac{(-a)^k}{b^{k+1}} \cos^{k}(t)$$
Now $$\int_0^{\pi} \cos^k(t) dt = 0 \text{ if $k$ is odd}$$
We also have that
$$\color{red}{\int_0^{\pi}\cos^{2k}(t) dt = \dfrac{(2k-1)!!}{(2k)!!} \times \pi = \pi \dfrac{\dbinom{2k}k}{4^k}}$$
Hence,
$$I=\int_0^{\pi}\dfrac{dt}{(b+a \cos(t))} = \sum_{k=0}^{\infty} \dfrac{a^{2k}}{b^{2k+1}} \int_0^{\pi}\cos^{2k}(t) dt = \dfrac{\pi}{b} \sum_{k=0}^{\infty}\left(\dfrac{a}{2b}\right)^{2k} \dbinom{2k}k$$
Now from Taylor series, we have
$$\color{blue}{\sum_{k=0}^{\infty} x^{2k} \dbinom{2k}k = (1-4x^2)^{-1/2}}$$
Hence,
$$\color{green}{I = \dfrac{\pi}{b} \cdot \left(1-\left(\dfrac{a}b\right)^2 \right)^{-1/2} = \dfrac{\pi}{\sqrt{b^2-a^2}}}$$
A: $f(z) := \frac{1}{a\cos z+b}$
Let $I$ be the integral in question.  Let's double the integral, to get
$$2I =\int_0^{2\pi} f(z)\, dz$$
Let $C$ be the contour of the unit circle $|z|=1$ in the positive direction.  Then using this, we have
$$2I = \oint_C \frac{1}{a\left(\frac{z+z^{-1}}{2}\right)+b}\frac{dz}{iz} = -2 i \oint_C \frac{dz}{az^2+2bz+a}$$
The last integral can be evaluated by residues.  The poles of the function are at 
$$b_\pm = \frac{-b\pm \sqrt{b^2-a^2}}{a}$$
Based on $b>a>0$, we find the only pole in the contour $C$ is $b_+$.  The residue there is:
$$z_+ = \operatorname*{Res}_{z=b_+}\frac{1}{az^2+2bz+a} = \frac{1}{2\sqrt{b^2-a^2}}$$
Then
$$2I = -2 i \left(\frac{2 \pi i}{2\sqrt{b^2-a^2}}\right) = \frac{2\pi}{\sqrt{b^2-a^2}}$$
Divide by $2$ and done.

$$f(z) := \frac{z^2}{1+z^2+z^4} = \frac{z^2}{(z^2-z+1)(z^2+z+1)}$$
Poles of $f$ occur at, using the quadratic formula:
$$b_{1} = \frac{1+\sqrt 3i}{2}$$
$$b_{2} = \frac{-1+\sqrt 3i}{2}$$
$$b_{3} = \frac{1-\sqrt 3i}{2}$$
$$b_{4} = \frac{-1-\sqrt 3i}{2}$$
Using the canonical semicircle contour ($Re^{i\theta}$ for $\theta \in [0,\pi]$) over the upper half plane, it is easily seen that the integral of $f(z)$ over the arc disappears as $R \to \infty$.  Then we only need to find the residues of $b_1$ and $b_2$ (using the first or second formula here):
$$z_1 = \operatorname*{Res}_{z=b_1}f(z)= -\frac{1}{4}-\frac{i}{4\sqrt 3}$$
$$z_2 = \operatorname*{Res}_{z=b_2}f(z)= \frac{1}{4}-\frac{i}{4\sqrt 3}$$
$$\oint_C f(z)\, dz = \int_{-\infty}^\infty f(x)\, dx = 2 \pi i (z_1+z_2) =-2 \pi  i \frac{i}{2\sqrt 3} = \frac{\pi}{\sqrt 3}$$
A: Here are the complex variables techniques you have asked for. The first one, consider the complex integral
$$ \int\limits_{C} \frac{z^2}{1+z^2+z^4}dz, $$
where $C$ is the upper half of the circle $z=Re^{i\theta}$ centered at the origin. Check Jordan' lemma. The second one, write it in the form
$$ \int\limits_{0}^\pi \frac{d\theta}{a\cos\theta+ b}= \frac{1}{2}\int\limits_{-\pi}^\pi\frac{d\theta}{a\cos\theta+ b}, $$
since the integrand is an even function, then use the change of variables $ \theta=\pi-\theta$, to write the integral in the form
$$ \frac{1}{2} \int\limits_{-\pi}^\pi \frac{d\theta}{a\cos\theta+ b}= \frac{1}{2}\int\limits_{0}^{2\pi} \frac{d\theta}{a\cos\theta+ b}.$$
Now, use complex variables techniques $z=e^{i\theta}$ where the $C:|z|=1$. For techniques to find the residue see here.
A: Although the solution above for the second integral works, it's nice to see a rather general method for turning such trignonometric integrals into contour integrals. The following method I learned from Alfhors. We have
$$
I = \frac{1}{2} \int_{0}^{2 \pi} \frac{d \theta}{a \cos \theta + b}
$$
For the right hand integral, consider the contour $C = \{|z| = 1\}$ in the complex plane. For $z = e^{i \theta} \in C$ we have
$$
\cos \theta = \frac{1}{2} (z + \frac{1}{z})
$$
and
$$
dz = i e^{i \theta} d \theta = i z d \theta
$$
This leads to
$$
I = \frac{1}{2} \int_{C} \frac{i dz}{z(\frac{a}{2}(z + \frac{1}{z}) + b)}
$$
You can now apply the usual residue calculus to this integral.
