Simplify integration with complex variables

Last night I was helping my daughter with her calculus homework. One of the problems was the following integral:

This is an interesting problem for two reasons. First, it illustrates a clever variation on integration by parts; that’s why it was assigned. But it can also be computed using complex variables. As is often the case, the “complex” approach is simpler. Below I’ll show the solution the students were expected to find, then one that they wouldn’t not be expected to find.

Integration by parts

The traditional approach to this integral is to integrate by parts. Letting u = sin(4x), the integral becomes

Next we integrate by parts one more time, this time letting u = cos(4x). This gives us

At this point it looks like we’re getting nowhere. We could keep on integrating by parts forever. Not only that, we’re going in circles: we have an integral that’s just like the one we started with. But then the clever step is to realize that this is a good thing. Let I be our original integral. Then

Now we can solve for I:

Complex variables

Here’s another approach. Recognize that sin(4x) is the imaginary part of exp(4ix) and so our integral is the imaginary part of

which we can integrate immediately:

There’s still algebra to do, but the calculus is over. And while the algebra will take a few steps, it’s routine.

First, let’s take care of the fraction.

Next,

and so our integral is the complex part of

which gives us the same result as before.

The complex variable requires one insight: recognizing a sine as the real part of an exponential. The traditional approach requires several insights: two integrations by parts and solving for the original integral.

Related:

9 thoughts on “Simplify integration with complex variables”

1. How about Laplace transform? There is probably no insight needed!

2. Sachin Shanbhag

Nice demonstration. You don’t need to remember many trig identities if you go complex. For example $\int cos^2(x) dx$

3. the cyclist

“Not only that, we’re going in circles” — pun intended?

4. Is it not possible to convert it to a contour integral?

5. @the cyclist: Sorta. I thought about a possible pun there but didn’t develop it.

@asesh: If this were a definite integral then you could use contour integration.

6. Thanks for inspiring me to do all this by hand… 30+ years since I played with this sort of calculus!

7. Jan Van lent

You could also use
sin(x) = -1/2*i*(exp(i*x)-exp(-i*x)),
integrate and then use
exp(i*x) = cos(x) + i*sin(x).

8. Pseudonym

An even easier (IMO) approach is to use the method of most general forms.

The derivative of $e^{-x}(A \sin(4x) + B \cos(4x))$ is $e^{-x}(C \sin(4x) + D \cos(4x))$, where A, B, C, and D are constants. Let’s assume that the converse is also true.

$\int e^{-x} \sin(4x) dx = e^{-x} (A \sin(4x) + B \sin(4x)) + C$
$\Rightarrow e^{-x} \sin(4x) = \frac{d}{dx} e^{-x} (A \sin(4x) + B \cos(4x))$
$\Rightarrow e^{-x} \sin(4x) = e^{-x} ( (-A – 4B) \sin(4x) + (4A-B) \cos(4x))$

Matching up coefficients gives the linear system:

$-A – 4B = 1$
$4A – B = 0$

Solve this and you’re done.

9. Things have probably changed since, but if I recall right, I was taught de Moivre’s theorem before integration by parts.

More generally, this a good technique to try on any expression involving trigonometric functions, whether in or out of integrals.