SigmaField
Mathematical Foundations for Quant Finance
0 of 256 lessons
      1. 1.7.1 Angles, the unit circle, sine and cosineConcept · 30 min
      2. 1.7.2 Complex numbersConcept · 25 min
      3. 1.7.3 Euler's formulaConcept · 25 min
      4. 1.7.4 Practice set: trigonometry and complex numbersPractice set · 20 min

Level 1, Precalculus 1.7 Trigonometry and complex numbers Lesson 2 of 4

ConceptLesson 1.7.2 in Level 1, Precalculus. About 25 minutes.

Complex numbers

A square root of −1

No real number squares to a negative number: x2≥0x^2 \geq 0 for every real xx. So x2=−1x^2 = -1 has no real solution, and −1\sqrt{-1} has no real value (lesson 1.1.1).

We add one new number, ii, defined by i2=−1i^2 = -1. It is called the imaginary unit. With it, every negative number has square roots: −16=4i\sqrt{-16} = 4i, since (4i)2=16i2=−16(4i)^2 = 16i^2 = -16.

Rule: Square roots of negative numbers

i2=−1−a=iafor a>0\begin{gathered} i^2 = -1 \\ \sqrt{-a} = i\sqrt{a} \quad \text{for } a > 0 \end{gathered}

(−i)2=−1(-i)^2 = -1 as well, so −1-1 has two square roots, ii and −i-i. −a\sqrt{-a} means the one with a plus sign, just as 9\sqrt{9} means 3, not −3-3.

A complex number is z=a+biz = a + bi, where aa and bb are real numbers. aa is the real part and bb the imaginary part. For z=3−2iz = 3 - 2i the real part is 3 and the imaginary part is −2-2, a real number, not −2i-2i.

Two kinds of number sit inside this. With b=0b = 0, a+0ia + 0i is just the real number aa, so every real number is complex. With a=0a = 0, the number bibi is called purely imaginary.

The complex plane

A complex number has two parts, so it needs two coordinates. Draw a+bia + bi as the point (a,b)(a, b): real part across, imaginary part up.

This is the complex plane. Its horizontal axis holds the real numbers and its vertical axis the purely imaginary ones.

Adding and subtracting work part by part, as for coordinates: (2+3i)+(3−2i)=5+i(2 + 3i) + (3 - 2i) = 5 + i, and (3+4i)−(1−6i)=2+10i(3 + 4i) - (1 - 6i) = 2 + 10i. In the plane, adding 3−2i3 - 2i moves a point 3 across and 2 down.

Rule: Adding and subtracting

(a+bi)+(c+di)=(a+c)+(b+d) i\begin{gathered} (a + bi) + (c + di) \\ = (a + c) + (b + d)\,i \end{gathered}

Add the real parts, and add the imaginary parts. Subtracting takes each part away in the same way.

The conjugate of z=a+biz = a + bi is zˉ=a−bi\bar{z} = a - bi, read "z bar". It has the same real part and the opposite imaginary part. In the plane it is the mirror image of zz in the real axis.

The modulus ∣z∣=a2+b2|z| = \sqrt{a^2 + b^2} is the distance from 0 to the point (a,b)(a, b), by Pythagoras' theorem (lesson 1.7.1). For a real number it is the absolute value of lesson 0.3.3: ∣−5∣=5|-5| = 5. It is never negative, and only 0 has modulus 0.

Rule: Conjugate and modulus

zˉ=a−bi∣z∣=a2+b2\begin{gathered} \bar{z} = a - bi \\ |z| = \sqrt{a^2 + b^2} \end{gathered}

The conjugate mirrors zz in the real axis. The modulus is its distance from 0.

The modulus of 4+3i4 + 3i is 16+9=5\sqrt{16 + 9} = 5, and its conjugate 4−3i4 - 3i is its mirror image. Adding two complex numbers moves one point by the steps of the other.

For z=4+3iz = 4 + 3i: zˉ=4−3i\bar{z} = 4 - 3i and ∣z∣=5|z| = 5. Adding a number to its conjugate cancels the imaginary parts: z+zˉ=8z + \bar{z} = 8, twice the real part.

Try it

Python writes ii as j, straight after a number: 4 + 3j, or 1j for ii itself.

z.real and z.imag give the two parts, as decimals. z.conjugate() gives the conjugate and abs(z) the modulus.

⌘/Ctrl + Enter runs the cell

Multiplying

Multiply out the brackets as for (x+2)(x+3)(x + 2)(x + 3), then replace i2i^2 by −1-1.

Example 1. Multiply (2+3i)(1−i)(2 + 3i)(1 - i).

(2+3i)(1−i)=2−2i+3i−3i2=2+i+3=5+i\begin{aligned} (2 + 3i)(1 - i) &= 2 - 2i + 3i - 3i^2 \\ &= 2 + i + 3 \\ &= 5 + i \end{aligned}

The −3i2-3i^2 became +3+3, which joined the real part. Doing the same with letters gives a rule for every product.

Rule: Multiplying

(a+bi)(c+di)=(ac−bd)+(ad+bc) i\begin{gathered} (a + bi)(c + di) \\ = (ac - bd) + (ad + bc)\,i \end{gathered}

The −bd-bd comes from bd i2bd\,i^2. A real number times a+bia + bi just scales both parts: 2(3+4i)=6+8i2(3 + 4i) = 6 + 8i.

Powers of ii, and the quarter turn

Multiplying by ii again and again gives a table that repeats.

poweri1i^1i2i^2i3i^3i4i^4i5i^5i6i^6i7i^7i8i^8
valueii−1-1−i-i1ii−1-1−i-i1

Algebra shows why: i3=i2⋅i=−ii^3 = i^2 \cdot i = -i, and i4=(i2)2=(−1)2=1i^4 = (i^2)^2 = (-1)^2 = 1. After every fourth power you are back at 1, so only the remainder after dividing the power by 4 matters. For example i10=i8⋅i2=−1i^{10} = i^8 \cdot i^2 = -1.

Multiplying any number by ii gives i(a+bi)=ai+bi2=−b+aii(a + bi) = ai + bi^2 = -b + ai. The point (a,b)(a, b) moves to (−b,a)(-b, a): a quarter turn anticlockwise about 0. So i(3+2i)=−2+3ii(3 + 2i) = -2 + 3i, and three more quarter turns lead back to 3+2i3 + 2i.

Each multiplication by ii turns a point a quarter turn about 0 and keeps its distance from 0. Four turns bring it back, which is why i4=1i^4 = 1.

Try it

The first line checks Example 1.

The loop multiplies by 1j eight times and prints the table. -0 is a zero that Python reached from the negative side; read it as 0. The last loop shows the four quarter turns of 3+2i3 + 2i.

⌘/Ctrl + Enter runs the cell

Dividing

Division rests on one product. Multiplying out, (a+bi)(a−bi)=a2−abi+abi−b2i2=a2+b2(a + bi)(a - bi) = a^2 - abi + abi - b^2i^2 = a^2 + b^2. So a number times its conjugate is real and never negative.

Rule: A number times its conjugate

z zˉ=a2+b2=∣z∣2z\,\bar{z} = a^2 + b^2 = |z|^2

The imaginary parts cancel. For 4+3i4 + 3i, (4+3i)(4−3i)=16+9=25(4 + 3i)(4 - 3i) = 16 + 9 = 25, which is 525^2.

To divide by c+dic + di, multiply the top and the bottom by its conjugate c−dic - di. The bottom becomes the real number c2+d2c^2 + d^2, and dividing by a real number divides both parts.

Rule: Dividing

a+bic+di=(a+bi)(c−di)c2+d2\frac{a + bi}{c + di} = \frac{(a + bi)(c - di)}{c^2 + d^2}

Use the conjugate of the bottom, not of the top. The bottom c2+d2c^2 + d^2 is 0 only when c+di=0c + di = 0, and dividing by 0 is still impossible.

Example 2. Divide 3+4i3 + 4i by 1+2i1 + 2i. The top becomes (3+4i)(1−2i)=3−6i+4i−8i2=11−2i(3 + 4i)(1 - 2i) = 3 - 6i + 4i - 8i^2 = 11 - 2i, and the bottom 12+22=51^2 + 2^2 = 5.

3+4i1+2i=11−2i5=2.2−0.4i\frac{3 + 4i}{1 + 2i} = \frac{11 - 2i}{5} = 2.2 - 0.4i

Multiplying back checks it: (2.2−0.4i)(1+2i)=2.2+4.4i−0.4i−0.8i2=3+4i(2.2 - 0.4i)(1 + 2i) = 2.2 + 4.4i - 0.4i - 0.8i^2 = 3 + 4i.

A special case: 1i=−i\frac{1}{i} = -i, because i⋅(−i)=−i2=1i \cdot (-i) = -i^2 = 1. Dividing by ii is a quarter turn clockwise.

Try it

The first line multiplies 4+3i4 + 3i by its conjugate. It prints (25+0j): a complex number whose imaginary part is 0.

Python divides complex numbers with /. The cell then checks Example 2, multiplies back, and works out 1i\frac{1}{i}.

⌘/Ctrl + Enter runs the cell

Complex roots of a quadratic

Lesson 1.2.2 stopped at a negative discriminant: no real roots, because the formula needs the square root of a negative number. With ii the quadratic formula works anyway.

Example 3. Solve x2−6x+13=0x^2 - 6x + 13 = 0. The discriminant is b2−4ac=36−52=−16b^2 - 4ac = 36 - 52 = -16, and −16=4i\sqrt{-16} = 4i. So

x=6±4i2=3±2ix = \frac{6 \pm 4i}{2} = 3 \pm 2i

Putting 3+2i3 + 2i back in checks it. (3+2i)2=9+12i+4i2=5+12i(3 + 2i)^2 = 9 + 12i + 4i^2 = 5 + 12i, and −6(3+2i)=−18−12i-6(3 + 2i) = -18 - 12i. Then 5+12i−18−12i+13=05 + 12i - 18 - 12i + 13 = 0.

Rule: Negative discriminant

b2−4ac<0:x=−b2a±4ac−b22a i\begin{gathered} b^2 - 4ac < 0: \\ x = -\frac{b}{2a} \pm \frac{\sqrt{4ac - b^2}}{2a}\, i \end{gathered}

The two roots are conjugates of each other. Their real part, −b2a-\frac{b}{2a}, is the axis of symmetry from lesson 1.2.2.

For a quadratic with real aa, bb and cc, complex roots always come as such a conjugate pair. That is what np.roots showed in lesson 1.3.1: x3−8x^3 - 8 has the real root 2 and the pair −1±1.732051i-1 \pm 1.732051i.

Try it

math.sqrt(-16) stops with an error, because math works only with real numbers. Its complex twin, cmath, returns 4j.

The cell then puts 3+2i3 + 2i back into the quadratic, which gives 0, and lets np.roots find both roots.

⌘/Ctrl + Enter runs the cell

Lesson 1.7.3 describes each complex number by its distance and its angle instead. That makes multiplying, and the quarter turn above, much simpler to see.

Common mistakes

  1. The imaginary part is a real number. For 3−2i3 - 2i it is −2-2, not −2i-2i.
  2. i2i^2 is −1-1, so −3i2-3i^2 is +3+3. Replace every i2i^2 after multiplying out: (2+3i)(1−i)(2 + 3i)(1 - i) is 5+i5 + i, not −1+i-1 + i.
  3. Python's j goes straight after a number: 1j, not j. On its own, j is a variable name.
  4. The modulus squares both parts. ∣4+3i∣=16+9=5|4 + 3i| = \sqrt{16 + 9} = 5, not 4+3=74 + 3 = 7. And ∣−4−3i∣|-4 - 3i| is also 5: the squares remove the signs.
  5. To divide, use the conjugate of the bottom. Multiplying by the conjugate of the top leaves a complex number underneath.
  6. ab=ab\sqrt{a}\sqrt{b} = \sqrt{ab} fails for negative numbers. −4−9=2i⋅3i=−6\sqrt{-4}\sqrt{-9} = 2i \cdot 3i = -6, but 36=6\sqrt{36} = 6. Take the ii out first.
  7. A negative discriminant does not mean "no roots". It means no real roots, and two complex ones, conjugates of each other.

Complex numbers

0 of 12 correct

  1. 1.
  2. 2.
  3. 3.
  4. 4.
  5. 5.
  6. 6.
  7. 7.
  8. 8.
  9. 9.
  10. 10.
  11. 11.
  12. 12.
How to type answers
  • Powers with ^: x^7, 2^(1/3), a^-2.
  • Multiply with * or by writing side by side: 3x^2, 2(x+1).
  • ln(x) is the natural log, log(x, 2) is log base 2, e is Euler's number, sqrt(x) is a square root.
  • sin(x), cos(x) and tan(x) take radians; write pi for π and sin(x)^2 for sin²x.
  • Your first answer to each question is saved: it counts towards your score and brings the question back for review.
  • Exact answers like ln(20)/ln(3) are best. Decimals need about 4 significant figures.

Summary card

  • i2=−1i^2 = -1, and −a=ia\sqrt{-a} = i\sqrt{a} for a>0a > 0. A complex number is a+bia + bi, with real part aa and imaginary part bb, both real.
  • In the complex plane a+bia + bi is the point (a,b)(a, b). Adding and subtracting work part by part.
  • The conjugate zˉ=a−bi\bar{z} = a - bi mirrors zz in the real axis; the modulus ∣z∣=a2+b2|z| = \sqrt{a^2 + b^2} is its distance from 0.
  • Multiply out and replace i2i^2 by −1-1: (a+bi)(c+di)=(ac−bd)+(ad+bc)i(a + bi)(c + di) = (ac - bd) + (ad + bc)i. Powers of ii repeat every 4, and multiplying by ii is a quarter turn.
  • zzˉ=∣z∣2z\bar{z} = |z|^2. To divide, multiply top and bottom by the conjugate of the bottom.
  • A quadratic with a negative discriminant has two complex roots, −b2a±4ac−b22ai-\frac{b}{2a} \pm \frac{\sqrt{4ac - b^2}}{2a}i, conjugates of each other.
  • In Python: 2 + 3j, abs(z), z.conjugate(), z.real, z.imag, and cmath.sqrt for square roots of negatives.

Free further reading

Optional. This lesson covers what you need; these add more examples and practice. All are free to read.

  • Complex Numbers

    Paul's Online Notes. Notes.

    Arithmetic with complex numbers in one short page.

  • Complex Number Primer

    Paul's Online Notes. Notes.

    Polar form, Euler's formula and powers of complex numbers.