1.3
Complex Numbers

Imaginary and complex numbers, and their relationships to circles, sine waves, and signal processing. 14 min read

Imaginary Numbers  

In the space of real numbers, the negative numbers do not have a defined square root, because any real number (positive or negative) multiplied by itself will have a positive product.

However, we can arbitrarily define a value called to represent the square root of -1. Note that in electrical engineering we use to avoid clashing with the use of the letter for current, and because it’s more distinct when written down.

This is now an “imaginary” number.

These imaginary numbers do not themselves have physical meaning: I can eat 3 slices of pizza, but I can’t eat slices of pizza. However, we’ll show that complex numbers form a self-consistent area of mathematics, and that their close connection to circles, trigonometry (sines and cosines), and sine waves makes them a powerful and convenient tool for tracking both the magnitude and phase of a sine wave as it propogates through any system.


Complex Numbers and 2D Vectors  

By adding real and imaginary numbers we can have complex numbers. Instead of imaginging the number line as a single line from to , we can imagine the space of complex numbers as being a two-dimensional plane: on the x-axis are the real numbers, and on the y-axis are the imaginary. Any point on the 2D plane is now a complex number:

If you’ve worked with the idea of unit vectors before (such as ), then in some sense we can imagine this as a space defined by two unit vectors, and . Of course, we don’t normally write at all, but we can imagine that it’s there.

We can define basic operations on complex numbers by thinking about them as two-dimensional vectors:


Multiplication and Rotations  

Multiplication is a more complicated case, but we can expand the product and work term by term to get the correct result:

If we consider the special case of multiplying by :

Interestingly, we find when multiplying by , the real and imaginary parts of have swapped, and the real part gets a negative sign too.

This maps geometrically to a rotation by 90 degrees counterclockwise around the origin, assuming we’ve drawn the real numbers on the x-axis and the imaginary numbers on the y-axis. If this is not clear, draw a two-dimensional plane with any point labeled. Then, plot the point .

Multiplication by a second time (i.e. multiplying by twice) maps geometrically to two 90 degree rotations, for a total of rotation 180 degrees around the origin:

Similarly, multiplication by corresponds to 90 degree clockwise rotation. In either direction, this series of rotations is periodic, because .


Complex Conjugate  

The complex conjugate of a complex number is defined as the value with negative imaginary part:

The complex conjugate is important because it multiplies with the original complex number to a purely real number:


Division  

Using the complex conjugate and multiplication definitions, we can define the divison of complex numbers as well:

Notice that for two purely real numbers (i.e. ), this simplifies to ordinary division: . The real numbers are a subset of the complex numbers.


Phase Angle and Magnitude  

As previously mentioned, complex numbers can be though of as part of a two-dimensional vector space, or imagined visually on the x-y (Re-Im) plane. These graphical interpretations give rise to two other geometric properties of a complex number: magnitude and phase angle.

The magnitude of a complex number is defined just like it is in three-dimensional vector spaces, as the overall length of the vector from the origin:

The phase angle is defined graphically from the x-y plane interpretation: it is the counterclockwise angle from the positive x-axis to the vector represented by the complex number. The phase of a positive real number is 0 degrees, and that of a negative real number is 180 degrees or radians. In general, the phase is defined as:

However, the naive definition does obscure the fact that a complex number with negative real part and negative imaginary part lies in the 3rd quadrant: the range of is which is only radians or 180 degrees wide – it covers only half of the phase space. (In computer programming, the “atan2” function accounts for these multi-quadrant issues and gives a full range of output by checking the sign of numerator and denominator before proceeding. You should do the same when working by hand.)

Although we have previously defined a complex number in terms of a Cartesian two-dimensional plane with orthogonal real and imaginary parts, an alternative polar interpretation is easy, useful, and suggested by the phase and magnitude. As long as we’re careful to have specified the phase angle with a full range, we can directly map any complex number with Cartesian representation to a polar representation , where and . To map back and forth between the two representations, note that:


Operations on Polar Complex Numbers  

While some operations like addition and subtraction are easiest in the Cartesian representation , other operations are actually simpler in the polar representation . In particular, multiplication and division become quite simple:

In multiplication, the two radius (or magnitude) values multiply, and the two phase angles add. (As an exercise, you may wish to prove this to yourself on paper.)

This is useful because many electronic systems like amplifiers and filters can be though of as working multiplicatively: a filter may reduce the input magnitude by a factor and apply a phase delay of -90 degrees. By tracking both the magnitude and phase, we can consider this filter as effectively being like multiplying the input signal by a complex number . For a quick hint of what’s to come, here’s a simple RC low-pass filter that behaves like this complex number (at least, it does at the particular frequency we’ve specified):

Exercise Click the circuit, then click “Simulate”, and “Run Time-Domain Simulation.” Observe the output signal is about a tenth as tall as the input, and the sine wave of the output is (very roughly) 90 degrees behind the input.

In division, it’s quite similar:

In division, the magnitudes are divided, and the phase angles are subtracted. (Again, you may wish to prove this as an exercise.)


Euler’s Formula and Polar Complex Numbers  

The polar representation of complex numbers is closely connected to one of the most beautiful expressions in mathematics. First, we start by observing that

The is just a scaling factor, but the other term is actually very interesting: the angle traces out a unit circle on the complex number plane. Again, if the complex number notation is unfamiliar, just observe that if we had two axes with unit vectors then the vector equation

traces out a unit circle on the x-y plane.

It turns out that there is a more compact representation of the complex plane unit circle, and it’s an incredible piece of mathematics called Euler’s Formula:

If you haven’t seen this before, this may seem cryptic, but it is incredibly powerful. The natural base constant raised to any imaginary number produces a complex number with unit magnitude and angle varying with the parameter.

Taking this as a given for the moment, this lets us write the complex number very simply:

Any complex number can be written in this form, where and are real numbers specifying the magnitude and phase of the complex number.

Importantly, from this definition, the rules about multiplication and division of complex numbers are very easy to work with. Since for any exponents and :

It’s reasonable to ask what it even means to raise a number to an imaginary number. Exponentiation of any base is clear enough when is a positive integer: multiplying by itself times. When is not an integer, it’s stranger: implies a square root, for example. But any exponentiation can be transformed to one in base , the base of the natural logarithm:

So far we’ve only shown that any real exponentiation can be made into a natural exponent and a natural logarithm. But for a computer to evaluate any (non-integer) exponent or any natural logarithm, we have to find a way to express these operations in terms of basic arithmetic: addition, multiplication, division, etc. Fortunately, we have something called the Taylor series expansion of :

This is an infinitely long series, but each term is simply a polynomial term in : easy enough to calculate by multiplying by itself an integer number of times directly. The terms eventually get smaller and smaller toward 0 because the factorial function in the denominator grows faster than the polynomial in the numerator, so the infinite series converges to a finite value for all inputs.

Other functions like and also have Taylor series expansions as polynomials:

When comparing the Taylor series for and with that for above, you can see there’s something interesting going on: all the terms with even powers of (including ) are contained within the series for , and all the odd power terms are contained within the series for – except for a pattern of alternating minus signs!

Now let’s take a look at the unit imaginary number and see what happens when it’s raised to the n-th power:

The idea that multiplication by is like rotating 90 degrees counterclockwise in the real-imaginary plane is a useful one here. After four rotations, we’re back to where we started.

Now look at just the first and third rows listed here:

If you look at the Taylor series expansion for , it has in each term, which maps precisely to this sequence for all even values of . Simply by comparing values, for even values of , we can write:

Of course we could also have observed that

directly, but it’s more concrete to see the matching of values within each term.

For the odd terms, we find something similar:

If you look at the Taylor series expansion for , it has in each term. This gives us the correct sequence of positive and negative inversions, but are missing the . (This missing factor of is OK – we’ll simply multiply by shortly to bring it back.)

So finally, let’s reassemble everything. Here is the series for :

And here’s the series for (we’ve simply multiplied every term by to fix the “missing” imaginary value from the sequence above):

And the series for will proceed similarly:

And so, when we combine (providing the even terms) and (providing the odd terms), we find precisely:

This is known as Euler’s formula.

Sometimes this is evaluated at a single point and written as:

This is famously known as Euler’s identity, and now hopefully you can understand where it comes from: just a special case of Euler’s formula.


Phasors  

As mentioned earlier, complex numbers can be used to represent the magnitude and phase of a sine wave. These two values – magnitude and phase – are all that’s needed to specify any sine wave.

Recalling our earlier example:

At the particular frequency of this example, the filter can be though of as (approximately) multiplying the magnitude of the input sine wave by 0.1, and (approximately) modifying the phase by -90 degrees. (We’re saying “approximately” because we’ve done some rounding to nice values. We’ll discuss how to analyze and design such filters in later chapters, but for now, just take it as a given that this design does approximately that.)

If we look at this purely in the time domain, for our single frequency , we might consider our input and output :

This is a simple, linear filter: if we double the magnitude of , the magnitude of also doubles. If we change the phase of the input by 20 degrees, we also change the phase of the output by 20 degrees. Yet, perhaps surprisingly, it would be very hard to write a single general algebraic formula that describes the filter transfer function . The amplitude part would factor out easily, but the phase part is trapped inside some sine expressions.

Instead, we can think about our input and output signals as phasors. This means that instead of treating as a function of time, we just treat it as a single complex number which represents a sine wave at our particular frequency. The magnitude and phase of represent that of the sine wave. Similarly, our output is just a single complex number . The advantage of doing so is that we can now represent our entire filter (at this frequency) very compactly:

We’re making two big assumptions here in order to work with these complex numbers called phasors:

First, we’re assuming that putting in a sinusoidal wave means we’ll get something shaped like a sinusoidal wave out. (Later we’ll show that this is always true for Linear Time-Invariant (LTI) Systems, but assume it’s true for now.)

Second, we’re assuming that we’re only working at one single particular frequency (for now) – or equivalently we’re assuming that if we put in only a sinusoidal signal at frequency , we’ll only get a sinusoidal signal at out. (Again, we’ll show this to be true for LTI systems. Additionally, in the future, we’ll look at how to combine different sinusoids at different frequencies – the key insight to Laplace and Fourier Transforms and the Frequency Domain.)

As long as we’re comfortable with these assumptions, we can now go back and forth between our two representations.


A Phasor Example  

Suppose our input signal is : we can represent this with a phasor of magnitude 5 and phase 0, or

We can apply our filter to find the phasor for our output:

How do we go back and forth from the phasor representation to the time-domain representation?

First, note that we can write the frequency as an angular frequency, often denoted by the greek character , so for this example, . We do this just because it gets tiring to write everywhere!

Now, to go from a phasor to the function , we just multiply by and then take the real part of the result:

This complex value is our base complex-valued sinusoid. Note that it keeps track of both a cosine and a sine at the same frequency within its real and imaginary parts, respectively. When we take the real part we find:

This was a particularly simple example because X was purely real. But now let’s find from our complex phasor Y:

In this case, was purely imaginary, and we find that purely has a term. In general, however, if has nonzero real and imaginary parts, then the time-domain will have both cosine and sine terms.

Note that it’s always possible to write a linear combination of and as only for some phase angle . In simple 90-degree cases, we may have a simple expression such as:

In more advanced cases for intermediate values, remember that:

So for our example above, we could write:

Here, we’ve shown that while it is very hard to write a general algebraic function for this simple filter that transforms our input sine wave directly into the output sine wave , it’s actually quite simple if we think of both input and output as being complex-valued phasors representing the magnitude and phase of the corresponding sinusoid. Applying the filter then becomes simply multiplication by a complex number, which is easy. And we can get back from our complex phasor to our time-domain signal by multiplying by our complex sine wave and then finally taking the real part.

Summarized:  

  1. Write the input sinusoid as a complex number with magnitude and phase corresponding to the input sine wave.
  2. Multiply by the complex number representing the effect of the filter at this particular frequency. Magnitudes will multiply and phases will add to get a new complex number .
  3. Convert the complex phasor back into a time-domain signal by multiplying and then taking the real part:

What’s Next  

In the next section, Linear & Nonlinear, we’ll switch gears and talk about linearity and why it’s so useful to understanding and designing systems of all kinds.