IMAGINE WINDING THE hour hand of a clock back from 3 o’clock to noon. Mathematicians have long known how to describe this rotation as a simple multiplication: A number representing the initial position of the hour hand on the plane is multiplied by another constant number. But is a similar trick possible for describing rotations through space? Common sense says yes, but William Hamilton, one of the most prolific mathematicians of the 19th century, struggled for more than a decade to find the math for describing rotations in three dimensions. The unlikely solution led him to the third of just four number systems that abide by a close analog of standard arithmetic and helped spur the rise of modern algebra.

The real numbers form the first such number system. A sequence of numbers that can be ordered from least to greatest, the reals include all the familiar characters we learn in school, like –3.7, the square root of 5, and 42. Renaissance algebraists stumbled upon the second system of numbers that can be added, subtracted, multiplied and divided when they realized that solving certain equations demanded a new number, i, that didn’t fit anywhere on the real number line. They took the first steps off that line and into the “complex plane,” where misleadingly named “imaginary” numbers couple with real numbers like capital letters pair with numerals in the game of Battleship. In this planar world, “complex numbers” represent arrows that you can slide around with addition and subtraction or turn and stretch with multiplication and division.

Hamilton, the Irish mathematician and namesake of the “Hamiltonian” operator in classical and quantum mechanics, hoped to climb out of the complex plane by adding an imaginary j axis. This would be like Milton Bradley turning “Battleship” into “Battlesubmarine” with a column of lower case letters. But there was something off about three dimensions that broke every system Hamilton could think of. “He must have tried millions of things and none of them worked,” said John Baez, a mathematician at the University of California, Riverside. The problem was multiplication. In the complex plane, multiplication produces rotations. No matter how Hamilton tried to define multiplication in 3-D, he couldn’t find an opposing division that always returned meaningful answers.

To see what makes 3-D rotation so much harder, compare turning a steering wheel with spinning a globe. All the points on the wheel move together in the same way, so they’re being multiplied by the same (complex) number. But points on the globe move fastest around the equator and slower as you move north or south. Crucially, the poles don’t change at all. If 3-D rotations worked like 2-D rotations, Baez explained, every point would move.

The solution, which a giddy Hamilton famously carved into Dublin’s Broome Bridge when it finally hit him on October 16, 1843, was to stick the globe into a larger space where rotations behave more like they do in two dimensions. With not two but three imaginary axes, i, j and k, plus the real number line a, Hamilton could define new numbers that are like arrows in 4-D space. He named them “quaternions.” By nightfall, Hamilton had already sketched out a scheme for rotating 3-D arrows: He showed that these could be thought of as simplified quaternions created by setting a, the real part, equal to zero and keeping just the imaginary components i, j and k — a trio for which Hamilton invented the word “vector.” Rotating a 3-D vector meant multiplying it by a pair of full 4-D quaternions containing information about the direction and degree of rotation. To see quaternion multiplication in action, watch the newly released video below by the popular math animator 3Blue1Brown.