Easy example why complex numbers are cool

Using $e^{i\theta} = \cos \theta + i \sin \theta$ it is very easy to find (and remember) many trigonometric identities.

For example, $e^{i(\alpha+\beta)} = e^{i\alpha}e^{i\beta}$ gives the sine-of-sums and cosine-of-sums formulas.


$$ \begin{align} e^{i(\alpha+\beta)} &= e^{i\alpha}e^{i\beta} \\ \cos(\alpha+\beta) + i \sin(\alpha+\beta) &= (\cos \alpha + i \sin \alpha)(\cos \beta + i \sin \beta) \\ &= (\cos \alpha \cos \beta - \sin \alpha \sin \beta) + i (\sin \alpha \cos \beta + \cos \alpha \sin \beta) \\ \end{align} $$

Equating the real parts,

$$\cos (\alpha + \beta) = \cos \alpha \cos \beta - \sin \alpha \sin \beta$$

Equating the imaginary parts,

$$\sin(\alpha+\beta) = \sin \alpha \cos \beta + \cos \alpha \sin \beta$$


Here's a really cool application: Complex Step Differentiation

The basic idea is that you normally compute a derivative as:

$$f'(x) \approx \frac{f(x+h)-f(x)}{h}$$

This requires evaluating $f$ twice. But what if we use complex numbers?

$$f'(x) \approx \frac{f(x+ih)-f(x)}{ih}\approx \frac{\Im{f(x+ih)}}{ih} $$

Now we only need to evaluate $f$ once!* ($\Im(z)$ is just the imaginary part of $z$.)
Not just that, but it's a lot more numerically accurate, too -- see the link above.

* This assumes the function is real-valued for real inputs, and analytic. In practice it often is.