Euler's Formula

In this chapter you'll learn one of the most amazing math things I have seen.

Be sure to learn radians, sin, cos, derivatives, e and Taylor series before reading this chapter. That's lots of stuff to learn, but this chapter is definitely worth the effort.

With all that out of the way, this chapter will blow up your mind. Proceed at your own risk.

Imaginary Numbers

In the basics section I said that you cannot do things like $\sqrt{-1}$, but now we'll do that.

$$\begin{align}i = \sqrt{-1}\end{align}$$

So we have $i^2=-1$. Obviously this weird "number" is not between $-\infty$ and $\infty$ because no number in that range behaves like this. It's something else, and the $i$ is short for imaginary. The numbers between $-\infty$ and $\infty$ are known as real numbers, but $-\infty$ and $\infty$ are not real because they behave very differently than real numbers.

A complex number is something real plus something imaginary, and they are often represented in a 2D plane. Like this:

Re is short for Real and Im for Imaginary.

Note how the words "imaginary" and "complex" reflect people's attitudes to these numbers. At first they were considered nonsense, but nowadays there are many uses for complex numbers. This tutorial focuses on a very important way to use them.

The Magic

Let's calculate some powers of $i$. We'll need them later.

$$\begin{align}i^1 &= i \\ i^2 &= -1 \\ i^3 &= (-1)i = -i \\ i^4 &= (-1)(-1) = 1 \\ i^5 &= i^4i^1=1i = i \\ i^6 &= i^4i^2=1(-1)=-1 \\ i^7 &= i^4i^3=1(-i)=-i \\ i^8 &= i^4i^4=1 \cdot 1 = 1 \\ ...\end{align}$$

We can see a pattern.

In the Taylor chapter we created these awesome series representations:

$$\begin{align}\sin(x) &= x - \frac{x^3}{3!} + \frac{x^5}{5!} - \frac{x^7}{7!} + \frac{x^9}{9!} - ... \\ \cos(x) &= 1 - \frac{x^2}{2!} + \frac{x^4}{4!} - \frac{x^6}{6!} + \frac{x^8}{8!} - ... \\ e^x &= 1 + x + \frac{x^2}{2!} + \frac{x^3}{3!} + \frac{x^4}{4!} + ...\end{align}$$

Let's try to calculate $e^{ix}$ and let the magic happen.

$$\begin{align}e^{ix} &= 1 + ix + \frac{(ix)^2}{2!} + \frac{(ix)^3}{3!} + \frac{(ix)^4}{4!} + \frac{(ix)^5}{5!} + \frac{(ix)^6}{6!} + ... \\ &= 1 + ix + \frac{i^2x^2}{2!} + \frac{i^3x^3}{3!} + \frac{i^4x^4}{4!} + \frac{i^5x^5}{5!} + \frac{i^6x^6}{6!} + ... \\ &= 1 + ix + \frac{(-1)x^2}{2!} + \frac{(-1)ix^3}{3!} + \frac{1x^4}{4!} + \frac{ix^5}{5!} + \frac{(-1)x^6}{6!} + ... \\ &= 1 + ix - \frac{x^2}{2!} - i\frac{x^3}{3!} + \frac{x^4}{4!} + i\frac{x^5}{5!} - \frac{x^6}{6!} + ... \\ &= \left(1 - \frac{x^2}{2!} + \frac{x^4}{4!} - \frac{x^6}{6!} + ...\right) + \left(ix - i\frac{x^3}{3!} + i\frac{x^5}{5!} - i\frac{x^7}{7!} + ...\right) \\ &= \left(1 - \frac{x^2}{2!} + \frac{x^4}{4!} - \frac{x^6}{6!} + ...\right) + i \left(x - \frac{x^3}{3!} + \frac{x^5}{5!} - \frac{x^7}{7!} + ...\right) \\ &= \cos(x) + i \sin(x)\end{align}$$

Boom. Can you believe that. We started with $e$ which we got out of exponentials and derivatives and the $i$, but we ended up with trig functions that are defined in a unit circle!

This is crazness is known as Euler's formula. Speaking of Euler, he's known for many many other math things as well, and I find it really amazing how much awesome math stuff he did. Even things like the $f(x)$ notation with parentheses and the concept of a function are from him.

After all the amazement, let's have a look at what we got. We know that $\cos$ is the $x$ coordinate and $\sin$ is the $y$ coordinate in a unit circle, and a moment ago we drew a $(\text{Re}, \text{Im})$-plane. Actually the formula represents a unit circle in $(\text{Re}, \text{Im})$ plane!

Just looking at the above drawing, everything else makes sense perfectly except the $e^{i\theta}$ label. It's just crazy.

Example: Trig Identities

Let's draw another unit circle with angles $\theta$ and $-\theta$.

The black dots are aligned horizontally so $x$ coordinates are the same and $\cos(\theta)=\cos(-\theta)$. But the $y$ coordinates are opposite, so $\sin(-\theta)=-\sin(\theta)$. These work with any $\theta$.

Let's plug some stuff to Euler's formula and use these trig things:

$$\begin{align}e^{i\theta} &= \cos(\theta) + i\sin(\theta) \\ e^{-i\theta} &= \cos(-\theta) + i\sin(-\theta) \\ &= \cos(\theta)-i\sin(\theta)\end{align}$$$$\begin{align}e^{i\theta}+e^{-i\theta} &= (\cos(\theta)+i\sin(\theta)) + (\cos(\theta)-i\sin(\theta)) \\ &= \cos(\theta)+i\sin(\theta)+\cos(\theta)-i\sin(\theta) \\ &= 2\cos(\theta) \\ \frac{e^{i\theta}+e^{-i\theta}}{2}&=\cos(\theta)\end{align}$$

Now your mind should be really blown up.

$$\begin{align}e^{i\theta}-e^{-i\theta} &= (\cos(\theta)+i\sin(\theta)) - (\cos(\theta)-i\sin(\theta)) \\ &= \cos(\theta)+i\sin(\theta)-\cos(\theta)+i\sin(\theta) \\ &= 2i\sin(\theta) \\ \frac{e^{i\theta}-e^{-i\theta}}{2i} &= \sin(\theta)\end{align}$$

Handy thing: $a^2-b^2=(a-b)(a+b)$

Proof using $(a+b)c=ac+bc$ and $(a-b)c=ac-bc$:

$$\begin{align}& \ (a-b)(a+b) \\ =&\ a(a+b)-b(a+b) \\ =&\ (aa+ab)-(ba+bb) \\ =&\ aa\rcancel{+ab}\rcancel{-ab}-bb \\ =&\ a^2 - b^2\end{align}$$

In this case we need to plug in $a=e^{i\theta}$ and $b=e^{-i\theta}$.

Equally head-exploding.

For example, let's try to find another way to represent $\sin(2\theta)$:

$$\begin{align}\sin(2\theta) &= \frac{e^{2i\theta}-e^{-2i\theta}}{2i} \\ &= \frac{(e^{i\theta})^2-(e^{-i\theta})^2}{2i} \\ &= \frac{(e^{i\theta}-e^{-i\theta})(e^{i\theta}+e^{-i\theta})}{2i} \\ &= 2 \cdot \frac{e^{i\theta}-e^{-i\theta}}{2i} \cdot \frac{e^{i\theta}+e^{-i\theta}}{2} \\ &= 2 \sin(\theta) \cos(\theta)\end{align}$$

This is just the tip of the iceberg. It's possible to find dozens of handy-dandy trig equations like this. Most trig things can be proved without Euler's formula, but this magic way can be much easier and faster.

Exercise

This is a true story. A friend of mine had watched a youtube video that used this formula, and he wanted to see a proof of it:

$$\begin{align}\tan(2\theta)=\frac{2\tan(\theta)}{1-\tan^2(\theta)}\end{align}$$

Here $\tan^2(\theta)$ means $(\tan(\theta))^2$, and people use the $\tan^2$ notation because it's easier and faster to write although it doesn't make much sense. Prove the above formula.

One way to do this is to use these formulas:

Then rewrite the left side as $\displaystyle\frac{\sin(2\theta)}{\cos(2\theta)}$, use the formulas and try to rewrite the result in terms of $\tan(\theta)$.

Example: Famous Constants

If we plug in $\theta=\tau=2\pi$ we get this:

$$\begin{align}e^{i\tau} = \cos(\tau) + i \sin(\tau) = 1 + i \cdot 0 = 1\end{align}$$

This makes sense because if we start at 1 and rotate a full turn ($\tau$ radians), we get back to where we started.

But if we don't rotate at all we also end up at 1:

$$\begin{align}e^{i \cdot 0} = e^0 = 1\end{align}$$

Equations like $e^{i\theta}=1$ have an infinite number of solutions because any number of full turns produces the 1, just like any number of full turns is a solution of $\cos(\theta)=1$.

We can also plug in $\theta=\frac \tau 2=\pi$ to go a half turn and end up at $-1$, and we get a very famous equation:

$$\begin{align}e^{i\pi} = -1\end{align}$$