Defining complex numbers
4.1. Defining complex numbers#
Recall that there is no real number \(x\) such that \(x^2 = -1\). However, if we imagine a “number” \(\mathrm{j}\) (which need not be real) such that \(\mathrm{j}^2 = -1\), it turns out that this leads to a whole new type of numbers, which we call complex.
As a general convention, to avoid confusion, it is common to denote real numbers by \(x\) and \(y\) and complex numbers by \(z\) and \(w\).
Formally, a complex number \(z\) consists of a \(\red{\text{real part}}\) and an \(\purple{\text{imaginary part}}\). We can equivalently think of the imaginary part as being a real number multiplied by \(\mathrm{j}\), so that the complex number can be expressed succinctly as
You can think of \(\red{a}\) as “how much real is in \(z\)”, and \(\purple{b}\) as “how much imaginary is in \(z\)”. If \(\red{a=0}\), then \(z=\mathrm{j}\purple{b}\) is called purely imaginary. Likewise, if \(\purple{b=0}\), then \(z=\red{a}\) is called purely real.
In Python, we can represent complex numbers using a similar notation:
z = 1 + 2j
print(z)
(1+2j)
We can then extract their real and imaginary parts by accessing z.real
and z.imag
:
print('Real part: {}'.format(z.real))
print('Imaginary part: {}'.format(z.imag))
Real part: 1.0
Imaginary part: 2.0
In mathematical notation, you may also see \(\mathsf{Re}z\) and \(\mathsf{Im}z\) used to denote the real and imaginary parts of a complex number \(z\).
This representation of \(z\) is known as the rectangular form, as you can interpret the real and imaginary parts as length and width of a rectangle. Interpreting complex numbers in this way leads to a natural way to reason about them as points in a two-dimensional plane, where the horizontal position measures the real part, and the vertical axis measures the imaginary part. The figure below demonstrates this idea, and shows the position of a few selected complex numbers \(z\).
It is tempting to think of a complex number as having two independent pieces (\(a\) and \(b\)), and it is sometimes helpful to do so. However, one must always keep in mind that this representation is primarily for convenience, and a complex number should always be treated holistically. A complex number has more structure than an arbitary pair of points \((x, y)\) because of the special interpretation of the imaginary unit \(\mathrm{j}\). We’ll see why exactly this is the case soon.