Pop Video: What are Quaternions, and How do you Visualize Them? A Story of Four Dimensions | Nagwa Pop Video: What are Quaternions, and How do you Visualize Them? A Story of Four Dimensions | Nagwa

# Pop Video: What are Quaternions, and How do you Visualize Them? A Story of Four Dimensions

Grant Sanderson • 3Blue1Brown • Boclips

What are Quaternions, and How do you Visualize Them? A Story of Four Dimensions

31:50

### Video Transcript

What youβre looking at right now is something called quaternion multiplication. Or rather, youβre looking at a certain representation of a specific motion happening on a four-dimensional sphere being represented in our three-dimensional space. One which youβll understand by the end of this video.

Quaternions are an absolutely fascinating and often underappreciated number system from math. Just as complex numbers are a two-dimensional extension of the real numbers, quaternions are a four-dimensional extension of complex numbers. But theyβre not just playful mathematical shenanigans. They have a surprisingly pragmatic utility for describing rotation in three dimensions and even for quantum mechanics. The story of their discovery is also quite famous in math.

The Irish mathematician William Rowan Hamilton spent much of his life seeking a three-dimensional number system analogous to the complex numbers. And, as the story goes, his son would ask him every morning whether or not he had figured out how to divide triples and he would always say, βno, not yet.β But on October 16th, 1843, while crossing the Broome Bridge in Dublin, he realized, with a supposed flash of insight, that what he needed was not to add a single dimension to the complex numbers. But to add two more imaginary dimensions. Three imaginary dimensions describing space. And the real numbers sitting perpendicular to that in some kind of fourth dimension. He carved the crucial equation describing these three imaginary units into the bridge. Which today bears a plaque in his honor showing that equation.

Now, you have to understand our modern notion of vectors with their dot product and the cross product and things like that didnβt really exist in Hamiltonβs time, at least not in a standardized form. So after his discovery, he pushed hard for quaternions to be the primary language with which we teach students to describe three-dimensional space. Even forming an official quaternion society to proselytize his discovery. Now, unfortunately, this was balanced with mathematicians on the other side of the fence. Who believed that the confusing notion of quaternion multiplication was not necessary for describing three dimensions. Resulting in some truly hilarious old-timey trash talk, legitimately calling them evil. Itβs even believed that the Mad Hatter scene from Alice in Wonderland, whose author you may know was an Oxford mathematician, was written in reference to quaternions. That the chaotic table-placement changes were mocking their multiplication. And that certain quotes were referencing their noncommutative nature.

Fast forward about a century. And the computing industry gave quaternions a resurgence among programmers who work with graphics and robotics and anything involving orientation in 3D space. And this is because they give an elegant way to describe and to compute 3D rotations. Which is computationally more efficient than other methods. And which also avoids a lot of the numerical errors that arise in these other methods. The 20th century also brought quaternions some more love from a completely different direction, quantum mechanics. You see, the special actions the quaternions describe in four dimensions are actually quite relevant to the way that two-state systems, like spin of an electron or the polarization of a photon, are described mathematically. What Iβll show you here is a way to visualize quaternions in their full four-dimensional glory.

It would surprise me if this approach was fully original. But I can say that itβs certainly not the standard way to teach quaternions. And that these specific four-dimensional right-hand rule image that Iβd like to build up to is something that I havenβt really seen elsewhere. Building up an understanding for this visual will take us meaningful time. But once you have it, there is a very natural and satisfying intuition for how to think about quaternion multiplication. It wonβt be until the next video that I show you how exactly quaternions describe orientation in three dimensions. Which is, for some people, the whole reason we care about it. But once weβre able to go at it armed with the image of what theyβre doing to a 4D hypersphere. Thereβs a pleasing understanding to be had for the otherwise opaque formulas characterizing this relationship.

The structure here will be to start by imagining teaching complex numbers to someone who only understands one dimension. Then, describing 3D rotations to someone who only understands two dimensions. And, ultimately, to represent what quaternions are doing up in four dimensions within the constraints of our 3D space.

Our first character is Linus the Linelander, whose mind can only grasp the one-dimensional geometry of lines and the algebra of real numbers. Weβre gonna try to describe complex numbers to Linus. And itβs really important for you to empathize with him as much as you can during this. Because, in a few minutes, youβre gonna be in his shoes. On the one hand, you could define complex numbers purely algebraically. You say each one is expressed as some real number plus some other real number times π. Where π is a newly invented constant whose defining property is that π times π equals negative one. Then you say to Linus, to multiply two complex numbers, you just use the distributive property. What many people learn in school as FOIL. And you apply this rule, that π times π equals negative one, to simplify things down further.

And thatβs fine! That totally works, and the standard textbook way to introduce quaternions is analogous to this. Showing the algebraic rules and calling it done. But I think something is missing if we donβt at least try to show Linus the geometry of complex numbers and what complex multiplication looks like. Since the problems in math and physics, where complex numbers are shockingly useful, often leverage this spatial intuition. You and I, who understand two dimensions, might think of it like this. When you multiply two complex numbers, π times π, you can think of π as a sort of function acting on π, rotating and stretching it in some way. I like to think of this by broadening the view and asking, what does π do to the entire plane? And you can think of that birdβs-eye view action by imagining using one hand to fix the number zero in place. And using another hand to drag the point at one up to π. Since anything times zero is zero, and anything times one is itself.

And in two dimensions, there is one and only one stretching-rotating action on the plane thatβll do this. This is also how Iβll have you thinking about quaternion multiplication later on. Where the number on the left acts as a kind of function to the one on the right. And weβll understand this function by seeing how it acts by transforming space. Although, instead of rotating 2D space, it does a sort of double rotation in 4D space. By the way, if you want to review thinking about complex numbers as a kind of action, a good warm-up for this video might be the one I did on π to the ππ, explained with introductory group theory.

Now Linus the Linelander is pretty comfortable with the idea of stretching. Thatβs what multiplication by real numbers looks like. Maybe itβs a little weird for him to think about stretching in multiple dimensions. But itβs not fundamentally different. The difficult thing to communicate to Linus is rotation. Specifically, focus on the unit circle of the complex plane. All the numbers at distance one from zero. Since multiplication by these numbers corresponds to pure rotation. How would you explain to Linus the look and the feel of multiplying by these numbers? At first, that might seem impossible. I mean, rotation is just such an intrinsically two-dimensional idea. But, on the other hand, rotation involves only one degree of freedom. A single number, the angle, specifies a given rotation uniquely.

So in principle, it should be possible to associate the set of all rotations to the one-dimensional continuum that is Linusβs world. And there are many ways you could do this. But the one Iβm gonna show you is whatβs called a stereographic projection. Itβs a special way to map a circle onto a line, or a sphere into a plane. Or even a 4D hypersphere into 3D space.

For every point on the unit circle, draw a line from negative one through that point. And wherever it intersects the vertical line through the circleβs center, thatβs where the point of the circle gets projected. So for example, the point at one gets projected into the center of the line. The point π actually stays fixed in place, as does negative π. All of the points on that 90 degree arc between one and π will get projected somewhere in the interval between where one landed and where π landed. As you continue farther around the circle on the arc between π and negative one. The projected points end up farther and farther away at an increasing rate. Similarly, if you come around the other way towards negative one. The projected points end up farther and farther on the other end of the line. This line of projected points is what we show to Linus. Labeling a few key points, like one and π and negative one, all for reference.

Technically, the point at negative one has no projection under this map. Since the tangent line to the circle at that point never crosses the vertical line. But what we say is that negative one ends up at the point at infinity. This is a special point you imagine adding to the line. Where you would approach it if you walk infinitely far along the line in either direction. Now itβs important to remember, and to remind Linus, that what heβs seeing is only the complex numbers that are a distance one from the origin, a unit circle. Linus doesnβt see most numbers, like zero or one plus π or negative two minus π. But thatβs okay. Because right now, we just wanna describe complex number π. Where multiplying by π has the effect of a pure rotation. So he only needs to understand the unit circle.

For example, when we take the number π and multiply it by any other complex number π, the effect is to rotate by 90 degrees counterclockwise. And when we apply this action to the circle being projected down to the line for Linus, what does he see? Well, itβs a bit of a strange morphing action on the line. One which I want you to become familiar with for something weβll see later on. Itβs easiest to understand by following a few key reference points. π times one is π, so that means that number one should move up to π. π times π is negative one, so the point at π slides off to infinity. π times negative one is equal to negative π. So that point at infinity kind of comes back around from the bottom to the position one unit below the center. And π times negative π is one, so that point at negative π slides up to one.

Even though this is kind of a weird motion, it lets us communicate some important ideas to Linus. For example, multiplying by π four times, which corresponds to rotating by 90 degrees four times in a row, gets us back to where we started. π to the fourth equals one. Here, to get more of a feel for things, let me just show the circle rotated at various different angles. On both the left and the right half of the screen here, Iβm putting a hand on the point that started at the number one. To help us and to help Linus keep track of the overall motion.

Next, letβs introduce Felix the Flatlander, who only understands two-dimensional geometry. Imagine trying to explain rotations of a sphere to Felix. In the spirit of transitioning from complex numbers to quaternions, letβs extend the complex numbers, with its horizontal axis of real numbers and its vertical axis of imaginary numbers, with a third axis. Defined by some newly invented constant, π, sitting one unit away from zero, perpendicular to the complex plane. Instead of having this new axis in the π§-direction like you might expect. For a better analogy with how weβll visualize quaternions, weβll want to orient things so that the π- and the π-axes sit in the π₯- and the π¦-directions with the real number line aligned along π§-direction. So every point in 3D space is described as some real number plus some real number times π plus some real number times π.

As it happens, itβs not possible to define a notion of multiplication for a 3D number system like this that would satisfy the usual algebraic properties that make multiplication a useful construct. Perhaps Iβll outline why this is the case in a follow-on video. But staying focused on our current goal, think about describing 3D rotations in this coordinate system to Felix the Flatlander. The unit sphere consists of all those numbers which are a distance one from zero at the origin. Meaning, the sum of the squares of their coordinates is one. We canβt show all of 3D space to Felix. But what we can do is project this 2D surface to him and give him a feel for what reorientations of the sphere look like under that projection. Analogous to what we did before, stereographic projection will associate almost every point on the unit sphere with a unique point on the horizontal plane defined by the π- and the π-axes.

For each point on the sphere, draw a line from negative one at the south pole through that point and see where it intersects the plane. So the point one at the north pole ends up at the center of the plane. All of the points on the northern hemisphere get mapped somewhere inside the unit circle of the ππ-plane. And that unit circle which passes through ππ, negative π, negative π actually stays fixed in place. And thatβs an important point to make note of. Even though most points and lines and patches that Felix the Flatlander sees are gonna be worked projections of the real sphere. This unit circle is the one thing that he has which is an honest part of our unit sphere, unaltered by projection. All of the points in the southern hemisphere get projected outside that unit circle, each getting farther and farther away as you approach negative one at the south pole.

And again, negative one has no projection under this mapping. But what we say is that it ends up at some point at infinity. That point at infinity is something such that no matter which direction you walk on the plane, as you go infinitely far out, youβll be approaching that point. Itβs analogous to how if you walk any direction away from the north pole, youβre approaching the south pole. Now let me just pull up a view of what Felix sees in two dimensions. As I rotate the sphere in various ways, the lines of latitude and longitude drawn on that sphere get projected into various circles and lines in Felixβs space. And the way Iβve done things up here, the checkerboard pattern on the surface of the sphere, is accurately reflected in the projected view that you see with Felix. And the pink dot represents where the point that started at the north pole ends up after the rotation. And that yellow circle represents where the equator ended up after the projection.

The more you put yourself in Felixβs shoes right now, the easier quaternions will be in a moment. And as with Linus, it helps to focus on a few key reference objects, rather than trying to see the whole sphere. This circle, passing through one, π, negative one, and negative π gets mapped onto a line which Felix sees as the horizontal axis. Itβs important to remind Felix that what he sees is not the same thing as the π-axis. Remember, weβre only projecting the numbers that have a distance one from the origin. So most points on the actual π-axis, like zero and two π and three π, etc., are completely invisible to Felix. Similarly, the circle that passes through one, π, negative one, and negative π gets projected onto what he sees as a vertical line. And in general, any line that Felix sees comes from some circle on the sphere that passes through negative one. In some sense, a line is just a circle that passes through the point at infinity.

Now think about what Felix sees as we rotate the sphere. A 90-degree rotation about the π-axis brings one to π, π to negative one, negative one to negative π, and negative π to one. So what Felix the Flatlander sees is an extension of the rotation that Linus the Linelander was seeing. Notice also that this action rotates the ππ unit circle to the position where the one π unit circle used to be. So what Felix sees is his yellow unit circle getting transformed into a vertical line. While that red vertical line gets transformed into the unit circle. Of course, from our perspective, we know this is all just rigid motion. No actual stretching or morphing is taking place. All of that is just an artifact of the projection.

Similarly, a rotation about the π-axis involves moving one to π, π to negative one, negative one to negative π, and negative π to one. This rotation turns the ππ unit circle into the one π unit circle, which, to Felix, looks like the unit circle getting transformed into a horizontal line. A rotation about the real axis is actually quite easy for Felix to understand. Since the whole projection simply gets rotated about the origin. Where the only points staying fixed in place are one at the origin and negative one off at infinity.

In the same way that the complex numbers included the real numbers with a single extra quote, unquote, imaginary dimension, represented by the unit π. And that the not-actually-a-number-system thing we had in three dimensions included a second imaginary direction, π. The quaternions include the real numbers together with three separate imaginary dimensions, represented by the units π, π, and π. Each of these three imaginary dimensions is perpendicular to the real number line. And theyβre all perpendicular to each other somehow. So in the same way that complex numbers are represented as a pair of real numbers, each quaternion can be written using four real numbers. And it lives in four-dimensional space. You often think of this as being broken up into a real or scalar part and then a 3D imaginary part.

And Hamilton used a special word for quaternions that had no real part and just π, π, π components. A word which was previously somewhat foreign in the lingo of math and physics, vector. On the one hand, you could just define quaternion multiplication by giving the rules for how π, π, and π multiply together and saying that everything must distribute nicely. This is analogous to defining complex multiplication by saying that π times π is negative one, and then distributing and simplifying products. And indeed, this is how you would tell a computer to perform quaternion multiplication. And the relative compactness of this operation compared to, say, matrix multiplication is whatβs made quaternion so useful for graphics programming and many other things.

Thereβs also a rather elegant form of this multiplication rule written in terms of the dot product and the cross product. And in some sense, quaternion multiplication subsumes both of these notions. At least, as they appear in three dimensions. But just as a deeper understanding for complex multiplication comes from understanding its geometry, that multiplying by a complex number involves a combination of scaling and rotating. You and I are here for the four-dimensional geometry of quaternion multiplication. And just as the magnitude of a complex number, its distance from zero, is the square root of the sum of the squares of its component. That same operation gives you the magnitude of a quaternion.

And multiplying one quaternion, π one, by another, π two, has the effect of scaling π two by the magnitude of π one followed by a very special type of rotation in four dimensions. And those special 4D rotations, the heart of what we need to understand, correspond to the hypersphere of quaternions a distance one from the origin. Both in the sense that the quaternions, whose multiplying action is a pure rotation, live on that hypersphere. And in the sense that we can understand this weird 4D action just by following points on the hypersphere. Rather than trying to look at all of the points in the inconceivable stretch as a four-dimensional space.

Analogous to what we did for Linus and Felix, we stereographically project this hypersphere into 3D space. This label in the upper right is gonna show a given unit quaternion. And this little pink dot will show where that particular quaternion gets projected in our 3D space. Just as before, weβre projecting from the number negative one, which sits on the real number line that is somehow perpendicular to all of our 3D space and beyond our perception. Just as before, the number one ends up projected straight into the center of our space. And in the same way that π and negative π were fixed in place for Linus, and that the ππ unit circle was fixed in place for Felix. We get a whole sphere passing through π, π, and π on that unit hypersphere which stays in place under the projection. So what we see as a unit sphere in our 3D space represents the only unaltered part of the hypersphere of quaternions getting projected down onto us.

Itβs something analogous to the equator of a 3D sphere. And it represents all of the unit quaternions whose real part is zero. What Hamilton would have described as unit vectors. The unit quaternions with positive real parts between zero and one end up somewhere inside this unit sphere, closer to the number one in our 3D space. Which should feel analogous to how the northern hemisphere got mapped inside the unit circle for Felix. On the other hand, all the unit quaternions with negative real part end up somewhere outside that unit sphere. The number negative one is sitting off at the point at infinity, which you can easily find by walking in any direction.

Keep in mind, even though we see the projection of some of these quaternions as being closer or farther from the origin of our 3D space. Everything youβre looking at represents a unit quaternion. So everything youβre looking at really has the same magnitude, the same distance from the number zero. And that number zero itself is nowhere to be found in this picture. Like all other nonunit quaternions, itβs invisible to us. In the same way that, for Felix, the circle passing through one, π, negative one, and negative π got projected into a line through the origin. When we see this line through the origin passing through π and negative π, we should understand that it really represents a circle. Likewise, up on the hypersphere invisible to us, there is a unit sphere passing through one, π, π, negative one, negative π, and negative π. And that whole sphere gets projected into the plane that we see passing through one, π, negative π, π, negative π, and negative one off at infinity. What you and I might call the π₯π¦-plane.

In general, any plane that you see here really represents the projection of a sphere somewhere up on the hypersphere which passes through the number negative one. Now the action of taking a unit quaternion and multiplying it by any other quaternion from the left can be thought of in terms of two separate 2D rotations happening perpendicular to and in sync with each other. In a way that could only ever be possible in four dimensions.

As a first example, letβs look at multiplication by π. We already know what this does to the circle that passes through one and π, which we see as a line. One goes to π, π goes to negative one off at infinity, negative one comes back around to negative π, and negative π goes to one. Remember, just like what Linus saw, all of this is the stereographic projection of a 90-degree rotation. Now look at the circle passing through π and π, which is in a sense perpendicular to the circle passing through one and π. Now, it might feel weird to talk about two circles being perpendicular to each other. Especially when they have the same center, the same radius, and they donβt touch each other at all. But nothing could be more natural in four dimensions.

You can think of the action of π on this perpendicular circle as obeying a certain right-hand rule. If youβll excuse the intrusion of my ghostly green-screen hand into our otherwise pristine platonic mathematical stage. You let that thumb of your right hand point from the number one to π, and you curl your fingers. The ππ circle will rotate in the direction of that curl. How much? Well, by the same amount as the one π circle rotates, which is 90 degrees in this case. This is what I meant by two rotations perpendicular to and in sync with each other. So π goes to π, π goes to negative π, negative π goes to negative π, and negative π goes to π. This gives us a little table for what the number π does to the other quaternions. But I want this not to be something that you memorize, but something that you could close your eyes and you could really see.

Computationally, if you know what a quaternion does to the numbers one, π, π, and π, you know what it does to any arbitrary quaternion. Since multiplication distributes nicely. In the language of linear algebra, one, π, π, and π form a basis of our four-dimensional space. So knowing what our transformation does to them gives us the full information about what it does to all of space.

Geometrically, a four-dimensional creature would be able to look at those two perpendicular rotations that I just described and understand that they lock you into one and only one rigid motion for the hypersphere. We might lack the intuitions of such a hypothetical creature. But we can maybe try to get close. Hereβs what the action of repeatedly multiplying by π looks like on our stereographic projection of the π, π, π sphere. It gets rotated into what we see as a plane. Then gets rotated further back to where it used to be, though the orientation is all reversed now. Then it gets rotated again into what we see as a plane. And after the fourth iteration, it ends up right back where it started.

As another example, think of a quaternion like π equals negative square root of two over two plus square root of two over two times π. Which, if we pull up a picture of a complex plane, is a 135-degree rotation away from one in the direction of π. Under our projection, we see this along the line from one to π somewhere outside the unit sphere. If that sounds weird, just remember how Linus wouldβve seen the same number. The action of multiplying this π by all other quaternions will look to us like dragging the point at one all the way to this projected version of π. While the ππ circle gets rotated 135 degrees, according to our right-hand rule.

Multiplication by any other quaternion is completely similar. For example, letβs see what it looks like for π to act on other quaternions by multiplication from the left. The circle through one and π, which we see projected as a line through the origin, gets rotated 90 degrees, dragging one up to π. So π times one is one, and π times π is negative one. The circle perpendicular to that one, passing through π and π, gets rotated 90 degrees according to this right-hand rule, where you point your thumb from one to π. So π times π is negative π, and π times π is π.

In general, for any other unit quaternion you see somewhere in space, start by drawing the unit circle passing through one, π, and negative one. Which we see in our projection as a line through the origin. Then draw the circle perpendicular to that one on what we see as the unit sphere. You rotate the first circle so that one ends up where π was. And rotate the perpendicular circle by the same amount, according to the right-hand rule.

One thing worth noticing here is that order of multiplication matters. Itβs not, as mathematicians would say, commutative. For example, π times π is π, which you might think of in terms of π acting on the quaternion π, rotating it up to π. But if you think of π as acting on π, π times π, it rotates π to negative π. In fact, commutativity, this ability to swap the order of multiplication, is a way more special property than a lot of people realize. And most groups of actions on some space donβt have it. Itβs like how in solving a Rubikβs cube, order matters a lot. Or how rotating a cube about the π§-axis and then about the π₯-axis gives a different final state from rotating it about the π₯-axis, then about the π§-axis.

And last, as one final but rather important point, so far Iβve shown you how to think about quaternions as acting by left multiplication. Where when you read an expression like π times π, you think of π as a kind of function morphing all of space and π is just one of the points that itβs acting on. But you can also think of them as a different sort of action, by multiplying from the right, where in this expression, π would be acting on π. In that case, the rule for multiplication is very similar. Itβs still the case that one goes to π and π goes to negative one, etc. But instead of applying the right-hand rule to the circle perpendicular to the one π circle, you would use your left hand.

So either way, π times π is equal to π. But you can either think about this with your right hand curling the number π to the number π as your thumb points from one to π. Or as your left hand curling π to π as its thumb points from one to π. Understanding this left-hand rule for multiplication from the other side will be extremely useful for understanding how unit quaternions describe rotation in three dimensions.

And so far, itβs probably not clear how exactly quaternions do describe 3D rotation. I mean, if you consider one of these actions on the unit sphere passing through π, π, and π. It doesnβt leave that sphere in place. It morphs it out of position. So the way that this works is slightly more complicated than a single quaternion product. It involves a process called conjugation. And Iβll make a full follow-on video all about it so that we have the time to go through some examples.

In the meantime, for more information on the story of quaternions and their relation to orientation in 3D space, Quanta, a mathematical publication Iβm sure a lot of you are familiar with, just put out a post in a kind of loose conjunction with this video. Link in the description. If you enjoyed this, consider sharing it with some friends. And if you felt like the narrative structure here was actually helpful for understanding, maybe reassure those friends who would be turned off by a large timestamp that good math is actually worth the time. And many thanks to the patrons among you. I actually spent way longer than I care to admit on this project. So your patience and support is especially appreciated this time around.

## Join Nagwa Classes

Attend live sessions on Nagwa Classes to boost your learning with guidance and advice from an expert teacher!

• Interactive Sessions
• Chat & Messaging
• Realistic Exam Questions