4.3. Complex exponentials#

Recall the definition of the exponential function as an infinite summation:

\[e^x = \sum_{n=0}^{\infty} \frac{x^n}{n!}\]

We normally think of this definition in terms of real-valued \(x\), but the idea carries over to complex exponentials \(e^z\) for \(z \in \mathbb{C}\) using exactly the same formula with \(z\) in place of \(x\).

Because any complex \(z\) is the sum of its real and imaginary parts, it can be helpful to separate the exponential using the product rule:

\[e^z = e^{a + \mathrm{j}b} = e^a \cdot e^{\mathrm{j}b}\]

Since \(a\) is real, we already have a good handle on how \(e^a\) behaves. Let’s focus on what happens just to that second factor, where the quantity in the exponent is purely imaginary: \(e^{\mathrm{j}b}\).

Fig. 4.6 shows what happens as we form better approximations to \(e^{\mathrm{j}b}\) by taking more terms in the summation (up to 50), for \(b \in [-4\pi, +4\pi]\). For clarity, the numbers in the interval \([-\pi, \pi]\) are highlighted.

Fig. 4.6 Partial summations illustrate how Euler’s formula maps imagine numbers \(\mathrm{j}b\) to the unit circle in the complex plane.#

4.3.1. Euler’s formula#

Fig. 4.6 shows that \(e^{\mathrm{j}b}\) wraps imaginary numbers around the unit circle in the complex plane. By visual inspection, one can see that the point \(b=0\) maps to \(z=1 + 0\mathrm{j}=1\), which makes sense since \(e^0 = 1\). More surprising are the points \(b=\pm\pi\), which both map to \(z=-1\). Even more surprising than that, larger values of \(b > \pi\) or smaller values \(b < -\pi\) also (eventually) wrap around the circle.

This phenomenon is summarized succinctly by Euler’s formula:

Euler’s formula

Let \(\theta \in \mathbb{R}\) denote any angle (in radians). Then the complex exponential \(e^{\mathrm{j}\theta}\) is equal to a complex number with real and imaginary parts given as follows:

(4.1)#\[e^{\mathrm{j}\theta} = \red{\cos(\theta)} + \mathrm{j}\cdot\purple{\sin(\theta)}.\]

In plain language, this formula says that if you take the exponential of a purely imaginary number, the result will be a complex number at unit distance from the origin, and with an angle matching the number.

This is probably the most important formula in all of signal processing.

4.3.2. Polar and rectangular form#

Euler’s formula says what happens when you take the exponential of an imaginary number. This might seem like an odd thing to do, but let’s take a step back to think about what this tells about exponentials of complex numbers \(z = a + \mathrm{j}b\).

Remember that \(e^z = e^{a + \mathrm{j}b} = e^a \cdot e^{\mathrm{j}b}\). Using Euler’s formula, we can write this as

\[\begin{align*} e^z = e^a \cdot e^{\mathrm{j}b} &= e^a \cdot \left(\red{\cos(b)} + \mathrm{j}\cdot\purple{\sin(b)}\right)\\ &= e^a \cdot \red{\cos(b)} + e^a \cdot\mathrm{j}\cdot\purple{\sin(b)}. \end{align*}\]

What does this buy us?

Imagine picking any complex number \(z = \red{a} + \mathrm{j}\purple{b}\). As we’ve seen earlier, this number can be represented by the point \((a, b)\) in the complex plane. Equivalently, we can represent \(z\) in polar form in terms of its distance from the origin (which we call \(r\)) and the angle \(\theta\) it makes with the real axis.

../../_images/5fbcdf6e32da575cb95a33aa78a48f92982eeb22caef96ae0d77206015728313.svg

Fig. 4.7 A complex number \(z\) can be expressed in polar form by finding its distance \(r\) from the origin, and the angle \(\theta\) it makes with the real number line.#

Putting this picture back into equations, any complex number \(z\) can be equivalently expressed using Euler’s formula as

\[\begin{align*} z &= r \cdot \left(\red{\cos(\theta)} + \mathrm{j}\cdot\purple{\sin(\theta)} \right)\\ &= r \cdot e^{\mathrm{j}\theta} \end{align*}\]

for some radius \(r\geq 0\) and angle \(\theta\). This is what we mean by the polar form of a complex number. The radius \(r\) of the circle is also called the magnitude of the complex number; the angle \(\theta\) is called either the angle or the phase of the number.

If we’re given a complex number in polar form (that is, we’re given \((r,\theta)\)), Euler’s formula tells us how to convert it to rectangular form:

\[\begin{align*} \red{a} &= \red{r\cdot \cos(\theta)}\\ \purple{b} &= \purple{r\cdot \sin(\theta)}. \end{align*}\]

If instead, we’re given a complex number in rectangular form (in terms of \((a, b)\)), we can convert to polar form by using the Pythagorean theorem to find the radius, and some geometry to find the angle:

\[\begin{align*} r^2 &= \red{a^2} + \purple{b^2} \quad &\Rightarrow r &= \sqrt{\red{a^2} + \purple{b^2}}\\ \tan(\theta) & = \frac{\purple{\sin(\theta)}}{\red{\cos(\theta)}} = \frac{\purple{r\cdot \sin(\theta)}}{\red{r \cdot \cos(\theta)}} = \frac{\purple{b}}{\red{a}} \quad &\Rightarrow \theta &= \tan^{-1}\left(\frac{\purple{b}}{\red{a}}\right). \end{align*}\]

where \(\tan^{-1}\) is the inverse or arc-tangent function.

Computing angles in practice

In practice, you shouldn’t compute the angle using the arc tangent directly. This is because dividing \(b/a\) can be numerically unstable when \(a\) is a small number.

# Don't do this.
np.arctan(1.0/0.0)

Instead, most mathematical software libraries give you functions to compute the inverse tanget without having to do the division first.

# Do this instead
np.arctan2(1.0, 0.0)

You can do even better by using the numpy functions to extract magnitude and angle from a complex number:

np.abs(0+1j)
np.angle(0+1j)

4.3.3. Summary#

The key point here is that it’s always possible to represent a complex number in either polar or rectangular form. Rectangular form is convenient when adding or subtracting complex numbers. As we’ll see next, polar form is more convenient for multiplying and dividing.