These Numbers Took 130 Years to Become Useful

Share
These Numbers Took 130 Years to Become Useful
Photo by Hugöl Hälpingston / Unsplash

Breaking the rules

If Pythagoras were alive, he would absolutely lose his mind over what passes for a number nowadays. To him, and other ancient Greeks, numbers were things you could count with, like 1, 2, and 3, or ratios of such things, like 1/2, 2/3 or 6/7[1]. Today we call the former positive integers and the latter rational numbers. Notice the absence of zero and negative quantities. Everything was geometry to them and if that's all you care about then why bother with lines with zero or negative length? Such a notion was obviously ridiculous! Pythagoras and his cult of followers vehemently believed that all lengths in nature could be measured by whole numbers or ratios thereof. If the legends are true (they almost certainly aren't), they were even willing to kill for this conviction.

Maths is as much about breaking rules as it is about making them, though. By the 7th century, the use of negative numbers to represent debt was widespread in India. Furthermore, it isn't even true that every length can be neatly expressed as a ratio of integers. This was known to the Pythagoreans, in fact, and they hated it. Have a look at this right-angled triangle.
root_2_triangle.png
By a theorem invented by the very leader of their cult, the length of the longest side is \(\sqrt{2}\). Say you really want to write this as a ratio of two whole numbers \(a\) and \(b\). That is \[\sqrt{2} = \frac{a}{b}.\] This fraction is in its simplest form, so \(a\) and \(b\) share no common factors. Square both sides and the equation becomes \[2 = \frac{ a^2 }{ b^2 }.\] This means \(a^2\) is even, which can only be true if \(a\) is even. Rearrange this equation, and you have \[b^2 = \frac{a^2}{2}.\] This implies \(b^2\) is also even, so \(b\) is even[2]. Hang on, didn't we assume \(a\) and \(b\) didn't share any common factors? We have a contradiction! Our initial assumption that we could write \(\sqrt{2}\) as a ratio of two whole numbers must be wrong. Quantities like \(\sqrt{2}\), \(\pi\), \(e\) and so on are what we call irrational numbers. They “break” the rule that numbers have to be expressible as ratios of integers. Let's break another one.

Fast-forward by about 2,000 years. It's 1545, and mathematicians have no problem using the word “number” for quantities like 0, -1, 42, 11/12 and \(\sqrt{5}\). Gerolamo Cardano was a prominent Italian mathematician of the time (as well as philosopher, biologist, writer and... gambler?), working on his Ars Magna, or Great Art. In it, he considered the curious case of equations that look like \[x^3 + x^2 + x + 1 = 0.\] With some secondary-school maths you can rewrite this in the equivalent form \[\left(x + 1\right)\times\left(x^2 + 1\right) = 0\]If the product of two numbers is zero, then either one or both of them is zero. If the number on the left is zero, then we have the solution \(x = -1\). But if the number on the right is zero, this would imply \[x^2 = -1.\] Surely this has no solutions, right? Well, in this instance, Cardano was a bit more imaginative than the Ancient Greeks. As was the case with the blasphemous triangle, you can't write the solution to this equation as a real number (where “real” means integer, rational or irrational). So just invent a new symbol, \(i\), whose meaning is defined by the equation \[i^2 = -1.\] Now we can solve this equation, and Cardano found the solutions \(x = i\) and \(x = -i\). Much like the Pythagoreans, however, Cardano was none too pleased with his creation. He deemed them “as subtle as they are useless” and wrote that using them was “mental torture”. Jokes on him, though, because it turns out you can't do modern physics without them[3].

By the way, every time we break one of our rules, we have to give something up. When you move from whole numbers to fractions, for instance, you give up (among other things) the notion of evenness and oddness. To move from rationals to irrationals, you have to give up the ability to write down every digit of your number in a finite amount of time. In moving from the reals to the complex (numbers of the form \(a + b i\)), you must rid yourself of the notion that numbers can be ordered. We can write \(4 > 3\), but we cannot write \(4i > 3i\), the comparison simple loses meaning. Complex numbers naturally sit in two dimensions (see the diagram below), so what exactly would it mean for a point in the top left to be greater or less than a point in the top right? This diagram also highlights a more general notion of size: the distance between a complex number and the point at 0. This is known as the modulus[4].

complex_numbers.png

Now, if you're thinking “What happens if we add a third axis?” then you're in good company. William Rowan Hamilton, one of the titans of mathematics and physics, thought the same thing in 1843. He had great difficulty coming up with anything satisfactory, however. He figured out a way to add and subtract these 3D numbers easily enough, but a sensible notion of multiplication and division escaped him. Keen readers might be thinking that perhaps multiplication and division are just the things you have to give up when you move to the next type of number, but Hamilton wasn't quite ready for that. It turns out that a three-dimensional number system that has a well-defined notion of division is a mathematical impossibility, and this would be proved about thirty years later. Hamilton would not be the one to prove it; he kept thinking away, not knowing that his efforts would ultimately never produce what he sought.

But then, in a moment of inspiration while walking along the Royal Canal with his wife, the answer hit him. What he needed was a fourth axis. He wrote,

And here there dawned on me the notion that we must admit, in some sense, a fourth dimension of space for the purpose of calculating with triples... An electric circuit seemed to close, and a spark flashed forth.

He was allegedly so overcome by his realization that he couldn't help but carve the defining formula for his number system into the wall of a bridge with a pocket knife: \[i^2 = j^2 = k^2 = ijk = -1.\] These are known as quaternions. They are “hypercomplex” in the sense that you have extra numbers which behave like \(i\) does for the complex numbers[5]. So what do we have to give up? Oh, nothing major. You know how \(5\times 4\) is the same thing as \(4 \times 5\)? This is called commutativity. Well, \(5i\times 4k\) is not the same thing as \(4k\times 5i\). In the quaternion system, multiplying different imaginary units together gives you an extra minus sign when you change the order of multiplication:\[ij = -ji = k,\quad jk = -kj = i,\quad ki = -ik = j.\]

The way you might be feeling now is probably akin to how the Pythagoreans felt about irrational numbers, or how Cardano felt about complex numbers. Perhaps you think it's even unnatural to speak of numbers for which changing the order of multiplication changes the product. Can such things even be called numbers? Surely these quaternions are just mathematical curiosities with no practical applications...

Quaternion Rotations

If you've taken a course in undergraduate maths, the quaternion multiplication rule might look familiar. Vectors in 3D space have a notion of multiplication. Actually, they have two, but the one whose output is also a vector is similarly not commutative. This link is not a coincidence. The 3D vector \((x, y, z)\) is, in a sense, identical to the quaternion \(0 + xi + yj + zk\).

Now, imagine that I gave you a random vector and asked you to calculate its rotation some number of degrees about the \(x\)-axis and some other number of degrees about the \(y\)-axis. This is a nontrivial task, unless the angles are particularly nice. Trigonometry is involved. The cosine rule is involved. Do you even remember the cosine rule? I'm literally a theoretical physicist and I don't.

Turns out, 3D rotation is way easier if you think of your rotation as a quaternion[6]. A tiny bit of trigonometry is still involved, only because where there are angles there are trig functions, but no rules or theorems need to be invoked. Only the quaternion multiplication rule. Rotating things the old-fashioned way also has a fatal flaw known as “gimbal lock”. Think of a gimbal as an imaginary ring around an object, arranged like a gyroscope (see this post's cover image). Rotating an object by tracking angles would involve rotating gimbals. Gimbal lock occurs when any two gimbals coincide and quite literally become locked together. Effectively, you've just lost an entire axis of rotation. Quaternions, on the other hand, represent both the angle and the relative axis of rotation in a single 4D number. So not only are they just a faster way to compute rotations, they are also far more robust.

This is extremely useful in 3D software. Have you ever used Blender, or Maya, or ZBrush? There's a very good chance that under the hood the software was utilizing quaternions to compute how the viewport should change when you move the camera, or how the object itself should transform when you apply a rotation. There is a very real sense in which Marvel movies exist in part due to some Irish dude thinking really hard about hypercomplex numbers in the 1840s.

The list of applications doesn't stop there. Think of any other context where it might be useful to quickly calculate angles, and quaternions probably show up. Computer vision is such an example, which touches on everything from 3D scanners to LiDAR, as well as image reconstruction from raw spatial data, as is the case in MRI scanners (more on them in a future post), and image processing for robotics.

I like to say that pure maths is a temporary term. It's the name we give to mathematics that will ultimately be applied, we just might not be the ones to apply it. In the case of quaternions, it took about 130 years. Yet now, cool movies are made, infrastructure is built and lives are saved, all with the power of quaternion algebra.


  1. Technically I'm collapsing terms here. The Ancient Greek's distinguished arithmos (what we would call whole numbers) from megethos (which more strongly resembles what we call "size" or "magnitude"). ↩︎

  2. Unless, of course, \(b = 1\), but this would imply that \(\sqrt{2}\) is an integer. It would have to lie between 1 and 2, where there are no integers, so \(b\neq 1\). ↩︎

  3. For the interested reader, see 2D fluid dynamics, special relativity, electrical engineering and quantum mechanics. ↩︎

  4. See this Khan Academy article for an introduction to complex numbers. ↩︎

  5. Of course, mathematicians have not stopped at quaternions. Other hypercomplex number sets include the octonions and the sedenions. ↩︎

  6. The maths involved is cool but I'm trying to keep things relatively non-technical on this blog. Take a look at these notes if you're interested. ↩︎