How I Impressed My Wife: Part 4c

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.
green lineHere’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. Also, R = \sqrt{(2a)^2 + (1-a^2-b^2)^2} and S = 1 + a^2 + b^2 (and \alpha is a certain angle that is now irrelevant at this point in the calculation).

This contour integral looks more 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. For this integral, that means finding the values of z where the denominator is equal to 0, and then determining which of those values lie inside of the closed contour. In this case, that means finding which root(s) of the denominator lie inside the unit circle in the complex plane.

To begin, we use the quadratic formula to find the roots of the denominator:

z^2 + 2\frac{S}{R}z + 1 = 0

Rz^2 + 2Sz + R = 0

z = \displaystyle \frac{-2S \pm \sqrt{4S^2 - 4R^2}}{2R}

z = \displaystyle \frac{-S \pm \sqrt{S^2 -R^2}}{R}.

So we have the two roots r_1 = \displaystyle \frac{-S + \sqrt{S^2 -R^2}}{R} and r_2 = \displaystyle \frac{-S - \sqrt{S^2 -R^2}}{R}. Earlier in this series, I showed that S > R > 0 as long as b \ne 0, and so the denominator has two distinct real roots. So the integral Q may be rewritten as

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

green line

Next, we have to determine if either r_1 or r_2 (or both) lies inside of the contour. I’ll discuss this in tomorrow’s post.

How I Impressed My Wife: Part 4b

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.
green lineLet me backtrack to a point in the middle of the previous solution:

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},

where R = \sqrt{(2a)^2 + (1-a^2-b^2)^2} and S = 1 + a^2 + b^2 (and \alpha is a certain angle that is now irrelevant at this point in the calculation).

Earlier in this series, I used the magic substitution u = \tan \displaystyle \frac{\phi}{2} to evaluate this last integral. Now, I’ll instead use contour integration; see Wikipedia for more details. I will use Euler’s formula as a substitution (see here and here for more details):

z = e^{i \phi} = \cos \phi + i \sin \phi,

so that the integral Q is transformed to a contour integral in the complex plane. Under this substitution, as discussed in yesterday’s post,

\cos \phi = \displaystyle \frac{1}{2} \left[z + \displaystyle \frac{1}{z} \right]

and

d\phi = \displaystyle -\frac{i}{z} dz

Employing this substitution, the region of integration changes from 0 \le \phi \le 2\pi to a the unit circle C, a closed counterclockwise contour in the complex plane:

Q = 2 \displaystyle \oint_C \frac{\displaystyle -\frac{i}{z} dz}{S + \displaystyle \frac{R}{2} \left[z + \displaystyle \frac{1}{z} \right]}

= -4i \displaystyle \oint_C \frac{dz}{Rz^2 + 2Sz + R}

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

green lineWhile this looks integral in the complex plane looks a lot more complicated than a regular integral, it’s actually a lot easier to compute using residues. I’ll discuss the computation of this contour integral in tomorrow’s post.

How I Impressed My Wife: Part 4a

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.
green lineLet me backtrack to a point in the middle of the previous solution:

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},

where R = \sqrt{(2a)^2 + (1-a^2-b^2)^2} and S = 1 + a^2 + b^2 (and \alpha is a certain angle that is now irrelevant at this point in the calculation).

In the previous solution, I used the “magic substitution” u = \tan \displaystyle \frac{\phi}{2} to convert the last integrand to a simple rational function. Starting today, I’ll use a completely different technique to compute this last integral.

The technique that I’ll use is contour integration; see Wikipedia for more details. I will use Euler’s formula as a substitution (see here and here for more details):

z = e^{i \phi} = \cos \phi + i \sin \phi,

so that the integral Q is transformed to a contour integral in the complex plane.

Under this substitution,

\displaystyle \frac{1}{z} = e^{-i\phi} = \cos(-\phi) + i \sin(-\phi) = \cos \phi - i \sin \phi

Using these last two equations, I can solve for \cos \phi and \sin \phi in terms of z and \displaystyle \frac{1}{z}. I’ll begin with \cos \phi:

z + \displaystyle \frac{1}{z} = \cos \phi + i \sin \phi + \cos \phi - i \sin \phi

z + \displaystyle \frac{1}{z} = 2 \cos \phi

\displaystyle \frac{1}{2} \left[z + \displaystyle \frac{1}{z} \right] = \cos \phi

Though not necessary for this particular, let me solve for \sin \phi for completeness:

z - \displaystyle \frac{1}{z} = \cos \phi + i \sin \phi - [ \cos \phi - i \sin \phi]

z - \displaystyle \frac{1}{z} = 2i \sin \phi

\displaystyle \frac{1}{2i} \left[z - \displaystyle \frac{1}{z} \right] = \sin\phi

 Finally, let me solve for the differential d\phi:

z = e^{i \phi}

dz = i e^{i \phi} d\phi

\displaystyle \frac{1}{i} e^{-i \phi} dz = d\phi

-i e^{-i \phi} dz = d\phi

\displaystyle -\frac{i}{z} dz = d\phi

green line I’ll continue with this different method of evaluating this integral in tomorrow’s post.

How I Impressed My Wife: Part 3i

Previously in this series, I showed 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|}.

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.
green line

So far, I have shown 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 \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}

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

= 4 \displaystyle \int_{-\infty}^{\infty} \frac{du}{(S + R) + u^2 (S - R)}

= \displaystyle \frac{2}{|b|} \int_{-\infty}^{\infty} \frac{dv}{1 + v^2},

as long as b \ne 0. (In the above calculations, the constants R, S, and \alpha depend on a and b but are no longer necessary at this point in the calculation.)

We can now directly compute this final integral using an antiderivative derived earlier in this series:

Q = \displaystyle \frac{2}{|b|} \left[ \tan^{-1} v \right]^{\infty}_{-\infty}

Q = \displaystyle \frac{2}{|b|} \left[ \displaystyle \frac{\pi}{2} - \displaystyle \frac{-\pi}{2} \right]

Q = \displaystyle \frac{2\pi}{|b|}

green line And so, with this completely different technique, we arrive at the same answer for the integral Q.

However, there are still different ways of computing Q. I’ll start on another method of attack with tomorrow’s post.

How I Impressed My Wife: Part 3h

Previously in this series, I showed 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|}.

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.
green line

So far, I have shown 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 \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}

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

= 4 \displaystyle \int_{-\infty}^{\infty} \frac{du}{(S + R) + u^2 (S - R)}

where R = \sqrt{(2a)^2 + (1-a^2-b^2)^2} and S = 1 + a^2 + b^2 (and \alpha is a certain angle that is now irrelevant at this point in the calculation).

We now employ the substitution

u = \displaystyle \sqrt{ \frac{S+R}{S-R} } v,

so that

du = \displaystyle \sqrt{ \frac{S+R}{S-R} } dv.

Before going much further, let’s take a closer look at R and S to make sure that \displaystyle \frac{S+R}{S-R} is positive (so that the square root is defined).

First, both S and $R$ are clearly positive, and so S+R > 0.

Next, notice that

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

So S^2 - R^2 > 0 as long as b > 0. Therefore, since S + R > 0:

S^2 - R^2 > 0

(S+R)(S-R) > 0

S - R > 0

So, since S + R > 0 and S - R > 0, we have \displaystyle \frac{S+R}{S-R} > 0, and so the above substitution is well-defined.

We now employ the above substitution. The endpoints of integration remain unchanged, and so

Q = 4 \displaystyle \int_{-\infty}^{\infty} \frac{\displaystyle \sqrt{ \frac{S+R}{S-R} } dv}{(S + R) + \left[ \displaystyle \sqrt{ \frac{S+R}{S-R} } v \right]^2 (S - R)}

= 4 \displaystyle \int_{-\infty}^{\infty} \frac{\displaystyle \sqrt{ \frac{S+R}{S-R} } dv}{(S + R) + (S + R) v^2}

= \displaystyle \frac{4}{S+R} \sqrt{ \frac{S+R}{S-R}} \int_{-\infty}^{\infty} \frac{dv}{1 + v^2}

= \displaystyle 4 \sqrt{ \frac{1}{(S+R)(S-R)}} \int_{-\infty}^{\infty} \frac{dv}{1 + v^2}

= \displaystyle 4 \sqrt{ \frac{1}{S^2-R^2}} \int_{-\infty}^{\infty} \frac{dv}{1 + v^2}

= \displaystyle 4 \sqrt{ \frac{1}{4b^2}} \int_{-\infty}^{\infty} \frac{dv}{1 + v^2}

= \displaystyle \frac{4}{2|b|} \int_{-\infty}^{\infty} \frac{dv}{1 + v^2}

= \displaystyle \frac{2}{|b|} \int_{-\infty}^{\infty} \frac{dv}{1 + v^2}

In the above calculation, I used the fact that S^2 - R^2 = 4b^2, which was derived above. Also, I was careful to avoid a common algebraic mistake.

green line I’ll complete this different method of evaluating this integral in tomorrow’s post.

How I Impressed My Wife: Part 3g

Previously in this series, I showed 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|}.

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.
green line

So far, I have shown 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 \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}

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

where R = \sqrt{(2a)^2 + (1-a^2-b^2)^2} and S = 1 + a^2 + b^2 (and \alpha is a certain angle that is now irrelevant at this point in the calculation).

As discussed in yesterday’s post, I now employ the “magic substitution” u = \tan \displaystyle \frac{\phi}{2}, so that

\cos \phi = \displaystyle \frac{1-u^2}{1+u^2}

and

d\phi = \displaystyle \frac{2 du}{1+u^2}.

Employing this substitution, the range of integration changes from -\pi < \phi < \pi to -\infty < u < \infty, so that

Q = 2 \displaystyle \int_{-\infty}^{\infty} \frac{ ~ \displaystyle \frac{2 du}{1+u^2} ~}{~ S + R \displaystyle \frac{1-u^2}{1+u^2} ~}

= 4 \displaystyle \int_{-\infty}^{\infty} \frac{du}{S(1+u^2) + R(1-u^2)}

= 4 \displaystyle \int_{-\infty}^{\infty} \frac{du}{(S + R) + u^2 (S - R)}

green lineUsing the magic substitution, the integral Q has been converted to a standard rational function. I’ll continue with this different method of evaluating this integral in tomorrow’s post.

How I Impressed My Wife: Part 3f

Previously in this series, I showed 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|}.

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.
green line

So far, I have shown 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 \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}

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

where R = \sqrt{(2a)^2 + (1-a^2-b^2)^2} and S = 1 + a^2 + b^2 (and \alpha is a certain angle that is now irrelevant at this point in the calculation).

There are actually a couple of ways for computing this last integral. Today, I’ll lay the foundation for the “magic substitution”

u = \tan \displaystyle \frac{\phi}{2}

With this substitution, the above integral will become a rational function, which can then be found using standard techniques.

First, we use some trig identities to rewrite \cos 2x in terms of \tan x:

\cos 2x = 2\cos^2 x - 1

= \displaystyle \frac{ \sec^2 x (2 \cos^2 x - 1)}{\sec^2 x}

= \displaystyle \frac{ 2 - \sec^2 x)}{\sec^2 x}

= \displaystyle \frac{ 2 - [ 1 + \tan^2 x])}{1 + \tan^2 x}

= \displaystyle \frac{1- \tan^2 x}{1 + \tan^2 x}

Next, I’ll replace x by \phi/2:

\cos \phi = \displaystyle \frac{1- \tan^2 (\phi/2)}{1 + \tan^2 (\phi/2)} = \displaystyle \frac{1-u^2}{1+u^2}.

Second, for the sake of completeness (even though it isn’t necessary for this particular integral), I’ll rewrite \sin 2x in terms of \tan x:

\sin 2x = 2\sin x \cos x

= \displaystyle \frac{2\sin x \cos x \sec^2 x}{\sec^2 x}

= \displaystyle \frac{ ~ \displaystyle \frac{2 \sin x}{\cos x} ~ }{\sec^2 x}

= \displaystyle \frac{ 2 \tan x }{\sec^2 x}

= \displaystyle \frac{ 2 \tan x }{1 + \tan^2 x}

= \displaystyle \frac{2 \tan x}{1 + \tan^2 x}

Next, I’ll replace x by \phi/2:

\sin \phi = \displaystyle \frac{2 \tan^2 (\phi/2)}{1 + \tan^2 (\phi/2)} = \displaystyle \frac{2u}{1+u^2}.

Third, again for the sake of completeness,

\tan \phi = \displaystyle \frac{\sin u}{\cos u} = \displaystyle \frac{ ~ \displaystyle \frac{2u}{1+u^2} ~ }{ ~ \displaystyle \frac{1-u^2}{1+u^2} ~ } = \displaystyle \frac{2u}{1-u^2}.

Finally, I need to worry about what happens to the d\phi:

u = \tan \displaystyle \frac{\phi}{2}

du = \displaystyle \frac{1}{2} \sec^2 \displaystyle \frac{\phi}{2} \, d\phi

du = \displaystyle \frac{1}{2} \left[ 1 + \tan^2 \displaystyle \frac{\phi}{2} \right] d\phi

du = \displaystyle \frac{1}{2} (1+u^2) d\phi

\displaystyle \frac{2 du}{1+u^2} = d\phi

These four substitutions can be used to convert trigonometric integrals into some other integral. Usually, the new integrand is pretty messy, and so these substitutions should only be used sparingly, as a last resort.

green line

I’ll continue this different method of evaluating this integral in tomorrow’s post.

How I Impressed My Wife: Part 3e

Previously in this series, I showed 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|}.

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.
green line

So far, I have shown 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 \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}.

where R = \sqrt{(2a)^2 + (1-a^2-b^2)^2} and S = 1 + a^2 + b^2 (and \alpha is a certain angle that is now irrelevant at this point in the calculation).

I now write Q as a new sum Q_5 + Q_6 by again dividing the region of integration:

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

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

For Q_6, I employ the substitution u = \phi - 2\pi, so that \phi = u + 2\pi and d\phi= du. Also, the interval of integration changes from \pi \le \phi \le 2\pi to -\pi \le u \le 0, so that

Q_6 = 2 \displaystyle \int_{-\pi}^{0} \frac{du}{S + R \cos (u + 2\pi)}

Next, I employ the trigonometric identity \cos(u + 2\pi) = \cos u:

Q_6 = 2 \displaystyle \int_{-\pi}^{0} \frac{du}{S + R \cos u} = 2 \displaystyle \int_{-\pi}^{0} \frac{d\phi}{S + R \cos \phi},

where I have changed the dummy variable from u back to \phi.

Therefore, Q = Q_6 + Q_5 becomes

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

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

Once again, the fact that the integrand is over an interval of length 2\pi allows me to shift the interval of integration.

green line

I’ll continue this different method of evaluating this integral in tomorrow’s post.

How I Impressed My Wife: Part 3d

Previously in this series, I showed 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|}.

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.
green line

So far, I have shown 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 \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)},

where R = \sqrt{(2a)^2 + (1-a^2-b^2)^2}, S = 1 + a^2 + b^2, and \alpha is a certain angle (that will soon become irrelevant).

I now write Q as a new sum Q_3 + Q_4 by dividing the region of integration:

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

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

For Q_3, I employ the substitution u = \theta + 2\pi, so that \theta = u - 2\pi and d\theta = du. Also, the interval of integration changes from 0 \le \theta \le \alpha to 2\pi \le u \le 2\pi + \alpha, so that

Q_3 = 2 \displaystyle \int_{2\pi}^{2\pi + \alpha} \frac{du}{S + R \cos (u - 2\pi - \alpha)}

Next, I employ the trigonometric identity \cos(u - 2\pi - \alpha) = \cos (u -\alpha):

Q_3 = 2 \displaystyle \int_{2\pi}^{2\pi + \alpha} \frac{du}{S + R \cos (u - \alpha)} = 2 \displaystyle \int_{2\pi}^{2\pi + \alpha} \frac{d\theta}{S + R \cos (\theta - \alpha)},

where I have changed the dummy variable from u back to \theta.

Therefore, Q = Q_4 + Q_3 becomes

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

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

Next, I employ the substitution \phi = \theta - \alpha, so that d\phi = d\theta and the interval of integration changes from \alpha \le \theta \le 2\pi + \alpha to 0 \le \phi \le 2\pi:

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

Almost by magic, the mysterious angle \alpha has completely disappeared, making the integral that much easier to compute.

green line

I’ll continue this different method of evaluating this integral in tomorrow’s post.

How I Impressed My Wife: Part 3c

Previously in this series, I showed 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|}.

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.
green line

So far, I have shown 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 \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}.

To simplify the denominator even further, I will combine the two trigonometric terms in the denominator; this is possible because the argument of both the sine and cosine functions are the same. To this end, notice that

2 a \sin \theta + (1 - a^2 - b^2) \cos \theta = R \displaystyle \left[ \frac{2a}{R} \sin \theta + \frac{1-a^2-b^2}{R} \cos \theta \right],

where

R = \sqrt{(2a)^2 + (1-a^2-b^2)^2}

Next, let \alpha be the unique angle so that

\cos \alpha = \displaystyle \frac{1-a^2-b^2}{\sqrt{(2a)^2 + (1-a^2-b^2)^2}},

\sin \alpha = \displaystyle \frac{2a}{\sqrt{(2a)^2 + (1-a^2-b^2)^2}}.

With this substitution, we find that

2 a \sin \theta + (1 - a^2 - b^2) \cos \theta = R [\cos \theta \cos \alpha + \sin \theta \sin \alpha]

= R \cos(\theta - \alpha)

Therefore, the integral Q may be rewritten as

Q = 2 \displaystyle \int_0^{2\pi} \frac{d\theta}{S + R \cos (\theta - \alpha)},

where R = \sqrt{(2a)^2 + (1-a^2-b^2)^2} and S = 1 + a^2 + b^2.

green line

I’ll continue this different method of evaluating this integral in tomorrow’s post.