# Integration with complex numbers

I know that you can integrate

$$\int e^{-x}\cos(x)dx$$

by parts, but I would like to know how you can use complex variables instead.

-
Use Euler's formula to express $\cos x$ in terms of complex exponentials. – Ben Crowell Feb 5 '12 at 4:24
Re integration by parts -- is that possible for this integral? I don't see how that would work. – Ben Crowell Feb 5 '12 at 4:54
@Ben I think it is possible to integrate this by parts. In general it is possible to integrate $\int e^{ax} \cos bx \mathrm d x$ by parts. The same is true when $\cos bx$ is replaced by $\sin bx$. – user21436 Feb 5 '12 at 5:11

Euler's form of a complex Number:

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

And, note that, as $\sin (-x)= -\sin x$ and $\cos (-x) = \cos x$, we have that, $$e^{-i x}=\cos x-i \sin x$$

This together gives you, $$\cos x = \dfrac{e^{ix}+e^{-ix}}{2}$$

Note: $\Re$ stands for the real part of a complex number and $\Im$ for its imaginary part.

Method 1:

\begin{align*}\int e^{-x}\cos x~~ \mathrm d x &= \Re\left(\int e^{-x}e^{ix} \mathrm dx\right)\\&=\Re\left(\int e^{x(i-1)} \mathrm d x\right) \\&=\Re\left(\dfrac{e^{x(i-1)}}{i-1}\right)\\&=e^{-x}\cdot\Re\left(\dfrac{\cos x+ i \sin x}{-1+i}\right) \\&= e^{-x} \cdot\dfrac{\sin x-\cos x}{2}\end{align*}

Method 2:(Ben's Comment)

\begin{align*} \int e^{-x} \cos x ~\mathrm dx&=\int e^{-x} \cdot \dfrac{e^{ix}+e^{-ix}}{2} \mathrm dx\\&=\dfrac{1}{2} \cdot \int (e^{ix-x}+e^{-ix-x}) \mathrm d x\\&=\dfrac{1}{2}\cdot \left(\dfrac{e^{x(i-1)}}{i-1}+\dfrac{e^{x(-1-i)}}{-i-1}\right)\end{align*}

Leaving the simplifications to you, you will see that the answer still turns out to be the same.

-
Looks fine, except that the factor of 1/2 appears one line too early. As an alternative to using the real part, one can write $\cos x$ as $(e^{ix}+e^{-ix})/2$. – Ben Crowell Feb 5 '12 at 4:51
@Ben I have added your suggestion as well. Thank You! – user21436 Feb 5 '12 at 5:07