# How I Impressed My Wife: Part 4f

Previously in this series, I have used two different techniques to show that

$Q = \displaystyle \int_0^{2\pi} \frac{dx}{\cos^2 x + 2 a \sin x \cos x + (a^2 + b^2) \sin^2 x} = \displaystyle \frac{2\pi}{|b|}.$

Originally, my wife had asked me to compute this integral by hand because Mathematica 4 and Mathematica 8 gave different answers. At the time, I eventually obtained the solution by multiplying the top and bottom of the integrand by $\sec^2 x$ and then employing the substitution $u = \tan x$ (after using trig identities to adjust the limits of integration).
But this wasn’t the only method I tried. Indeed, I tried two or three different methods before deciding they were too messy and trying something different. So, for the rest of this series, I’d like to explore different ways that the above integral can be computed.
Previously in this series, I have used two different techniques to show that

$Q = \displaystyle \int_0^{2\pi} \frac{dx}{\cos^2 x + 2 a \sin x \cos x + (a^2 + b^2) \sin^2 x} = \displaystyle \frac{2\pi}{|b|}.$

Originally, my wife had asked me to compute this integral by hand because Mathematica 4 and Mathematica 8 gave different answers. At the time, I eventually obtained the solution by multiplying the top and bottom of the integrand by $\sec^2 x$ and then employing the substitution $u = \tan x$ (after using trig identities to adjust the limits of integration).
But this wasn’t the only method I tried. Indeed, I tried two or three different methods before deciding they were too messy and trying something different. So, for the rest of this series, I’d like to explore different ways that the above integral can be computed.
Here’s my progress so far:

$Q = \displaystyle \int_0^{2\pi} \frac{dx}{\cos^2 x + 2 a \sin x \cos x + (a^2 + b^2) \sin^2 x}$

$= \displaystyle \int_0^{2\pi} \frac{2 \, dx}{1+\cos 2x + 2 a \sin 2x + (a^2 + b^2)(1-\cos 2x)}$

$= 2 \displaystyle \int_0^{2\pi} \frac{d\theta}{(1+a^2+b^2) + 2 a \sin \theta + (1 - a^2 - b^2) \cos \theta}$

$= 2 \displaystyle \int_{0}^{2\pi} \frac{d\theta}{S + R \cos (\theta - \alpha)}$

$= 2 \displaystyle \int_{0}^{2\pi} \frac{d\phi}{S + R \cos \phi}$

$= \displaystyle -\frac{4i}{R} \oint_C \frac{dz}{z^2 + 2\frac{S}{R}z + 1}$,

where this last integral is taken over the complex plane on the unit circle, a closed contour oriented counterclockwise. In these formulas, $R = \sqrt{(2a)^2 + (1-a^2-b^2)^2}$ and $S = 1 + a^2 + b^2$. (Also, $\alpha$ is a certain angle that is now irrelevant at this point in the calculation).

This contour integral looks complicated; however, it’s an amazing fact that integrals over closed contours can be easily evaluated by only looking at the poles of the integrand. In recent posts, I established that there was only one pole inside the contour, and the residue at this pole was equal to $\displaystyle \frac{R}{ 2 \sqrt{S^2-R^2} }$.

This residue can be used to evaluate the contour integral. Ordinarily, integrals are computed by subtracting the values of the antiderivative at the endpoints. However, there is an alternate way of computing a contour integral using residues. It turns out that the value of the contour integral is $2\pi i$ times the sum of the residues within the contour; see Wikipedia and Mathworld for more information.

Therefore,

$Q = \displaystyle -\frac{4i}{R} \oint_C \frac{dz}{(z - r_1)(z- r_2)}$

$= \displaystyle -\frac{4i}{R} \cdot 2\pi i \cdot \frac{R}{ 2 \sqrt{S^2-R^2} }$

$= \displaystyle \frac{4\pi}{\sqrt{S^2-R^2}}$

Next, I use some algebra to simplify the denominator:

$S^2 - R^2 = (1+a^2+b^2)^2 - (1-a^2-b^2)^2 - (2a)^2$

$S^2 - R^2 = [(1 + a^2 + b^2) + (1-a^2-b^2)][(1 + a^2 + b^2) - (1 - a^2 -b^2)] - 4a^2$

$S^2 - R^2 = 2[2 a^2 + 2b^2] - 4a^2$

$S^2 - R^2 = 4b^2$

Therefore,

$Q = \displaystyle \frac{4\pi}{\sqrt{4b^2}} = \displaystyle \frac{4\pi}{2|b|} = \frac{2\pi}{|b|}$

Once again, this matches the solution found with the previous methods… and I was careful to avoid a common algebraic mistake.

In tomorrow’s post, I’ll discuss an alternative way of computing the residue.