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(4*x*), the integral becomes

Next we integrate by parts one more time, this time letting *u* = cos(4*x*). 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(4*x*) is the imaginary part of exp(4*ix*) 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**:

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

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

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

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

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

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

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

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.