The bridge and the day
Hamilton was Professor of Astronomy at Trinity College, lived at Dunsink Observatory north-west of Dublin and was President of the Royal Irish Academy. On 16 October 1843 he was to chair a council meeting of the Academy and walked into town along the towpath of the Royal Canal with his wife, Helen. When they reached the bridge at Cabra – today Broom Bridge, which Hamilton himself called Brougham Bridge – he felt "the galvanic circuit of thought close", as he later wrote. He saw that he had to use four dimensions instead of three, and that multiplication had to give up the commutative law. He cut the fundamental rules into a stone of the bridge and wrote them in his notebook the same evening. The next day he described the discovery in a long letter to his friend John T. Graves, and on 13 November he presented it to the Academy.
In a letter to his son Archibald in 1865, shortly before his death, Hamilton recalled that every morning at breakfast the children had asked: "Well, Papa, can you multiply triplets?" – and that he had been obliged to reply, with a sad shake of the head, that he could only add and subtract them.
The bridge today
Hamilton's carving has long since disappeared. A stone plaque under the bridge, on the towpath side, was unveiled by the Taoiseach Éamon de Valera – himself a former mathematics teacher – on 13 November 1958. The plaque records that here Hamilton, in a flash of genius, discovered the fundamental formula for quaternion multiplication and cut it on a stone of the bridge. The bridge carries Broombridge Road over the Royal Canal and is named after William Broome, a director of the canal company. Hamilton's sons called it "Quaternion Bridge", and 16 October is today jokingly known as "Broomsday" (after Joyce's "Bloomsday").
The Hamilton Walk
Since 1990 mathematicians have walked Hamilton's route from Dunsink Observatory to the bridge every year on 16 October. The walk was started by Tony O'Farrell of the mathematics department at Maynooth and has had participants such as Andrew Wiles, Roger Penrose, Timothy Gowers and the physicists Murray Gell-Mann, Steven Weinberg and Frank Wilczek. At the bridge the formula is read aloud – and some write it again in chalk.
Why not three dimensions?
The complex numbers $a+bi$ with $i^2=-1$ are points in a plane, and multiplying by a complex number means rotating and scaling in the plane. Hamilton wanted to do the same in space with "triplets" $a+bi+cj$. He wanted a multiplication in which the length of a product is the product of the lengths, $|ab|=|a|\,|b|$, as for the complex numbers. It did not work, and it cannot work. Try it: $(a+bi+cj)$ multiplied by itself gives a term in $ij$. If $ij$ is to be a number of the form $x+yi+zj$, you run into conflict with the length requirement. Hamilton realised on the bridge that $ij$ had to be a completely new number, $k$, perpendicular to the other three – and that $ji$ had to be $-k$.
It has since been proved that Hamilton could not have done better. Ferdinand Georg Frobenius showed in 1877 that the real numbers, the complex numbers and the quaternions are the only finite-dimensional associative division algebras over the reals. Adolf Hurwitz showed in 1898 that algebras with $|ab|=|a||b|$ exist only in dimensions 1, 2, 4 and 8. The eight-dimensional one is the octonions, which Graves found as early as December 1843 – after reading Hamilton's letter – and Arthur Cayley independently in 1845. There one must also give up the associative law.
Calculating with quaternions
A quaternion is an expression
where $a$ is called the scalar part and $bi+cj+dk$ the vector part. You add term by term and multiply out by the distributive law with the rules from the bridge:
(Multiply $ijk=-1$ on the right by $k$: $ij\,k^2=-k$, so $-ij=-k$ and $ij=k$. The rest follows in the same way.) The multiplication table is cyclic: $i\to j\to k\to i$ gives plus, the opposite way gives minus – the same pattern as the cross product of the unit vectors. One defines:
- Conjugate: $\bar q=a-bi-cj-dk$, and $\overline{pq}=\bar q\,\bar p$ (note the reversed order).
- Norm: $|q|^2=q\bar q=a^2+b^2+c^2+d^2$, and $|pq|=|p|\,|q|$.
- Inverse: $q^{-1}=\bar q/|q|^2$. So you can divide by any non-zero quaternion.
Calculator and multiplication table
Click a cell in the multiplication table (row times column), or type two quaternions and see that $pq$ and $qp$ differ, while the norm behaves nicely.
The birth of the dot and cross products
Write a quaternion as a pair of a scalar and an ordinary vector, $q=(a,\mathbf u)$. Multiplying out gives a compact formula:
For two "pure" quaternions (scalar part zero), $\mathbf u\mathbf v = -\mathbf u\cdot\mathbf v+\mathbf u\times\mathbf v$. Hamilton thus found the dot product and the cross product as the two parts of a single product, and it was he who introduced the words "scalar" and "vector". Peter Guthrie Tait and James Clerk Maxwell used quaternions in electromagnetism; Maxwell's Treatise (1873) writes the field equations with Hamilton's $\nabla$. But in the 1880s Josiah Willard Gibbs and Oliver Heaviside separated the two parts and created the vector analysis we use today. That set off a bitter "quaternion war" with Tait in the pages of Nature. Lord Kelvin, who disliked them, called quaternions in 1892 "an unmixed evil to those who have touched them in any way". The vectors won – for a hundred years.
Rotations in 3D with quaternions
The great comeback came with computers. A rotation by the angle $\theta$ about an axis with unit vector $\mathbf n$ corresponds to the unit quaternion
and a vector $\mathbf v$, regarded as the pure quaternion $v=v_xi+v_yj+v_zk$, is rotated by "sandwiching" it between $q$ and $\bar q$:
Two rotations in succession are simply the product $q_2q_1$ – four numbers instead of a 3×3 matrix with nine. The French mathematician Olinde Rodrigues had in fact found the formula for composing rotations using half-angles in 1840, without seeing the algebra behind it; the connection became widely known only in the 20th century. Notice the half-angle: a rotation of 360° gives $q=-1$, and only after 720° is $q=+1$ again. Both $q$ and $-q$ rotate vectors in the same way.
- Make the axis vertical (elevation 90°) and θ = 90°. What are the components of $q$? Do they match $\cos 45°$ and $\sin 45°$?
- Run θ from 0° to 360°. The aircraft is back where it started – but what is $q$ now? Carry on to 720°.
- Find an axis and an angle that turn the aircraft upside down with its nose pointing the same way. Is there more than one possibility?
Slerp: the shortest way between two orientations
In a film or a game a figure must glide smoothly from one orientation to another. With Euler angles (heading, pitch, roll) it is tempting to interpolate each angle separately, but that gives a convoluted, uneven motion. The unit quaternions lie on a three-dimensional sphere $S^3$ in four dimensions, and the natural path is the great circle between them. Ken Shoemake introduced slerp (spherical linear interpolation) in 1985:
Slerp rotates about one fixed axis at constant angular velocity – the shortest rotation from start to finish. If $q_0\cdot q_1<0$, one changes the sign of $q_1$ (it is the same rotation) so as not to go the long way round.
- Which curve is part of a great circle? How long is each path (the angle in the readout)?
- Roll the dice a few times. Can the Euler path become much longer than the slerp path? When do they look alike?
Gimbal lock – the Apollo astronauts' nightmare
A gyroscope or an inertial navigation system sits in three gimbal rings: one for heading, one for pitch and one for roll. That corresponds to describing the orientation with three Euler angles. But when the pitch reaches 90°, the axis of the innermost ring coincides with that of the outermost. Two of the rings now turn about the same axis, and one degree of freedom is lost: gimbal lock. Mathematically, the volume spanned by the three axes is $\cos(\text{pitch})$, which becomes zero.
The inertial platform of the Apollo spacecraft had exactly three gimbals. The computer gave a warning when the middle gimbal angle approached 70°, and at 85° the platform locked, so the astronauts had to realign it on the stars. During Apollo 11, Michael Collins jokingly asked Mission Control to send him a fourth gimbal for Christmas. Quaternions have no such singularities, and that is why modern spacecraft, drones and phones compute their orientation with quaternions. See also inertial navigation on the gyroscope page.
- Set the pitch to 90°. Now try changing heading and roll separately. Why do they do the same thing?
- In gimbal lock the aircraft cannot turn about its own lateral axis without the rings having to turn infinitely fast. Which rotation has "disappeared"?
720° and the electron's spin
That the quaternion becomes $-1$ after one full turn is not a curiosity. The unit quaternions form the group $SU(2)$, which covers the rotation group $SO(3)$ twice: to each rotation correspond two quaternions, $q$ and $-q$. Pauli's spin matrices are the quaternions in disguise: $i\leftrightarrow -i\sigma_x$, $j\leftrightarrow -i\sigma_y$, $k\leftrightarrow -i\sigma_z$. An electron's spin state transforms like $q$ itself – not like $q\,v\,\bar q$ – and therefore changes sign under a rotation of 360°. This has been measured directly with neutron interferometry (Rauch et al. and Werner et al., 1975). You can experience it with Dirac's belt trick or the "plate trick": hold a plate level on your hand and turn it through 360° – your arm is twisted. Turn it a further 360° the same way, and your arm is back in its starting position.
Applications today
- Computer graphics and games: every 3D figure on this website is rotated by Three.js, which internally stores orientations as quaternions – including those on this page.
- Spaceflight: the Space Station, the Hubble telescope and most satellites control their attitude with quaternions.
- Mobile phones, drones and VR: gyroscopes and accelerometers are combined into a quaternion that is updated hundreds of times a second.
- Robots and molecules: robot arms, crystallography and molecular dynamics use quaternions to describe the rotation of rigid bodies without singularities.
- Physics: spin-½, $SU(2)$ in the Standard Model and Lorentz transformations (with complex quaternions).
Exercises
- Calculate $(1+i)(1+j)$ and $(1+j)(1+i)$. Check that the norm of the product is $|1+i|\cdot|1+j|=2$.
- Show from $i^2=j^2=k^2=ijk=-1$ that $jk=i$ and $ki=j$.
- Rotate the vector $\mathbf v = i$ (the x-axis) by 90° about the z-axis with $q=\cos45°+k\sin45°$. Calculate $q\,i\,\bar q$ and show that the result is $j$.
- Show that $q$ and $-q$ give the same rotation, but that the rotation by θ + 360° corresponds to $-q$.
- Prove the formula $(0,\mathbf u)(0,\mathbf v)=(-\mathbf u\cdot\mathbf v,\;\mathbf u\times\mathbf v)$ by multiplying out $u_1i+u_2j+u_3k$ times $v_1i+v_2j+v_3k$.
Sources and further reading
- W. R. Hamilton: "On Quaternions; or on a New System of Imaginaries in Algebra", Philosophical Magazine, 1844–1850, and Lectures on Quaternions, Dublin 1853.
- T. L. Hankins: Sir William Rowan Hamilton. Johns Hopkins University Press, 1980.
- S. L. Altmann: "Hamilton, Rodrigues, and the Quaternion Scandal", Mathematics Magazine 62 (1989) 291–308.
- K. Shoemake: "Animating Rotation with Quaternion Curves", SIGGRAPH '85, Computer Graphics 19 (1985) 245–254.
- J. B. Kuipers: Quaternions and Rotation Sequences. Princeton University Press, 1999.
- J. Baez: "The Octonions", Bull. Amer. Math. Soc. 39 (2002) 145–205.
- MacTutor History of Mathematics: "Dublin – Hamilton's plaque", and Wikipedia: Broom Bridge, Hamilton Walk.
Related pages: Hamiltonian mechanics · Lagrangian mechanics · The gyroscope and the tippe top · Newton's Principia.