The standard method (typically found in first-year calculus textbooks) for determining the integrals

$\int e^x \cos x \, {\rm d}x$

and

$\int e^x \sin x \, {\rm d}x$

is to integrate by parts twice. If you haven’t seen the standard method, I’ll show you how to do the first one; the second one is similar. Later in the post I’ll show you the neat trick for determining both integrals at once.

It doesn’t much matter whether you let *u* represent the exponential function or the trigonometric function in the first integration, but you have to be consistent in the second integration. (That is, if you let *u* stand for the exponential function in the first integration, then also let *u* stand for the exponential function in the second integration. Alternatively, if you let *u* stand for the trigonometric function in the first integration, then also let *u* stand for the trigonometric function in the second integration.) Otherwise, after two integrations by parts you will end up with 0 = 0, which is true but not helpful.

So, let $u = e^x$ and ${\rm d} v = \cos x \, {\rm d}x$, so that ${\rm d} u = e^x \, {\rm d}x$ and $v = \sin x$. Then, calling the integral to be determined “$I$,” for reasons that will become clear shortly, we have

$I = \int e^x \cos x \, {\rm d}x$

$I = uv \; – \int v \, {\rm d}u$

$I = e^x \sin x \; – \int e^x \sin x \, {\rm d}x$

In the integral on the right side of the previous equation, integrate by parts again, letting $U = e^x$ and ${\rm d} V = \sin x \, {\rm d}x$, so that ${\rm d} U = e^x \, {\rm d}x$ and $V = -\cos x$. The result is

$I = e^x \sin x \; – \left [ UV \; – \int V \, {\rm d}U \right ]$

$I = e^x \sin x \; – \left [ e^x \left ( -\cos x \right ) \; – \int e^x \left ( -\cos x \right ) \, {\rm d}x \right ]$

$I = e^x \sin x \; – \left [- e^x \cos x + \int e^x \cos x \, {\rm d}x \right ]$

$I = e^x \sin x + e^x \cos x \; – \int e^x \cos x \, {\rm d}x$

We seem to be going around in circles, because the integral on the right side of the previous equation is the same as the one we started with. However, if we just replace it by its label $I$, the previous equation is seen to be an algebraic equation that we can solve for $I$. (This is the motivation for introducing the label $I$.) Doing this, we obtain

$I = e^x \sin x + e^x \cos x \; – I$

$2I = e^x \sin x + e^x \cos x$

$2I = e^x \left [ \sin x + \cos x \right ]$

$I = \dfrac{e^x}{2} \left [ \sin x + \cos x \right ]$

$\int e^x \cos x \, {\rm d}x = \dfrac{e^x}{2} \left [ \sin x + \cos x \right ]$

You can check the result by differentiating it to arrive at the original function. Some people enjoy this method as it seems as if we got something for nothing. We never really “finished” the integration by parts (after two iterations, we were still left with an integral), and yet the final result somehow popped out.

And of course, if you need to determine the other integral, then you have to go through the process once more, integrating by parts twice again. Try it for practice, if you wish; the result is

$\int e^x \sin x \, {\rm d}x = \dfrac{e^x}{2} \left [ \sin x \; – \cos x \right ]$

Now for the trick, which relies on you knowing about complex numbers, including Euler’s formula:

$e^{ix} = \cos x + i \sin x$

The strategy is to multiply the second of the original integrals by $i$ and then add it to the first of the original integrals. It turns out that combining them in this way results in an integral that is quite easy to determine; no integration by parts four times is needed. Then we just separate the final result into a sum of real and imaginary parts; the real part is the result for the first integral and the imaginary part is the result of the second integral.

Let’s see how it works: First multiply $\int e^x \sin x \, {\rm d}x$ by $i$ and add it to $\int e^x \cos x \, {\rm d}x$ and combine the integrals into one integral:

$\int e^x \cos x \, {\rm d}x + i \int e^x \sin x \, {\rm d}x = \int \left [ e^x \cos x + i e^x \sin x \right ] \, {\rm d}x$

$\int e^x \cos x \, {\rm d}x + i \int e^x \sin x \, {\rm d}x = \int e^x \left [ \cos x + i \sin x \right ] \, {\rm d}x$

$\int e^x \cos x \, {\rm d}x + i \int e^x \sin x \, {\rm d}x = \int e^x \left [ e^{ix} \right ] \, {\rm d}x$ (using Euler’s formula)

Now combine the exponential functions on the right side of the previous equation and antidifferentiate:

$\int e^x \cos x \, {\rm d}x + i \int e^x \sin x \, {\rm d}x = \int e^{(1 + i)x} \, {\rm d}x$

$\int e^x \cos x \, {\rm d}x + i \int e^x \sin x \, {\rm d}x = \dfrac{1}{1 + i} e^{(1 + i)x}$

The final stage is to express the right side of the previous equation as the sum of a real part and an imaginary part. Part of this process is to multiply the numerator and denominator of the fractional factor by the complex conjugate of the denominator; the other part is to separate the exponential functions on the right side of the equation:

$\int e^x \cos x \, {\rm d}x + i \int e^x \sin x \, {\rm d}x = \dfrac{1}{1 + i} \times \dfrac{1 \; – i}{1 \; – i} e^x e^{ix}$

$\int e^x \cos x \, {\rm d}x + i \int e^x \sin x \, {\rm d}x = \dfrac{1 \; – i}{1 \; – i^2} e^x \left [ \cos x + i \sin x \right ]$

$\int e^x \cos x \, {\rm d}x + i \int e^x \sin x \, {\rm d}x = \dfrac{1 \; – i}{2} e^x \left [ \cos x + i \sin x \right ]$

$\int e^x \cos x \, {\rm d}x + i \int e^x \sin x \, {\rm d}x = \dfrac{e^x}{2} \left [ 1 \; – i \right ] \left [ \cos x + i \sin x \right ]$

$\int e^x \cos x \, {\rm d}x + i \int e^x \sin x \, {\rm d}x = \dfrac{e^x}{2} \left [ \cos x + i \sin x \; – i \cos x \; – i^2 \sin x \right ]$

$\int e^x \cos x \, {\rm d}x + i \int e^x \sin x \, {\rm d}x = \dfrac{e^x}{2} \left [ \cos x + i \sin x \; – i \cos x + \sin x \right ]$

$\int e^x \cos x \, {\rm d}x + i \int e^x \sin x \, {\rm d}x = \dfrac{e^x}{2} \left [ \sin x + \cos x + i \left ( \sin x \; – \cos x \right ) \right ]$

$\int e^x \cos x \, {\rm d}x + i \int e^x \sin x \, {\rm d}x = \dfrac{e^x}{2} \left [ \sin x + \cos x \right ] + i \dfrac{e^x}{2} \left [ \sin x \; – \cos x \right ]$

Matching real and imaginary parts on both sides of the previous equation gives us the final results:

$\int e^x \cos x \, {\rm d}x = \dfrac{e^x}{2} \left [ \sin x + \cos x \right ]$

$\int e^x \sin x \, {\rm d}x = \dfrac{e^x}{2} \left [ \sin x \; – \cos x \right ]$

Conclusion: Does the trick save work? The integration step in the trick method is very easy, so we’re trading four integrations by parts plus some algebra for a simple integration and some algebra with complex numbers. It’s a trade I’d make any day. But of course, to each his own, so try both ways and decide for yourself which way you like better.

If the integrals are a bit more complex, then the savings in the trick method are even greater. For example, you might try using both methods to determine the integrals

$\int e^{ax} \cos bx \, {\rm d}x$

and

$\int e^{ax} \sin bx \, {\rm d}x$

Integration by parts is even more of a pain, but the trick method is hardly more difficult. If you do try them, you can check your final results against these:

$\int e^{ax} \cos bx \, {\rm d}x = \dfrac{e^{ax}}{a^2 + b^2} \left [ b\sin bx + a\cos bx \right ]$

$\int e^{ax} \sin bx \, {\rm d}x = \dfrac{e^{ax}}{a^2 + b^2} \left [ a\sin bx \; – b\cos bx \right ]$

I just did these two integrals with pencil and paper, and the trick method is much faster. Even if you only have to work out one of the integrals (the method is the same, you just ignore one of the final results), I think the trick method is still a time-saver and the probability of making an error is reduced, because you avoid the messy integrations by parts.

(This post first appeared at my other (now deleted) blog, and was transferred to this blog on 21 January 2021.)