Multiplication as pairs¶
Level: 101 → 201 · for anyone who has multiplied out (a + b)(c + d)
One line: A complex number is a point (x, y) of the plane ℝ², and complex multiplication is one specific rule for combining two points into a third — no square root of −1 is needed to define it, and the number whose square is −1 falls out of the rule afterwards.
The rule¶
Write a complex number as a pair of real numbers, z = (x, y), so that the set of complex numbers is the plane ℝ². Addition is what you would guess, component by component. Multiplication is the one thing that has to be defined, and this is the definition:
Read it slowly, because everything else on this page is a consequence of it. The first component multiplies the firsts, multiplies the seconds, and subtracts. The second component multiplies across, both ways, and adds. Four real multiplications, one subtraction, one addition. There is nothing in it but real arithmetic on real numbers.
Section 1 of the program applies the rule to (3, 2) and (1, 4), one component at a time, and gets (−5, 14).
What the program prints¶
Verified output of multiplication_as_pairs.py — regenerated by tools/run_examples.py, never hand-typed.
1. THE RULE, APPLIED TO TWO PAIRS
z1 = (3, 2) z2 = (1, 4)
first = x1*x2 - y1*y2 = 3*1 - 2*4 = 3 - 8 = -5
second = x1*y2 + x2*y1 = 3*4 + 1*2 = 12 + 2 = 14
z1 . z2 = (-5, 14)
Four real multiplications, one subtraction, one addition. That is all.
2. THE PAIR (0, 1) SQUARES TO (-1, 0)
(0, 1) . (0, 1) = (0*0 - 1*1, 0*1 + 0*1) = (-1, 0)
Nothing was taken the square root of. The rule has this property
because of the minus sign in its first component, and for no other
reason. Calling (0, 1) by the name i is a choice of notation.
3. THE REAL NUMBERS SIT INSIDE, AS THE PAIRS (x, 0)
(2, 0) . (3, 0) = (6, 0) and 2 x 3 = 6
(-5, 0) . (7, 0) = (-35, 0) and -5 x 7 = -35
(1/2, 0) . (4/3, 0) = (2/3, 0) and 1/2 x 4/3 = 2/3
On pairs with second part 0, the rule is ordinary multiplication,
so the reals were not replaced by something new; they were kept.
4. WHAT (x, 0) . (0, 1) DOES: SCALES THE SECOND AXIS
(2, 0) . (0, 1) = (0, 2)
(-3, 0) . (0, 1) = (0, -3)
(1/2, 0) . (0, 1) = (0, 1/2)
So every pair splits: (x, y) = (x, 0) + (y, 0) . (0, 1), which in
the usual notation reads x + y i.
(3, 2) = (3, 0) + (2, 0) . (0, 1) = (3, 2) [3 + 2i]
(-1, -5) = (-1, 0) + (-5, 0) . (0, 1) = (-1, -5) [-1 - 5i]
5. THE LAWS OF ARITHMETIC HOLD (checked on a grid of pairs)
36 pairs, coordinates from {-2, -1, 0, 1/2, 1, 3}, exact fractions:
commutative z1.z2 = z2.z1 1,296 cases, 0 failures
associative (z1.z2).z3 = z1.(z2.z3) 46,656 cases, 0 failures
distributive z1.(z2+z3) = z1.z2 + z1.z3 46,656 cases, 0 failures
identity (1, 0).z = z 36 cases, 0 failures
A finite check; the page gives the two-line algebra that covers all.
6. AND EVERY NON-ZERO PAIR HAS A RECIPROCAL
(3, 4) inverse (3/25, -4/25) product (1, 0)
(0, 1) inverse (0, -1) product (1, 0)
(1/2, -1/3) inverse (18/13, 12/13) product (1, 0)
The inverse is (x, -y) / (x^2 + y^2), and x^2 + y^2 is 0 only for (0, 0).
Those are the field axioms: the pairs with this rule are a FIELD,
the complex numbers, built from the reals with no new symbol.
7. THE SAME RULE, AS PYTHON'S complex TYPE
(3, 2) . (1, 4) = (-5, 14) complex: (-5+14j) same
(0, 1) . (0, 1) = (-1, 0) complex: (-1+0j) same
(2, -1) . (2, 1) = (5, 0) complex: (5+0j) same
(1/2, 3/2) . (-2, 1/4) = (-11/8, -23/8) complex: (-1.375-2.875j) same
The built-in type stores exactly a pair (z.real, z.imag) and applies
this rule. The 'j' it prints is the name it gives the pair (0, 1).
8. THE SAME RULE, WHERE NOBODY SAYS 'COMPLEX'
a. Rotating the plane. Multiplying by the unit pair (cos t, sin t)
turns every point through the angle t. Take t = 90 degrees:
after 1 quarter turn : (-1, 3)
after 2 quarter turns: (-3, -1)
after 3 quarter turns: (1, -3)
after 4 quarter turns: (3, 1)
Four quarter turns come back to (3, 1). This is the 2x2 matrix
[[x, -y], [y, x]] acting on a column vector, written on one line.
b. Adding angles. For unit pairs (cos a, sin a) . (cos b, sin b) the
rule reads (cos a cos b - sin a sin b, cos a sin b + cos b sin a):
the two angle-addition formulas at once, cos(a+b) and sin(a+b).
With 3-4-5 and 5-12-13 triangles the check is exact:
(3/5, 4/5) . (5/13, 12/13) = (-33/65, 56/65)
and (-33/65)^2 + (56/65)^2 = 1, still on the unit circle.
c. Sums of two squares. The rule proves the identity
(x1^2 + y1^2)(x2^2 + y2^2) = (x1x2 - y1y2)^2 + (x1y2 + x2y1)^2,
so a product of two sums of two squares is again one:
5 x 13 = 65 = (-4)^2 + (7)^2 = 65
25 x 169 = 4225 = (-33)^2 + (56)^2 = 4225
Multiply by the mirror image (x2, -y2) instead and the signs swap:
(x1^2 + y1^2)(x2^2 + y2^2) = (x1x2 + y1y2)^2 + (x1y2 - x2y1)^2,
a second way to write the same product as two squares:
5 x 13 = 65 = (8)^2 + (1)^2 = 65
25 x 169 = 4225 = (63)^2 + (-16)^2 = 4225
Brahmagupta wrote both forms in the 7th century, a thousand
years before anyone wrote the symbol i.
Where the square root of −1 comes from¶
Apply the rule to the pair (0, 1) times itself (section 2):
No square root was taken. The pair (0, 1) squares to (−1, 0) because the first component of the rule has a minus sign in it, and for no other reason. Giving the pair (0, 1) the name i is a choice of notation, made after the fact; the property i² = −1 was already sitting in the rule.
This is the whole point of defining complex numbers this way, and it is why Hamilton did it. "A number whose square is −1" sounds like something you have to believe in. "A rule on pairs of ordinary numbers, under which one particular pair squares to (−1, 0)" is something you can check by hand, and section 2 does.
The reals are still there¶
Take two pairs whose second component is 0 (section 3). The rule gives
which is ordinary multiplication, carried in the first slot. So the real number line is inside the plane as the horizontal axis, and on that axis the new rule is the old one. Nothing was replaced; the reals were kept and the plane was built around them.
Why x + yi is the same thing¶
Section 4 multiplies a real (a, 0) by the pair (0, 1): the result is (0, a). Multiplying by (0, 1) moves a number from the first axis to the second. So any pair can be taken apart as
and if (x, 0) is written as x, and (0, 1) as i, that line reads x + yi. The familiar notation is not a different definition of complex numbers; it is this one, with two abbreviations.
And now the familiar rule of thumb — multiply out and replace i² by −1 — can be derived rather than assumed:
The last line is the pair rule from the top of the page, written in the other notation. The rule of thumb works because it is the definition in disguise.
It obeys the laws of arithmetic¶
A rule on pairs could easily fail to be commutative, or associative, or to distribute over addition; most rules you might write down do fail. This one does not. Section 5 checks all four laws exactly on a 6 × 6 grid of pairs with fractional coordinates: 1,296 products for commutativity, 46,656 triples for associativity and for distributivity, no failures.
A program only checks finitely many. Commutativity for every pair is two lines: swapping z₁ and z₂ in the rule turns x₁x₂ − y₁y₂ into x₂x₁ − y₂y₁ and x₁y₂ + x₂y₁ into x₂y₁ + x₁y₂, and real multiplication is commutative, so both components are unchanged. Associativity and distributivity are the same kind of check, a few lines longer, and every step is real arithmetic.
Section 6 adds the last law. Every pair except (0, 0) has a reciprocal, (x, −y) divided by x² + y², and the product with it is (1, 0). Together these are the field axioms: the pairs of reals with this rule form a field, the complex numbers, built from ℝ with no new symbol and no leap of faith.
Python's complex is exactly this¶
Section 7 runs the same products through the built-in complex type. It stores exactly a pair, z.real and z.imag, and multiplies by the rule above; the j it prints is its name for the pair (0, 1). The two agree in every case, up to the built-in type using floats where the program uses fractions.
Is the rule only used for complex numbers?¶
The formula is the definition of complex multiplication, but the same rule turns up in places where nobody says "complex", and section 8 shows three.
Rotation. A pair (cos t, sin t) of length 1 acts, under this rule, as a rotation of the plane through the angle t. Multiplying (3, 1) by (0, 1), which is a quarter turn, four times over walks it through (−1, 3), (−3, −1), (1, −3) and back to (3, 1). Written as a matrix, multiplication by (x, y) is the 2 × 2 matrix [[x, −y], [y, x]] acting on a column vector, so the rule is a compact way of writing every rotation-and-scaling of the plane. Computer graphics and signal processing use it in that form constantly.
Angle addition. Put two unit pairs (cos a, sin a) and (cos b, sin b) into the rule and it reads
which is the pair of angle-addition formulas, cos(a + b) and sin(a + b), produced at once. With the 3-4-5 and 5-12-13 triangles the check is exact: (3/5, 4/5) · (5/13, 12/13) = (−33/65, 56/65), still on the unit circle.
Sums of two squares. Squaring both components and adding gives an identity in pure integer arithmetic:
So a product of two sums of two squares is again a sum of two squares, and the rule says which one: 5 × 13 = 65 = 4² + 7². In complex language, x² + y² is the squared length |z|² of the pair, and the identity says |z₁z₂|² = |z₁|²|z₂|², lengths multiply. But the identity itself is a statement about whole numbers, and it needs no complex numbers to state or to use. Brahmagupta wrote it down in the seventh century, a thousand years before anyone wrote the symbol i, and it is a step in the proof of which whole numbers are sums of two squares.
There is a second form with the signs swapped, (x₁x₂ + y₁y₂)² + (x₁y₂ − x₂y₁)², and the rule explains that one too: it is what you get by multiplying z₁ by the mirror image (x₂, −y₂) of z₂, the conjugate, whose squared length is the same. So 65 is also 8² + 1², and section 8 prints both.
The same construction done in four components gives Euler's four-square identity and Hamilton's quaternions, and in eight gives Degen's eight-square identity and the octonions. Each step up loses a law: quaternion multiplication is not commutative, octonion multiplication is not even associative. Complex multiplication, in two components, is the last one that keeps them all.
The rule also has siblings in two components. Change the minus sign in the first component to a plus and you get the split-complex numbers; delete the y₁y₂ term altogether and you get the dual numbers, which automatic differentiation uses. Complex multiplication is the one of the three that makes a field.
Run it yourself¶
From the root of your clone of this repository:
Auf Deutsch: Stichwörter¶
Multiplikation ist eine Regel auf Paaren: (a, b)(c, d) = (ac − bd, ad + bc), und aus ihr folgt (0, 1)² = (−1, 0).
Stichwörter: komplexe Zahl als Paar, Multiplikationsregel, imaginäre Einheit i, Körper, Rechengesetze geprüft.
See also¶
- Machine numbers — Python's
complexholds two floats, so each component is a member of the finite set described there - Complex number ↗ — Wikipedia, the construction as ordered pairs
- Introduction to Complex Numbers, UC Davis ↗ — free notes that open with the same construction
- Where this is taught — more notes and the textbooks
- Brahmagupta–Fibonacci identity ↗ — Wikipedia