Skip to main content
Complex numbers
This material has been adapted from material by Fergus Cooper and others from the "Essential Mathematics" module at the Doctoral Training Centre, University of Oxford.

This material has been adapted from material by Fergus Cooper and others from the "Essential Mathematics" module at the Doctoral Training Centre, University of Oxford.

Creative Commons License
This course material was developed as part of UNIVERSE-HPC, which is funded through the SPF ExCALIBUR programme under grant number EP/W035731/1

This course material was developed as part of UNIVERSE-HPC, which is funded through the SPF ExCALIBUR programme under grant number EP/W035731/1

Creative Commons License

Complex numbers


YouTube lecture recording from October 2020

A recording of this lecture from October 2020; the material has changed a little since.
Youtube lecture thumbnail

Why complex numbers?

Some equations, like x2+1=0x^2+1=0, have no solutions among the real numbers. Complex numbers give every polynomial a full set of roots.
We will meet them again when we study systems of differential equations. There, complex roots tell us that the system oscillates (e.g. populations of predators and prey that rise and fall in turn).
The link is eiθ=cos⁡θ+isin⁡θe^{i\theta}=\cos\theta+i\sin\theta, which we show at the end of this lecture.

Imaginary numbers

The imaginary number ii:
  • The polynomial x2−1=0x^2-1=0 has two real roots: 11 and −1-1
  • The polynomial x2+1=0x^2+1=0 has no real roots.
Consider solving:
x2=1andx2=−1x^2 = 1\qquad\text{and}\qquad x^2 = -1
We introduce an "imaginary" number ii so that there are two solutions to x2=−1x^2 = -1: ii and −i-i. That is, ii is a number with the property that i2=−1i^2=-1.

Complex numbers

The complex numbers are the set of all expressions of the form a+bia + bi where i2=−1i^2=-1 and aa and bb are real numbers:
C={a+bi∣a, b∈R}\mathbb{C}=\left\{a + bi \mid a,\ b \in\mathbb{R}\right\}
For z=a+bi∈Cz=a+bi\in\mathbb{C} we define the real and imaginary parts of zz to be ℜ(z)=a\Re(z) = a and ℑ(z)=b\Im(z)=b.
The imaginary number ii has no home on the real number line. Instead, we locate it on the complex plane at the point (0,1)(0,1).
  • We can represent any complex number z=a+biz=a+bi as the point (a,b)(a,b) in the complex plane.
  • The coordinates (a,b)(a,b) are usually called the Cartesian coordinates for zz. (Named after the mathematician and philosopher René Descartes).
  • In this plane, the real numbers lie on the horizontal axis. We usually refer to the horizontal axis of C\mathbb{C} as the real axis.
The following plot shows a complex number with a real component of 18 and an imaginary component of 12:
The complex plane

Complex conjugates

  • The complex plane C\mathbb{C} contains all of the roots of every polynomial.
E.g., let's look at a quadratic equation. Recall the quadratic formula:
ax2+bx+c=0  ⟺  x=−b±b2−4ac2aax^2 +bx +c = 0 \iff x= \frac{-b \pm\sqrt{b^2-4ac}}{2a}
Now, let's consider this specific quadratic equation:
x2−8x+25=0x^2-8x+25 = 0
which we can solve using the quadratic formula:
x=8±64−1002=8±−362=8±6i2=4±3ix=\frac{8\pm\sqrt{64-100}}{2}=\frac{8\pm\sqrt{-36}}{2}=\frac{8\pm6i}{2}=4\pm3i
  • Note that these two roots are reflections of one another through the real axis. They are conjugates of one another.
  • In general, let z=a+biz=a + bi. The conjugate of zz is the complex number zˉ=a−bi\bar{z}=a-bi.
We can also use SymPy's solve method to solve polynomials:
import sympy as sp x = sp.symbols('x') sp.solve(x**2 - 8*x + 25)
[4−3i, 4+3i]\left[ 4 - 3 i, \ 4 + 3 i\right]

Modulus (size) of a complex number

The distance to a point on the complex plane from 0 is called its modulus, and we find this by calculating the hypotenuse of the triangle with base ℜ(z)\Re(z) and height ℑ(z)\Im(z):
E.g. The modulus of 4±3i4\pm3i is 32+42=9+16=25=5\sqrt{3^2+4^2}=\sqrt{9+16}=\sqrt{25}=5
  • In general, the modulus of z=a+biz=a+bi is the real number ∣z∣=a2+b2|z|=\sqrt{a^2+b^2}.
  • The modulus is connected to the conjugate by means of the formula z⋅zˉ=∣z∣2z\cdot \bar{z}=|z|^2. Indeed:
z⋅zˉ=(a+bi)(a−bi)=a2−(bi)2=a2−b2⋅i2=a2−b2(−1)=a2+b2=∣z∣2\begin{aligned} z\cdot\bar{z}&=(a+bi)(a-bi)=a^2-(bi)^2=a^2-b^2\cdot i^2\\ &=a^2-b^2(-1)=a^2+b^2=|z|^2 \end{aligned}

Complex numbers in Python

Note that, in Python, because i is often used as an index variable in loops, the language uses j, instead, to represent the imaginary unit:
x = 1 + 2j print(f'x = {x} Re(x) = {x.real} Im(x) = {x.imag} |x| = {abs(x)}')
x = (1+2j) Re(x) = 1.0 Im(x) = 2.0 |x| = 2.23606797749979
In SymPy, the imaginary unit is sp.I:
x = 1 + 2 * sp.I print(f'x = {x} Re(x) = {sp.re(x)} Im(x) = {sp.im(x)} |x| = {sp.Abs(x)}')
x = 1 + 2*I Re(x) = 1 Im(x) = 2 |x| = sqrt(5)

Addition and subtraction

Addition and subtraction of complex numbers work as you would expect:
(a+bi)±(c+di)=(a±c)+(b±d)i(a+bi)\pm(c+di)=(a\pm c) + (b\pm d)i
and
−(a+bi)=−a−bi-(a+bi)=-a-bi
Try adding: (5+6i)+(1−i)(5+6i)+(1-i):
print((5 + 6j) + (1 - 1j))
(6+5j)
Try subtracting: (5+6i)−(1−i)(5+6i)-(1-i):
print((5 + 6j) - (1 - 1j))
(4+7j)

Multiplication

Multiplication is not quite so convenient in Cartesian coordinates:
(a+bi)(c+di)=ac+adi+bci+bidi=ac+adi+bci−bd=(ac−bd)+(ad+bc)i\begin{aligned} (a+bi)(c+di)&=ac + adi + bci + bidi \\ &= ac + adi + bci -bd \\ &= (ac-bd)+(ad+bc)i \end{aligned}
Try multiplying: (5+6i)(1−i)(5+6i)(1-i):
print((5 + 6j) * (1 - 1j))
(11+1j)

Division

Division is even more awkward in Cartesian coordinates: we have to multiply the numerator and the denominator by the complex conjugate of the denominator.
a+bic+di=(a+bi)(c−di)(c+di)(c−di)=(ac+bd)+(bc−ad)ic2+d2=(ac+bdc2+d2)+(bc−adc2+d2)i\begin{aligned} \frac{a+bi}{c+di}&=\frac{(a+bi)(c-di)}{(c+di)(c-di)}\\ &=\frac{(ac+bd)+(bc-ad)i}{c^2+d^2}=\left(\frac{ac+bd}{c^2+d^2}\right)+ \left(\frac{bc-ad}{c^2+d^2}\right)i \end{aligned}
Try dividing:
−4+7i2+3i\frac{-4+7i}{2+3i}
print(sp.simplify((-4 + 7*sp.I) / (2 + 3*sp.I)))
1 + 2*I

Polar coordinates

It is often convenient to represent the complex number z=a+biz = a + bi in terms of its polar coordinates ⟨r,θ⟩\langle r,\theta\rangle.
  • The angle θ\theta is called the argument of zz.
  • We take θ\theta in the range (−π,π](-\pi, \pi], so that each non-zero zz has exactly one argument. A round bracket leaves out its end point and a square bracket includes it: θ=π\theta=\pi is allowed, but θ=−π\theta=-\pi is not.
  • The real number r=∣z∣r=|z| is sometimes denoted mod(z)(z).
Representing a complex number in polar coordinates

Connection between Cartesian and polar

Let z=x+iyz=x+iy. If we are given the polar coordinates of zz and want to express the Cartesian coordinates use
x=rcos⁡θy=rsin⁡θz=rcos⁡θ+risin⁡θ=r(cos⁡θ+isin⁡θ)\begin{gathered} x=r\cos\theta\\ y=r\sin\theta\\ z=r\cos\theta + ri\sin\theta=r(\cos\theta + i\sin\theta) \end{gathered}
If we are given the Cartesian coordinates and want to find the polar coordinates, use:
r=mod(z)=∣z∣=x2+y2r=\text{mod}(z)=|z|=\sqrt{x^2+y^2} θ=arg(z)={π/2,if x=0,y>0−π/2,if x=0,y<0arctan⁡(yx),if x>0arctan⁡(yx)+π,if x<0,y≥0arctan⁡(yx)−π,if x<0,y<0\theta=\text{arg}(z)= \begin{cases}\pi/2, & \text{if } x=0,y>0 \\ -\pi/2, & \text{if } x=0,y<0 \\ \arctan\left(\frac{y}{x}\right), & \text{if } x>0\\ \arctan\left(\frac{y}{x}\right)+\pi, & \text{if } x<0, y\geq 0\\ \arctan\left(\frac{y}{x}\right)-\pi, & \text{if } x<0, y<0 \end{cases}
Note: all of the fuss about the value of θ\theta in the formula above is to make sure that zz gets into the proper quadrant. Beware of the sign of this tangent: it depends on which quadrant you are in.
The positive xx axis is defined as having θ=0\theta=0 and positive θ\theta goes in an anticlockwise sense around the x−yx-y plane.

Some examples

Example 1

Find the Cartesian coordinates for the complex number zz with polar coordinates r=2r=2 and θ=π/6\theta=\pi/6.
ℜ(z)=x=rcos⁡θ=2cos⁡(π/6)=2(32)=3ℑ(z)=y=rsin⁡θ=2sin⁡(π/6)=2(12)=1\begin{aligned} \Re(z)&=x=r\cos\theta=2\cos(\pi/6)=2\left(\frac{\sqrt{3}}{2}\right)=\sqrt{3}\\ \Im(z)&=y=r\sin\theta=2\sin(\pi/6)=2\left(\frac{1}{2}\right)=1 \end{aligned}
Therefore, z=3+iz = \sqrt{3} + i.
import cmath import numpy as np print(cmath.rect(2, np.pi/6))
(1.7320508075688774+0.9999999999999999j)

Example 2

Find the polar coordinates for the complex number z=−3+4iz= -3+4i.
∣z∣=r=(−3)2+42=25=5arg(z)=θ=arctan⁡(yx)+π(as x<0, y≥0)=arctan⁡(−4/3)+π=−0.93+π≈2.21 radians≈127∘\begin{aligned} |z|=r &= \sqrt{(-3)^2+4^2}=\sqrt{25}=5 \\ \text{arg}(z)=\theta&=\arctan\left(\frac{y}{x}\right)+\pi \qquad \text{(as } x<0,\ y\geq 0\text{)}\\ &=\arctan(-4/3)+\pi = -0.93+\pi \approx 2.21 \text{ radians}\approx 127^\circ \end{aligned}
print(cmath.polar(-3 + 4j))
(5.0, 2.214297435588181)

Example 3

Find the polar coordinates for the complex number z=−2iz= -2i.
mod(z)=r=∣z∣=2arg(z)=θ=−π2\begin{aligned} \text{mod}(z)&=r = |z|=2\\ \text{arg}(z)&=\theta=-\frac{\pi}{2} \end{aligned}
print(cmath.polar(-2j))
(2.0, -1.5707963267948966)

Multiplication in polar coordinates

First a reminder of three useful and important identities:
cos⁡2θ+sin⁡2θ=1cos⁡(θ1+θ2)=cos⁡θ1cos⁡θ2−sin⁡θ1sin⁡θ2sin⁡(θ1+θ2)=sin⁡θ1cos⁡θ2+sin⁡θ2cos⁡θ1\begin{aligned} \cos^2\theta + \sin^2\theta &= 1 \\ \cos(\theta_1+\theta_2)&=\cos\theta_1\cos \theta_2 - \sin\theta_1\sin\theta_2 \\ \sin(\theta_1+\theta_2)&=\sin\theta_1\cos \theta_2 + \sin\theta_2\cos\theta_1 \end{aligned}
Now, let z1=r1cos⁡θ1+ir1sin⁡θ1z_1=r_1\cos\theta_1+ir_1\sin\theta_1 and z2=r2cos⁡θ2+ir2sin⁡θ2z_2=r_2\cos\theta_2+ir_2\sin\theta_2.
We first compute the real part of the product z1⋅z2z_1\cdot z_2:
ℜ(z1⋅z2)=r1cos⁡θ1⋅r2cos⁡θ2−r1sin⁡θ1⋅r2sin⁡θ2=r1r2(cos⁡θ1cos⁡θ2−sin⁡θ1sin⁡θ2)=r1r2cos⁡(θ1+θ2)\begin{aligned} \Re(z_1\cdot z_2) &= r_1\cos\theta_1\cdot r_2\cos\theta_2 - r_1\sin\theta_1\cdot r_2\sin\theta_2\\ &=r_1r_2(\cos\theta_1\cos\theta_2 - \sin\theta_1\sin\theta_2)\\ &=r_1r_2\cos(\theta_1 + \theta_2) \end{aligned}
Note that for the real part the moduli have been multiplied and the arguments added.
Now we compute the imaginary part of z1⋅z2z_1\cdot z_2:
ℑ(z1⋅z2)=r1sin⁡θ1⋅r2cos⁡θ2+r2sin⁡θ2⋅r1cos⁡θ1=r1r2(sin⁡θ1cos⁡θ2+sin⁡θ2cos⁡θ1)=r1r2sin⁡(θ1+θ2)\begin{aligned} \Im(z_1\cdot z_2) &= r_1\sin\theta_1\cdot r_2\cos\theta_2 + r_2\sin\theta_2\cdot r_1\cos\theta_1\\ &=r_1r_2(\sin\theta_1\cos\theta_2 + \sin\theta_2\cos\theta_1)\\ &=r_1r_2\sin(\theta_1 + \theta_2) \end{aligned}
For the imaginary part too, the moduli multiply while the arguments add.
This gives a relatively compact and highly geometric result for the product:
z1⋅z2=r1r2(cos⁡(θ1+θ2)+isin⁡(θ1+θ2))z_1\cdot z_2 = r_1r_2(\cos(\theta_1 + \theta_2)+i\sin(\theta_1 + \theta_2))
It is multiplicative in the modulus and additive in the argument:
∣z1z2∣=∣z1∣⋅∣z2∣arg⁡(z1z2)=arg⁡(z1)+arg⁡(z2)(adding or subtracting 2π if needed, to stay in (−π,π])\begin{aligned} |z_1z_2|&= |z_1|\cdot |z_2|\\ \arg(z_1z_2)&=\arg (z_1)+ \arg( z_2) \qquad \text{(adding or subtracting } 2\pi \text{ if needed, to stay in } (-\pi, \pi]\text{)} \end{aligned}
This means that when we multiply by zz, we are rotating through the angle arg⁡(z)\arg(z) and radially stretching by a factor of ∣z∣|z|.

A remarkable connection with eiθe^{i\theta}

First, think of z=cos⁡θ+isin⁡θz=\cos\theta + i\sin\theta as a function of θ\theta and differentiate with respect to θ\theta:
dzdθ=ddθ(cos⁡θ+isin⁡θ)=−sin⁡θ+icos⁡θ(1)\frac{dz}{d\theta}=\frac{d}{d\theta}\left(\cos\theta+i\sin\theta\right)=-\sin\theta+i\cos\theta \qquad \text{(1)}
Next notice that the right-hand side is just the product iziz:
iz=i(cos⁡θ+isin⁡θ)=icos⁡θ+i2sin⁡θ=−sin⁡θ+icos⁡θ(2)iz=i(\cos\theta+i\sin\theta)=i\cos\theta+i^2\sin\theta=-\sin\theta+i\cos\theta \qquad \text{(2)}
Thus, from (1) and (2),
dzdθ=iz\frac{dz}{d\theta}=iz
This is a separable differential equation (we cover differential equations properly in the next lecture):
∫dziz=∫dθ⇒1iln⁡z=θ+c⇒ln⁡z=iθ+ic\int\frac{dz}{iz}=\int d\theta \qquad\Rightarrow\qquad \frac{1}{i}\ln z =\theta +c \qquad\Rightarrow\qquad \ln z =i\theta +ic
In exponential form:
z=eiθ+ic=eiθ eic=AeiθwithA=eicz=e^{i\theta+ic} = e^{i\theta}\,e^{ic} = Ae^{i\theta} \qquad \text{with} \qquad A=e^{ic}
When θ=0\theta=0, z=1z=1, giving A=1A=1, so:
cos⁡θ+isin⁡θ=eiθ(3)\cos\theta + i \sin\theta=e^{i\theta} \qquad \text{(3)}
Putting (3) into the polar form r(cos⁡θ+isin⁡θ)r(\cos\theta + i\sin\theta), any complex number can now be written:
z=x+iy=r(cos⁡θ+isin⁡θ)=r eiθz=x+iy=r(\cos\theta + i\sin\theta)=r\,e^{i\theta}

Several important consequences

  1. Any complex number can be written in the polar form z=reiθz = re^{i\theta} where r=∣z∣r=|z| and θ=arg⁡(z)\theta=\arg(z).
  2. The unit circle in C\mathbb{C} consists exactly of those complex numbers with modulus equal to 1, that is the numbers eiθe^{i\theta}.
  3. Multiplication on the unit circle r=1r=1 can be carried out by adding the angles:
    eiθ1⋅eiθ2=ei(θ1+θ2)e^{i\theta_1}\cdot e^{i\theta_2} = e^{i(\theta_1+\theta_2)}
  4. Exponentiation on the unit circle r=1r=1 can be done by multiplying the angle by the index (for integer nn). Written with cos and sin, this is known as de Moivre's theorem.
    (eiθ)n=eiθn=ei(nθ)\left(e^{i\theta}\right)^n = e^{i\theta n}=e^{i(n\theta)}
  5. This makes powers quick. For example, 1+i=2 eiπ/41+i=\sqrt{2}\,e^{i\pi/4}, so:
    (1+i)8=(2)8(eiπ/4)8=16 e2πi=16(1+i)^8=\left(\sqrt{2}\right)^8\left(e^{i\pi/4}\right)^8=16\,e^{2\pi i}=16
  6. Finally, the famous identity by Leonhard Euler
    eπi+1=0e^{\pi i}+1=0

Introductory problems

For more practice, an AI tool can write new problems like the ones below. Ask it for problems of the same type and difficulty, or for problems set in your own field. For example, you could ask it to "write five physics problems on complex numbers, at the level of these ones". Work them on paper first, then ask the tool to check your answers and to explain any step you are unsure of.

Introductory problems 1

Simplify:
  1. 2−2i+3+i2-2i\quad+\quad 3+i
  2. 4−6i+19+4i4-6i\quad+\quad 19+4i
  3. (1−i)2(1-i)^2
  4. (2+i)2(2+i)^2
  5. (4−3i)/(2+6i)(4-3i)/(2+6i)
  6. (1+2i)/(1−3i)(1+2i)/(1-3i)
  7. (2−i)−2+(2+i)−2(2-i)^{-2} +(2+i)^{-2}
  8. (5−i)−2−(5+i)−2(5-i)^{-2} -(5+i)^{-2}

Introductory problems 2

Find the sum, difference, product and quotient of the complex numbers z1=5+3iz_1=5+3i and z2=−4+2iz_2=-4+2i.

Main problems

Main problems 1

Solve the following equations for zz:
  1. (7+i)z−3i=6(7 + i)z - 3i = 6
  2. (z−i)/(z+i)=2/3(z-i)/(z+i)=2/3
  3. z2+(1+4i)z+(15+27i)=0z^2 + (1+4i)z + (15 + 27 i) = 0
Hint for 3.: the quadratic formula needs the square root of −75−100i-75-100i. To find it, find the real numbers aa and bb with (a+bi)2=−75−100i(a+bi)^2 = -75-100i.

Main problems 2

Represent the complex numbers z1=5−2iz_1= 5-2i and z2=−2+4iz_2=-2 +4i on a sketch/plot of the complex plane (an Argand diagram).
  1. Write down z1z_1 and z2z_2 in polar form (either give rr and θ\theta for each, or write them as exponentials).
  2. What is the product of z1z_1 and z2z_2?

Main problems 3

Find the sum, difference, product and quotient of the complex numbers z1=5e4iz_1=5e^{4i} and z2=3e−2iz_2=3e^{-2i}. Can you represent the results on an Argand diagram?

Main problems 4

What are the (x,y)(x,y) coordinates of the complex number 5e4i5e^{4i}?

Main problems 5

If z=1+iz=1+i, mark on an Argand diagram the four points AA, BB, CC and DD representing zz, z2z^2, z3z^3 and z4z^4 respectively.
Find by calculation or from your diagram, the moduli and arguments of the complex numbers z2−1z^2-1 and z+z4z+z^4.

Main problems 6

Find the complex numbers represented by the vertices of a square if one vertex represents 3+3i3+3i and the centre of the square represents 1+2i1+2i.

Extension problems

Extension problems 1

Use Python's complex numbers to check your answers to Introductory problems 1 and Main problems 1.