On the morning of 16 October 1843, the Irish mathematician William Rowan Hamilton was walking along the Royal Canal in Dublin with his wife. He had been trying for fifteen years to extend the algebra of complex numbers from two dimensions to three. Every approach had failed — multiplication kept producing inconsistent results in three dimensions.
That morning, walking past Brougham Bridge, the answer came to him: don’t try for three dimensions. Use four.
He took out a knife and carved into the bridge:
Those four equations define what Hamilton called quaternions — a number system with one real component and three imaginary ones. The carving on the bridge has long since worn away, but every year a small group of mathematicians makes a pilgrimage to the spot. The plaque there now reads: “Here as he walked by on the 16th of October 1843 Sir William Rowan Hamilton in a flash of genius discovered the fundamental formula for quaternion multiplication…”
This article is about what Hamilton invented, why it took so long to find, and why a 19th-century algebraic curiosity has turned out to be one of the most useful mathematical tools in 21st-century computer graphics.
What complex numbers did
Recall that ordinary complex numbers consist of a real part plus an imaginary part: , where . They form a 2D number system. Their geometric interpretation, established by Wessel and Argand and rigorized by Gauss, is points on a plane: real component on the horizontal axis, imaginary on the vertical.
Two of the most useful properties of complex numbers in this picture:
- Multiplication by a complex number rotates and scales. Multiplying any vector by rotates it by angle . Multiplying by rotates and scales by .
- Adding combines vectors. Standard parallelogram rule.
This makes complex numbers ideal for 2D graphics, signal processing, and any rotation-heavy 2D problem. (See our imaginary numbers piece for the broader context.)
It seems natural to ask: can we do the same in 3D? Build a number system whose multiplication produces 3D rotations?
Why three dimensions don’t work
Hamilton spent fifteen years trying. He wanted a “triple” with rules for multiplication that would produce 3D analogues of complex-number rotations.
Every approach failed. The problem was always the same: he could define addition cleanly, and he could even pick rules for multiplication, but the rules either weren’t consistent or didn’t produce useful rotations. The mathematical problem turned out to have a deep structural reason: there is no 3D real division algebra. The dimensions where you can have a number system with all four arithmetic operations — addition, subtraction, multiplication, division — are 1, 2, 4, and 8.
This is a theorem (Frobenius for division algebras over , refined to the four normed division algebras: ). 3D doesn’t make the cut. Hamilton’s failure wasn’t due to lack of cleverness — it was a basic constraint of mathematics.
But four dimensions do work, and that’s what Hamilton finally realized.
The quaternions defined
A quaternion is a number of the form
where are real and are three independent square roots of that satisfy
From these three equations, all the other multiplication rules follow. In particular:
The last three equations are crucial: quaternion multiplication is not commutative. . This is the price you pay for going from 2D to 4D.
The set of quaternions is denoted (after Hamilton). It satisfies all the laws of arithmetic except commutativity of multiplication. Addition is component-wise; multiplication is distributive but ordered. Every nonzero quaternion has a multiplicative inverse:
So is a “skew field” (a non-commutative field). This is the precise structural fact Hamilton had been searching for.
How quaternions encode rotations
Here’s where quaternions become interesting for 3D applications. Take a unit quaternion — one whose components satisfy . Such a quaternion can always be written as
where is a “pure imaginary” unit quaternion representing a direction in 3D space.
Now interpret a 3D point as a pure imaginary quaternion . Then the formula
produces a new pure imaginary quaternion whose components are rotated by angle around the axis .
This is the master formula. Every rotation in 3D space corresponds to a unit quaternion (up to sign), and rotation composition is just quaternion multiplication. To rotate first by and then by , you compute — no matrix multiplication needed.
Why graphics engineers love them
The quaternion-based representation of rotations has several enormous practical advantages over alternatives:
Compact. A quaternion is 4 numbers. A rotation matrix is 9 (with 6 redundant constraints). For storing thousands of orientations per second — animation skeletons, particle systems, robotics — the savings matter.
No gimbal lock. Euler angles (yaw, pitch, roll) suffer from a classic singularity: when one rotation axis aligns with another, you lose a degree of freedom. This is why aircraft autopilots and 3D animation software using Euler angles can suddenly behave erratically. Quaternions don’t have this problem — the entire rotation space is smooth.
Smooth interpolation. Animating a rotation between two orientations is a common task. With matrices, you have to be careful — naive linear interpolation gives non-rotation matrices (skews and scales). Quaternions admit slerp (spherical linear interpolation) — a clean formula that smoothly interpolates between two rotations along the shortest arc on the 4D unit sphere. This is the standard for 3D animation tween systems.
Numerical stability. Composing many rotation matrices accumulates error. Repeated quaternion multiplication accumulates much less, and renormalizing a quaternion to unit length is cheap (just divide by the norm). For long-running simulations like spacecraft attitude tracking, this matters.
The combination — compact, singularity-free, smoothly interpolatable, numerically stable — is why every modern 3D graphics library (OpenGL, DirectX, Vulkan), every game engine (Unity, Unreal, Godot, CryEngine), and most robotics frameworks store and manipulate orientations as quaternions internally. Hamilton’s 1843 invention became the standard 21st-century tool for representing 3D rotation.
The hierarchy of normed division algebras
Quaternions sit in a hierarchy of “good” number systems:
| System | Dimension | Property lost |
|---|---|---|
| Real numbers | 1 | (the base case) |
| Complex numbers | 2 | order |
| Quaternions | 4 | commutativity |
| Octonions | 8 | associativity |
Each step doubles the dimension and loses one algebraic property. Beyond octonions, the algebra deteriorates further: sedenions (16D) have zero divisors (nonzero numbers whose product is zero), so they don’t form a meaningful algebra.
Hurwitz’s theorem (1898) proves these four are the only finite-dimensional normed division algebras over . There is no 5D, 6D, or 7D analogue. The mathematical landscape allows exactly these four sizes.
This restriction is not an accident — it’s tied to the topology of spheres, the theory of Lie groups, and ultimately to the structure of mathematics itself. Octonions, despite their non-associativity, appear in modern theoretical physics: in superstring theory, M-theory, and certain exceptional Lie groups. Quaternions appear in 3D graphics. Each finite-dimensional division algebra has found its applications.
Hamilton’s life
William Rowan Hamilton was born in Dublin in 1805. By age 13 he could speak 13 languages. By age 22 he was Astronomer Royal of Ireland. He published transformative work in optics, mechanics (the Hamiltonian formulation, still central to physics), and algebra.
The quaternion discovery in 1843 was, by his own assessment, the most important moment of his intellectual life. He spent the rest of his career — almost 25 more years — developing and promoting quaternions. He believed they would become the natural language of 3D physics, replacing vectors. His magnum opus, Lectures on Quaternions (1853) and the posthumous Elements of Quaternions (1866), totaled over 2,000 pages.
The campaign mostly failed. Heaviside and Gibbs in the 1880s extracted the cleaner concepts of vector algebra from Hamilton’s quaternions, and physics adopted those. By 1900 quaternions were considered a 19th-century curiosity, replaced by simpler vector-and-matrix notation.
Then 3D graphics happened in the 1980s. Slerp interpolation for animation was published in 1985 and revealed quaternions as the right tool for animation. By 2000 they were everywhere in 3D applications. Hamilton’s vision — quaternions as the natural language of 3D rotation — turned out to be prescient, just by 150 years.
He died in 1865, having spent his final decade in increasingly difficult circumstances — alcoholism, financial troubles, isolation from the Irish mathematical community. He didn’t live to see his discovery vindicated.
What quaternions teach
For a student of mathematics, quaternions illustrate several lessons:
Generalization has costs. Going from 2D to 4D buys you 3D rotation, but at the cost of commutativity. Generalization in mathematics rarely comes for free.
Algebraic structure has consequences. The four normed division algebras correspond to four allowed dimensions. This pattern, traced from algebra into topology and physics, has been one of the most productive themes of 20th-century mathematics.
Practical applications come from unexpected places. Hamilton invented quaternions to clean up 3D geometry. They became standard in computer graphics 150 years later. The mathematician who invents a tool rarely knows what it will be used for.
Sometimes the mathematics is more durable than the application. Hamilton’s contemporary applications of quaternions to physics were largely abandoned. The underlying mathematics was preserved by pure mathematicians for a century before computer graphics rediscovered it.
The next time you play a 3D video game, watch a rocket dock in space, or use your phone’s compass, there’s a quaternion working in the background. A 20-year-old polymath in Dublin, frustrated by 15 years of failed three-dimensional algebra, finally saw that he needed a fourth dimension. Two centuries later, that insight is one of the load-bearing pieces of modern 3D computing.
The carving on Brougham Bridge wore away within decades. The mathematics it commemorated has only become more important.
Frequently asked
Why are quaternions better than rotation matrices?
Three reasons. First, they're more compact: 4 numbers versus 9 in a rotation matrix. Second, they avoid 'gimbal lock' — a singularity in Euler-angle representations where two rotation axes align. Third, interpolating between rotations is mathematically cleaner with quaternions (slerp). Most modern graphics engines and robotics systems use quaternions internally for these reasons.
Are quaternions really used in real-world applications?
Constantly. NASA uses them for spacecraft attitude control. Every 3D video game engine (Unity, Unreal, Godot) uses them for object rotation. Robotic arms use them for end-effector orientation. Inertial measurement units (IMUs) in your phone produce orientation data as quaternions. They're the unsung workhorse of 3D applications.
Are there higher-dimensional number systems?
Yes — there's a hierarchy. Real numbers (1D), complex numbers (2D), quaternions (4D), octonions (8D), sedenions (16D). Each step doubles the dimension and loses some property: complex numbers lose ordering, quaternions lose commutativity, octonions lose associativity. Sedenions even have zero divisors. Beyond 16D, the algebraic structure deteriorates so much that it's no longer a useful number system.