Quaternions are a number system similar to the complex numbers with four fundamental basis elements: , , , and . These elements obey the following rules:

Quaternions can be understood in at least two complementary ways: algebraically, and geometrically. Most of the applications of quaternions come from their ability to describe 3D rotation.

This essay is something of a work in progress, since quaternions are fairly complicated and I want to get it right. As a result the contents may change as I update it.

A bit of history

Quaternions were invented/discovered/hallucinated1 by William Rowan Hamilton in 1843, with related work done a little earlier by Olinde Rodrigues in 1840. William Rowan Hamilton is the same Hamilton that Hamiltonian mechanics in physics and Hamiltonian paths in graph theory are both named after, among many other of his discoveries. He also coined the terms ‘scalar’ and ‘tensor’. Not bad.

Song rec

Watch this song about William Rowan Hamilton by A Capella Science. It’s really very good.

He created the quaternions after a fruitless search for an algebraic structure that describes rotation in three dimensions. He was very aware of how the complex numbers could be used to describe 2D rotation using two basis elements, and where , and wanted to find an equivalent well-behaved structure with three basis elements for 3D. In a letter Hamilton wrote to his son Archibald, he said

Every morning in the early part of October 1843, on my coming down to breakfast, your brother William Edwin and yourself used to ask me: “Well, Papa, can you multiply triples?” Whereto I was always obliged to reply, with a sad shake of the head, “No, I can only add and subtract them.”

It turns out that such a structure is impossible if we take ‘well-behaved’ to mean ‘works like the real numbers’2 This was proved by Ferdinand George Frobenius, of chicken mcnugget theorem fame, who showed that there are only three unique associative algebraic structures3 based on the real numbers where you can always do division: the real numbers themselves in one dimension, the complex numbers with two dimensions, and quaternions with four. That’s it.

All the possible options are structurally identical to these three, which means that Hamilton’s search for an algebra with three basis elements was doomed from the start. He did find the quaternions though, so I don’t think he was too cut up about it.

The algebraic interpretation

[work in progress]

The geometric interpretation

[also a work in progress]

3D rotation

The main application of quaternions is for describing 3D rotation. By taking , , and as the unit vectors of 3D space (aka ) and doing a special kind of quaternion conjugation, we can perform any 3D rotation while avoiding the issues of other systems, like gimbal lock.

The way this is done mathematically is quite complicated. I’ll give an overview here but if you want to fully understand how quaternions produce rotation, Grant Sanderson and Ben Eater made an amazing interactive website that gives the geometric intuition.

Quaternion rotation

Start by taking , , and as the three axes of your 3D space, oriented perpendicular to each other such that if and are oriented along the index and middle finger of your right hand, points upwards along your thumb. 3D rotation can be uniquely defined by an axis through the origin and an angle of rotation around that axis. Let’s limit the axis vector to have length 1 for consistency.

Thoughts

Plan

Tie it all together by talking a bit about interpreting mathematical structures

Some better explanations of quaternions

Realistically, you’re not going to understand quaternions just by reading this blog post. With that in mind, here are some places where you’ll find more complete explanations of what’s going on:

Algebraic

Geometric

Footnotes

Footnotes

  1. Remind me that I need to write about the philosophy of mathematics

  2. An annoying thing about algebra: all of the nice properties about the real numbers like associativity, commutativity, multiplicative distributitivity, and additive and multiplicative inverses are not necessary in the slightest, and you shouldn’t expect them when dealing with more general structures like groups (or semigroups (or magmas)). Primary school me was baffled as to why you can’t swap the terms for subtraction but you can for addition and multiplication (division made a bit more sense). Turns out it’s because addition and multiplication are just really special, and nothing else is ever that nice.

  3. Strictly they have to be an associative algebra, which I don’t really understand well enough to comment on