# Simple Complex Number Algebra

I decided to start reviewing some of my controls courses from university to brush up on the fundamentals. While reviewing, I had an "Oh shit" moment when I realized that I've forgotten some really basic math. Namely, working with complex numbers. I decided to write this article so that I can easily find a reference if I ever need it (hopefully it helps you too). (BIG thanks to Dr. Tabrizi for putting together notes that are very comprehensible.)

## General Form of a Complex Number

According to Wikipedia, complex numbers are

[...] regarded in the mathematical sciences as just as "real" as the real numbers, and are fundamental in many aspects of the scientific description of the natural world.

Complex numbers can be written in two forms: rectangular and polar. They live in the 2-dimensional complex plane with the horizontal axis is called the "real" axis while the vertical axis is called the "imaginary" axis. The figure below shows this nicely. A complex number z, as a point (red) and its position vector (blue). Image courtesy of LasinIkamusumeFan under the Creative Commons 4.0 License .

Note that in electrical engineering $$j$$ denotes the imaginary number/axis so as to avoid confusion with the time-varying current $$i$$. This is the notation that I'll be using throughout this article. If this confuses you, then just replace every instance of $$j$$ with $$i$$.

### Rectangular Form

The rectangular form of a complex number is as follows

$$z = a + jb.$$

The letters $$a$$ and $$b$$ are referred to as the real and imaginary components of the complex number $$z$$, respectively. In the figure above, $$a$$ is the horizontal axis while $$b$$ is the vertical axis.

You may sometimes see $$Re(z)$$ and $$Im(z)$$ to mean the real and imaginary components of the complex number $$z$$, respectively.

### Polar Form

The rectangular form of a complex number is as follows

$$z = \|r\| e^{j\phi}.$$

and is shown in the figure below. A complex number z, as a point (red) and its position vector (blue). Image courtesy of Oleg Alexandrov under the Creative Commons 3.0 License .

$$\|r\|$$ is the magnitude and $$\phi$$ is the phase angle of the complex number $$z$$, respectively. To help explain this, you can think of a complex number as a vector in the complex plane with the magnitude being the length of the vector and the phase angle the direction.

## Converting Between Forms

It's often useful (or necessary) to convert from one form to another to either get information (such as magnitude) or to aid in calculations (adding complex numbers is easier when both numbers are in rectangular form).

### Converting From Polar to Rectangular Form

To convert from polar to rectangular form, we will use Euler's formula and multiply the result by the magnitude $$\|r\|$$.

\begin{align} z &= \|r\|\left(\cos \phi + j \sin \phi \right) \nonumber \\ &= a + jb \label{eq:polar_to_rect} \end{align}

Interesting side note: Euler made discoveries in so many different fields that it started getting to the point that there were too many discoveries/theorems being named after him, so

[in] an effort to avoid naming everything after Euler, some discoveries and theorems are attributed to the first person to have proved them after Euler. 1

#### Example

It usually helps to make everything clear by having examples. So, let's see how the conversion from polar to rectangular form actually works.

Let $$z = 2 \sqrt{2} \, e^{j \, \frac{\pi}{4}}$$.

The first thing that we have to do is identify the magnitude and phase angle. Here, the magnitude is $$\|r\| = 2 \sqrt{2}$$ and the phase angle is $$\phi = \frac{\pi}{4}$$. Now, it's just a matter of plugging everything in to Equation $$\ref{eq:polar_to_rect}$$.

\begin{align*} a + jb &= \|r\| \left(\cos \phi + j \sin \phi \right) \\ &= 2 \sqrt{2} \left(\cos \frac{\pi}{4} + j \sin \frac{\pi}{4} \right) \\ &= 2 \sqrt{2} \left(\frac{\sqrt{2}}{2} + j \frac{\sqrt{2}}{2} \right) \\ &= \boxed{2 + j2} \end{align*}

### Converting from Rectangular to Polar Form

To convert from rectangular to polar form, we will need to find the magnitude and the phase angle of the complex number. To find the magnitude of $$z$$, we will use the formula for the [Euclidean norm] (also known as the modulus, or norm)

$$\begin{equation} \|r\| = \sqrt{a^2 + b^2}. \label{eq:euclidean_norm} \end{equation}$$

Finding the phase angle can be a little bit tricky (which is what prompted me to write this article). Although you may be tempted to immediately use $$\phi = \tan^{-1}{\frac{b}{a}}$$, you will quickly run into trouble. This equation only works for the first quadrant. Therefore, you must determine which quadrant the complex number is in, which is the tricky part. Luckily, the table below shows you exactly how to find this out.

Conditions Quadrant Range of $$\phi$$
$$a \gt 0\,$$ and $$b \gt 0$$ 1st quadrant $$\lt \phi \lt$$ 90°
$$a \gt 0\,$$ and $$b \gt 0$$ 2nd quadrant 90° $$\lt \phi \lt$$ 180°
$$a \gt 0\,$$ and $$b \gt 0$$ 3rd quadrant 180° $$\lt \phi \lt$$ 270°
a $$\gt 0\,$$ and b $$\gt 0$$ 4th quadrant 270° $$\lt \phi \lt$$ 360°

Once you know what quadrant the complex number is in, then finding the phase angle is pretty straightforward. Below I've created another table that lists the formula that you need to use to find the (numerical) phase angle dependent on the quadrant.

1st quadrant $$\phi = \tan^{-1}{\frac{b}{a}}$$
2nd quadrant $$\phi = \pi - \tan^{-1}{\frac{\left|b\right|}{a}}$$
3rd quadrant $$\phi = \pi + \tan^{-1}{\left|\frac{b}{a}\right|}$$
4th quadrant $$\phi = -\tan^{-1}{\frac{\left|b\right|}{a}}$$

#### Example

Let's convert $$z = \pm 3 \pm j3$$ to polar form.

Let's first do $$z = 3 + j3$$. It's very simple to find the magnitude so let's do that first.

\begin{align*} \|r\| &= \sqrt{a^2 + b^2} \\ &= \sqrt{3^2 + 3^2} \\ &= \sqrt{18} \\ &= \boxed{3 \sqrt{2}} \end{align*}

We can tell that this number is in the first quadrant because both of the real and imaginary components are positive. Therefore, according to the above table, we will use $$\phi = \tan^{-1}{\frac{b}{a}}$$ to find the phase angle.

\begin{align*} \phi &= \tan^{-1}{\frac{b}{a}} \\ &= \tan^{-1}{\frac{3}{3}} \\ &= \boxed{\frac{\pi}{4}} \end{align*}

Combining the magnitude and phase leaves us with the polar form

$$\boxed{z = 3 \sqrt{2} \, e \, ^{j \frac{\pi}{4}}}$$

Now, let's do $$z = -3 + j3$$. Again, we're going to find the magnitude first.

\begin{align*} \|r\| &= \sqrt{\left(-3 \right)^2 + 3^2} \\ &= \sqrt{18} \\ &= \boxed{3 \sqrt{2}} \end{align*}

We can tell that this number is in the second quadrant because the real component is negative while the imaginary component is positive. Therefore, according to the above table, we will use $$\phi = \pi - \tan^{-1}{\frac{b}{\left|a\right|}}$$ to find the phase angle.

\begin{align*} \phi &= \pi - \tan^{-1}{\frac{b}{\left|a\right|}} \\ &= \pi - \tan^{-1}{\frac{3}{\left|-3\right|}} \\ &= \pi - \frac{\pi}{4} \\ &= \boxed{\frac{3\pi}{4}} \end{align*}

Combining the magnitude and phase leaves us with the polar form

$$\boxed{z = 3 \sqrt{2} \, e \, ^{j \frac{3\pi}{4}}}$$

Now, let's do $$z = -3 - j3$$. Again, we're going to find the magnitude first.

\begin{align*} \|r\| &= \sqrt{\left(-3 \right)^2 + \left(-3 \right)^2} \\ &= \sqrt{18} \\ &= \boxed{3 \sqrt{2}} \end{align*}

We can tell that this number is in the third quadrant because both of the real and imaginary components are negative. Therefore, according to the above table, we will use $$\phi = \pi + \tan^{-1}{\left|\frac{b}{a}\right|}$$ to find the phase angle.

\begin{align*} \phi &= \pi + \tan^{-1}{\left|\frac{b}{a}\right|} \\ &= \pi + \tan^{-1}{\left|\frac{-3}{-3}\right|} \\ &= \pi + \frac{\pi}{4} \\ &= \boxed{\frac{5\pi}{4}} \end{align*}

Combining the magnitude and phase leaves us with the polar form

$$\boxed{z = 3 \sqrt{2} \, e \, ^{j \frac{5\pi}{4}}}$$

Now, let's do $$z = 3 - j3$$. Again, we're going to find the magnitude first.

\begin{align*} \|r\| &= \sqrt{3^2 + \left(-3 \right)^2} \\ &= \sqrt{18} \\ &= \boxed{3 \sqrt{2}} \end{align*}

We can tell that this number is in the fourth quadrant because real component is positive and the imaginary component is negative. Therefore, according to the above table, we will use $$\phi = -\tan^{-1}{\frac{\left|b\right|}{a}}$$ to find the phase angle.

\begin{align*} \phi &= -\tan^{-1}{\frac{\left|b\right|}{a}} \\ &= -\tan^{-1}{\frac{\left|-3\right|}{-3}} \\ &= \boxed{-\frac{\pi}{4}} \end{align*}

Combining the magnitude and phase leaves us with the polar form

$$\boxed{z = 3 \sqrt{2} \, e \, ^{-j \frac{\pi}{4}}}$$

## Arithmetic Operations

Now that we know how to convert from one form to another, we can perform arithmetic operations with complex numbers.

It's easiest to add and subtract complex numbers when they're in rectangular form. So, the first thing to do is to convert all of the complex numbers to rectangular form if necessary. Then, you simply add the components together.

For example, suppose that you have two complex numbers $$z_1 = a_1 + jb_1$$ and $$z_2 = a_2 + jb_2$$. To get the new number $$z_3 = z_1 + z_2$$, you would do the following

\begin{align*} z_3 &= z_1 + z_2 \\ &= \left(a_1 + jb_1 \right) + \left(a_2 + jb_2 \right) \\ &= \left(a_1 + a_2 \right) + j\left(b_1 + b_2 \right) \\ &= a_3 + jb_3. \end{align*}

### Subtraction

Subtraction works similarly to addition (just like with real numbers). First, we should make sure that all complex numbers are in rectangular form. Then, we can simply subtract the components of each complex number.

For example, suppose that you have two complex numbers $$z_1 = a_1 + jb_1$$ and $$z_2 = a_2 + jb_2$$. To get the new number $$z_3 = z_1 + z_2$$ you would do the following

\begin{align*} z_3 &= z_1 - z_2 \\ &= \left(a_1 + jb_1 \right) - \left(a_2 + jb_2 \right) \\ &= \left(a_1 - a_2 \right) + j\left(b_1 - b_2 \right) \\ &= a_3 + jb_3. \end{align*}

### Multiplication

In contrast to addition and subtraction, multiplication of complex numbers is more easily performed when all complex numbers are in polar form.

The first thing to do when multiplying complex numbers is to make sure to convert all of them into polar form. Next, we multiply the magnitudes and then add the phase angles.

For example, suppose that we have two complex numbers $$z_1 = r_1 \, e^{j \phi_1}$$ and $$z_2 = r_2 \, e^{j \phi_2}$$ and we want to multiply them. To multiply them, you would do the following

\begin{align} z_3 &= z_1 \cdot z_2 \\ &= \left(r_1 \, e^{j \phi_1} \right) \cdot \left(r_2 \, e^{j \phi_2} \right) \\ &= \left(r_1 \cdot r_2 \right) \, e^{\left(\phi_1 + \phi_2 \right)}. \end{align}

### Division

Like multiplication, division of complex numbers is easiest when all of the complex numbers are in polar form. So, first convert all of the complex numbers to polar form, then divide the magnitudes and subtract the phase angles.

For example, suppose that we have two complex numbers $$z_1 = r_1 \, e^{j \phi_1}$$ and $$z_2 = r_2 \, e^{j \phi_2}$$ and we want to multiply them. To multiply them, you would do the following

\begin{align} z_3 &= \frac{z_1}{z_2} \\ &= \frac{r_1 \, e^{j \phi_1}}{r_2 \, e^{j \phi_2}} \\ &= \frac{r_1}{r_2} \, e^{\left(\phi_1 - \phi_2 \right)}. \end{align}

## Complex Conjugate

Every complex number has a complex conjugate and that conjugate is found by switching the signs of the imaginary component. For example, if we have a complex number $$z = a + jb$$ then its complex conjugate is $$z^* = a - jb$$. Notice how only the sign of the imaginary component became negative and the real component's sign remained the same. Because we're just switching signs of the imaginary component, you can think of the complex conjugate as a reflection about the real axis. Also note the $$^*$$ next to the variable $$z$$. This is one of the notations to denote a complex conjugate.

Complex conjugates are very important in math, physics, and engineering and you should definitely read about the importance of complex conjugates.

## Conclusion

In this article, we learned about the different forms of a complex number and how to convert between them. We also learned how to add, subtract, multiply, and divide complex numbers. Finally, we learned how to find the complex conjugate of a complex number as well. If you have any comments or questions, please comment below.