Simplify integration with complex variables

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

\int \exp(-x) \sin(4x) \, dx

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

- \exp(-x) \sin(4x) + 4 \int \exp(-x) \cos(4x) \, dx

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

- \exp(-x) \sin(4x) - 4 \exp(-x) \cos(4x) -16\int \exp(-x) \sin(4x) \, dx

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

I = -\exp(x) \left(\sin(4x) + 4 \cos(4x)\right) - 16 I

Now we can solve for I:

I = - \frac{1}{17} \exp(-x) (\sin(4x) + 4 \cos(4x))

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

\int \exp(-x) \exp(-4ix) \,dx = \int \exp\left((-1+4i)x\right) \,dx

which we can integrate immediately:

\frac{1}{-1+4i} \exp\left((-1+4i)x\right).

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.

\frac{1}{-1+4i} = \frac{1}{-1+4i} \frac{-1 - 4i}{-1 - 4i} = - \frac{1+4i}{17}.

Next,

\exp\left((-1+4i)x\right) = \exp(-x)\left( \cos(4x) + i \sin(4x) \right)

and so our integral is the complex part of

-\frac{1}{17} \exp(-x) (1 + 4i)\left( \cos(4x) + i \sin(4x) \right)

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:

8 thoughts on “Simplify integration with complex variables

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

  2. @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.

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

  4. 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).

  5. 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.

Leave a Reply

Your email address will not be published. Required fields are marked *