---
title: Deriving Euler's formula from series
heading: Why Euler's formula is true
eyebrow: A6 · Lesson 43 · Euler's formula from series
xp: 40
---

::: hook
In A3 you watched the series for $e^{j\theta}$ spiral onto the unit circle and took Euler's formula on trust. With Taylor series in hand you can now prove it in three lines, and then prove it a second, completely different way. Two independent proofs of the same surprising fact are worth having: this formula carries all of AC circuit analysis.

::: play
- The yellow and blue curves are $\cos\theta$ and $\sin\theta$. The dashed curves are the real and imaginary parts of the series for $e^{j\theta}$, added up to the power $N$.
- Raise $N$. Which terms of the series build the cosine, and which build the sine?
- With $N = 12$, how far out in θ do the dashed curves still match?
:::
:::

```sim plot
view: graph
x: theta = 0..10
y: y = -2..2
slider: N = 0..12 step 1 = 4
plot: cos(theta) | label: cos θ
plot: sin(theta) | color: ch2 | label: sin θ
plot: 1 - step(N - 2)*theta^2/2 + step(N - 4)*theta^4/24 - step(N - 6)*theta^6/720 + step(N - 8)*theta^8/40320 - step(N - 10)*theta^10/3628800 + step(N - 12)*theta^12/479001600 | dashed | color: ch1 | label: real part
plot: step(N - 1)*theta - step(N - 3)*theta^3/6 + step(N - 5)*theta^5/120 - step(N - 7)*theta^7/5040 + step(N - 9)*theta^9/362880 - step(N - 11)*theta^11/39916800 | dashed | color: ch2 | label: imaginary part
```

::: predict
## In the series $\sum (j\theta)^n/n!$, the term with $n = 4$ is $(j\theta)^4/4!$. Is it real or imaginary, and what sign?

- [x] Real and positive: $+\theta^4/24$
- [ ] Real and negative: $-\theta^4/24$
- [ ] Imaginary: $j\theta^4/24$
- [ ] Imaginary and negative

::: reveal
Real and positive, because $j^4 = 1$. The powers of $j$ cycle $1, j, -1, -j$, so the even terms are real with alternating signs, $1, -\theta^2/2!, +\theta^4/4!, \ldots$, and the odd terms are imaginary with alternating signs. The even ones are exactly the cosine series, and the odd ones the sine series.
:::
:::

::: nameit
## Proof 1: from the series

Put $x = j\theta$ into $e^x = \sum x^n/n!$ and sort the terms by the powers of $j$:

$$e^{j\theta} = \Big(1 - \frac{\theta^2}{2!} + \frac{\theta^4}{4!} - \cdots\Big) + j\Big(\theta - \frac{\theta^3}{3!} + \frac{\theta^5}{5!} - \cdots\Big) = \cos\theta + j\sin\theta$$

Rearranging the terms of an infinite series is allowed here because the series converges absolutely: the sum of the sizes of its terms, $\sum|\theta|^n/n! = e^{|\theta|}$, is finite.

## Proof 2: from derivatives

Let $g(\theta) = \cos\theta + j\sin\theta$. Its derivative is

$$g'(\theta) = -\sin\theta + j\cos\theta = j(\cos\theta + j\sin\theta) = j\,g(\theta)$$

and $g(0) = 1$. The function $e^{j\theta}$ has exactly the same two properties: derivative $j$ times itself, and value 1 at 0. A differential equation like $g' = jg$ with a given starting value has only one solution (A8 shows why), so the two functions are the same.

## What follows

- **De Moivre's formula:** $(\cos\theta + j\sin\theta)^n = e^{jn\theta} = \cos n\theta + j\sin n\theta$. Expanding the left side gives multiple-angle formulas for free: the real part of $(\cos\theta + j\sin\theta)^2$ is $\cos^2\theta - \sin^2\theta = \cos 2\theta$.
- **Cosine and sine as exponentials:** $\cos\theta = \frac{e^{j\theta} + e^{-j\theta}}{2}$ and $\sin\theta = \frac{e^{j\theta} - e^{-j\theta}}{2j}$.
- **Hyperbolic functions** are the same formulas without the $j$: $\cosh x = \frac{e^{x} + e^{-x}}{2}$ and $\sinh x = \frac{e^{x} - e^{-x}}{2}$. They describe a hanging cable, and they turn up in transmission-line formulas (C10).
:::

::: example
## Add the real terms of the series for $e^{j\pi/3}$ up to the fourth power, and compare with $\cos 60°$.

::: solution
1. **Add the real terms.** With $\theta = \pi/3 = 1.047198$:
   $$\begin{aligned} &1 - \frac{\theta^2}{2} + \frac{\theta^4}{24} \\ &= 1 - 0.548311 + 0.050108 \\ &= 0.501796 \end{aligned}$$
2. **Compare.** $\cos 60° = 0.5$, so three real terms are already within 0.002.

**Answer:** the real terms add to 0.501796, within 0.002 of $\cos 60° = 0.5$.
:::
:::

::: example
## Use Euler's formula to show that $\cos^2\theta = \frac{1}{2}(1 + \cos 2\theta)$.

::: solution
1. **Write cosine with exponentials.**
   $$\cos\theta = \frac{e^{j\theta} + e^{-j\theta}}{2}$$
2. **Square it.**
   $$\begin{aligned} \cos^2\theta &= \frac{e^{2j\theta} + 2 + e^{-2j\theta}}{4} \\ &= \frac{2 + 2\cos 2\theta}{4} \\ &= \frac{1}{2}(1 + \cos 2\theta) \end{aligned}$$
3. **See why it works.** Squaring exponentials only adds exponents, which is why Euler's formula turns trigonometric identities into algebra.

**Answer:** $\cos^2\theta = \frac{1}{2}(1 + \cos 2\theta)$, as claimed.
:::
:::

::: example
## What is $j^j$?

::: solution
1. **Write $j$ as an exponential.**
   $$j = e^{j\pi/2}$$
2. **Raise it to the power $j$.**
   $$\begin{aligned} j^j &= \left(e^{j\pi/2}\right)^j \\ &= e^{j^2\pi/2} \\ &= e^{-\pi/2} \\ &= 0.2079 \end{aligned}$$
   a real number.
3. **Note the other values.** Since $j$ is also $e^{j(\pi/2 + 2\pi k)}$, $j^j$ has other values too, $e^{-\pi/2 - 2\pi k}$; 0.2079 is the principal one.

**Answer:** $j^j = e^{-\pi/2} = 0.2079$, a real number (the principal value).
:::
:::

::: check
given: n = 5..12 int
answer: Re(j^n)
tolerance: 0.001

## In the series for $e^{j\theta}$, the term $(j\theta)^{\given{n}}/\given{n}!$ equals $c\,\theta^{\given{n}}/\given{n}!$ times either 1 or $j$. What is the real coefficient $c$ if the term is real, or 0 if it's imaginary?

::: right
Right. It depends only on $j^{\given{n}}$, which is {answer} in its real part.
:::

::: misses
- [any] Find $j^{\given{n}}$ from the cycle $1, j, -1, -j$.
:::
:::

::: check
given: t = 0.5 | 1 | 1.5
answer: 1 - t^2/2 + t^4/24
tolerance: 0.0001%

## Add the real terms of the series for $e^{j\given{t}}$ up to the fourth power.

::: right
Right. $1 - \given{t}^2/2 + \given{t}^4/24$ = {answer}, close to $\cos\given{t}$.
:::

::: misses
- [cos(t)] That's the exact cosine. Stop at the $\theta^4$ term.
- [1 + t^2/2 + t^4/24] The signs alternate, since $j^2 = -1$.
- [any] Not yet. The real terms are $1 - \theta^2/2! + \theta^4/4!$.
:::
:::

::: check
kind: expression
answer: cos(x)^3 - 3*cos(x)*sin(x)^2
vars: x = -2..2

## Using de Moivre, $\cos 3x$ is the real part of $(\cos x + j\sin x)^3$. Expand it and write $\cos 3x$ in terms of $\cos x$ and $\sin x$.

::: right
Right. The binomial expansion gives $c^3 + 3c^2(js) + 3c(js)^2 + (js)^3$; the real terms are $c^3 - 3cs^2$.
:::

::: misses
- [cos(x)^3 + 3*cos(x)*sin(x)^2] $(js)^2 = -s^2$, so that term is negative.
- [3*cos(x)^2*sin(x) - sin(x)^3] That's the imaginary part, which is $\sin 3x$.
- [any] Not yet. Expand $(c + js)^3$ and keep the real terms.
:::
:::

::: check
kind: choice

## Proof 2 shows $g(\theta) = \cos\theta + j\sin\theta$ satisfies $g' = jg$ with $g(0) = 1$. Why does that make $g = e^{j\theta}$?

- [x] $e^{j\theta}$ satisfies the same equation and starting value, and that combination has only one solution
- [ ] Because both are periodic
- [ ] Because both have magnitude 1
- [ ] It doesn't; the two only agree at θ = 0

::: right
Right. A rule for the rate of change plus a starting value determines a function completely, so two functions obeying both must be the same function.
:::

::: misses
- [2] Lots of different functions are periodic. The argument rests on the differential equation.
- [3] Many functions have magnitude 1. The argument rests on the derivative and the starting value.
- [4] Agreeing at the start and changing by the same rule keeps them together everywhere.
:::
:::

::: check
kind: parts
given: t = 0.5 | 1 | 2

## Use Euler's formula with $\theta$ = {t} rad.

::: part
answer: cos(t)
tolerance: 0.5%

### What is $\text{Re}\,e^{j\theta}$?

::: misses
- [any] $e^{j\theta} = \cos\theta + j\sin\theta$.
:::
:::

::: part
answer: cos(2*t)
tolerance: 0.5%

### What is $\text{Re}\,(e^{j\theta})^2$?

::: misses
- [cos(t)^2] Squaring doubles the angle.
- [any] $(e^{j\theta})^2 = e^{j2\theta}$.
:::
:::
:::

::: check
kind: derivation
vars: t = -3..3

## Get the double-angle formulas from Euler's formula.

::: step
answer: cos(t)^2 - sin(t)^2

### Expand $(\cos\theta + j\sin\theta)^2$. What is its real part?
:::

::: step
answer: 2*sin(t)*cos(t)

### What is its imaginary part?
:::

::: right
Right. $\cos 2\theta = \cos^2\theta - \sin^2\theta$ and $\sin 2\theta = 2\sin\theta\cos\theta$, from squaring one exponential.
:::
:::

::: explain
## Explain in a few sentences why the series for $e^{j\theta}$ splits into the cosine series and the sine series.

::: model
The series for $e^x$ has every power of x. Putting $x = j\theta$ multiplies each term by a power of $j$, and those cycle $1, j, -1, -j$. So the even powers come out real, with signs alternating $+, -, +$, and the odd powers come out imaginary, also alternating. The real terms, $1 - \theta^2/2! + \theta^4/4! - \cdots$, are exactly the Taylor series of $\cos\theta$, and the imaginary ones are exactly the series of $\sin\theta$.
:::
:::

::: practice

::: check
given: x = 0.5 | 1 | 2
answer: (exp(x) + exp(-x))/2
tolerance: 0.1%

## What is $\cosh \given{x}$?

::: misses
- [cos(x)] cosh is the hyperbolic cosine: $(e^x + e^{-x})/2$, with no $j$.
- [any] $\cosh x = (e^x + e^{-x})/2$.
:::
:::

::: check
given: n = 2..6 int; t = 10 | 20 | 25
answer: cos(n*t°)
tolerance: 0.1%

## By de Moivre, the real part of $(\cos\given{t}° + j\sin\given{t}°)^{\given{n}}$ is what number?

::: misses
- [cos(t°)^n] De Moivre: raising $e^{j\theta}$ to the n multiplies the angle, giving $\cos n\theta$.
- [any] $(\cos\theta + j\sin\theta)^n = \cos n\theta + j\sin n\theta$.
:::
:::

::: check
given: t = 1 | 1.5 | 2
answer: t - t^3/6 + t^5/120
tolerance: 0.0001%

## Add the imaginary terms of the series for $e^{j\given{t}}$ up to the fifth power (as real numbers, without the $j$).

::: misses
- [sin(t)] That's the exact sine. Stop at the fifth power.
- [any] $\theta - \theta^3/3! + \theta^5/5!$.
:::
:::
:::
