Quantumania 25 - Irritating Conveyor Belts

Quantumania (25 of 25)

What we’re going to do with our solid United Nations-slash-Flerfer map is use it to represent both operations-on-things and things-being-operated-on. To do this, we’ll stick strictly to unit quaternions, which have modulus 1 and are a closed set under multiplication: if you multiply two unit quaternions, the result is a unit quaternion. The things-being-operated-on are points in space, and the operations-on-things are rotations, and they are both simply points in our solid ball map. In fact, they are the only kind of quaternions in our map.

The unit quaternions describe all the possible pure rotations (with no scaling) that can be performed on a 3D space, just as unit complex numbers describe all pure rotations (with no scaling) on the complex plane. I can think of two possible nagging objections you might feel about this.

First, why does it need to have 4 parameters if it’s a rotation in 3D space? Well, it sort of doesn’t: the constraint where their squares must sum to 1 means that if you know three of them, the fourth is tied down to no more than two possible values, positive or negative:

w = \pm \sqrt{1 - (x^2 + y^2 + z^2)}

The role of the w coordinate being thus diminished, our map almost insults it, giving the three spatial directions of the map space to the other three coordinates.

This is also important because it means that points in the northern (positive w) and southern (negative w) hemispheres of the unit quaternion 3-sphere are paired up. Once you pick values for (x, y, z), there are only two points on the unit quaternion 3-sphere that you could be talking about. Or to refer to our ball-map, there’s a matching pair of points in the inner core and the outer shell.

Second, surely we only need two parameters to specify a point on a 2-sphere? Yes, but we also need to say how much to rotate by (and which of two ways, clockwise or anticlockwise). This works very much like complex rotation. The complex value 1 + 0i=1 is the identity operation, having no effect at all. The value 0 + 1i=i rotates 90^\circ, and -1 + 0i rotates 180^\circ. In general, a pure rotation c by angle \theta is given by:

c = \cos \theta + i \sin \theta

(Often an arbitrary complex number is labelled z but I’ve switched to c as we’ve been using z for one of the ordinary spatial coordinates.)

So as \theta increases from 0, the real part gradually falls as the imaginary part rises, and the two parts, interpreted as coordinates in a plane, describe a circular path. Such a complex number can be multiplied with any other complex number to move it around the origin by the angle \theta, so we can think of it applying as an operator to all complex numbers, i.e. it rotates the entire plane.

Unit circle in the complex plane: multiplying by i rotates 90 degrees anticlockwise around the circle from 1 to i to -1 to -i and back to 1, while a general unit complex number c=cos theta + i sin theta lies at angle theta

So now we need to figure out the same thing for the quaternion space: what is the action of a unit quaternion on all the points in that space? So that we can see the results on our solid model, which only contains unit quaternions, we’ll restrict our space of points to be operated on to the unit quaternions with zero scalar part, which sit on the 2-sphere boundary between the inner core and the outer shell. That way we can visualise points moving around on our map.

It turns out to be not quite as simple and convenient as the complex numbers, but in a way that is easily fixed. First, we’ll use \vec{i} as our rotation, and apply it to various test quaternions using the rules we listed last time:

\vec{i}\vec{j} = \vec{k} \quad \quad \vec{i}\vec{k} = -\vec{j} \quad \quad \vec{i}(-\vec{j}) = -\vec{k} \quad \quad \vec{i}(-\vec{k}) = \vec{j}

These evidently are working as a cycle: the output of each stage becomes the input to the next stage. As \vec{i}, \vec{j} and \vec{k} are acting as basis vectors for 3D space, we effectively visit these points in the coordinate system, starting at \vec{j}:

(0, 1, 0) \quad \quad (0, 0, 1) \quad \quad (0, -1, 0) \quad \quad (0, 0, -1)

So looks like a very helpful rotation in the yz-plane, around the x-axis, in 90^\circ increments, and certainly if the x-coordinate is zero then it stays zero. By symmetry we can similarly rotate the zx-plane around the y-axis by multiplying repeatedly by \vec{j}, or the xy-plane around the z-axis by multiplying repeatedly by \vec{k}.

The w=0 equatorial 2-sphere with the yz-circle highlighted in teal: left-multiplying repeatedly by i rotates points in the yz-plane around the x-axis through j, k, -j, -k

So it sounds like we can perform rotations around all three axes, using their basis vectors. Which ever imaginary quaternion you choose to rotate by, the other two imaginary components are affected. Also by reducing the strength of the imaginary components (and making a compensating increase to the real component to keep it a unit quaternion) you can reduce the angle by which it rotates from 90^\circ to whatever angle you require.

Hence, a first guess at a general formula, the angle \theta determining the mix between real and imaginary, and the imaginary part being simply a unit vector imported from 3D space:

r = \cos \left( \theta \right) + \sin \left( \theta \right) (u_x \vec{i} + u_y \vec{j} + u_z \vec{k})

But before we celebrate too much, we need to see what happens to points that aren’t on the one specific circle of points we’ve tested so far. If we apply \vec{i} as the operator to a test quaternion that has a non-zero \vec{i} component, x \ne 0, what happens? It’s not good news. Clearly, like in regular complex numbers, if we apply \vec{i} to itself we get -1, and so on:

\vec{i}\vec{i} = -1 \quad \quad \vec{i}(-1) = -\vec{i} \quad \quad \vec{i}(-\vec{i}) = 1 \quad \quad \vec{i}(1) = i

This is a rotation alright, at least in quaternion-space, but on our 3D map, referring to our test input, it looks more like a conveyor belt, carrying points in a straight line along the x-axis, passing through 1 (the centre of the map), \vec{i} (on the equator, or the spherical boundary between the inner core and the outer shell), -1 (the outer shell, where it teleports to the opposite side of the ball-map), continuing through -\vec{i} before returning to 1 and repeating the cycle.

This looks exactly like ordinary complex rotation, interchanging between the real number line and whichever imaginary component we chose to multiply by, but the effect of it on our ball-map is to drag anything not on the x = 0, y^2 + z^2 = 1 circle around in a kind of weird cycle that includes an apparently discontinuous flip from positive x to negative x. Really of course this discontinuity is a side-effect of our projection to 3D. The unit quaternions with positive and negative x are really two halves of the hypersphere surface.

In your mind, set the y and z coordinates of a test quaternion to zero, while allowing x and w (the real, scalar coordinate) to cycle around the surface. The test quaternion travels through the North Pole (w=1, x=0) smoothly and without incident. Why can’t it do the same at the South Pole? It can, and does! It passes through (w=-1, x=0) just as smoothly. It’s just that in our projection to 3D, we exploded the South Pole into the outermost sphere, the 3D ice wall of our 3D United Nations map, where all points have coordinates (w=-1, x=0, y=0, z=0). So anything that passes through the South Pole appears, on our projection, to discontinuously teleport. When x has a tiny positive value, it’s right next to the ice wall on one side of the outer sphere, and when it passes through x=0 to become slightly negative, it’s then just inside the ice wall on the opposite side.

Edge-on view of the x-axis across the ball-map with the scalar coordinate w plotted vertically: the conveyor belt slides down the curve from w=+1 at the centre through +i (w=0) to w=-1 at the right ice wall, teleports across to w=-1 at the left ice wall, and climbs back up through -i (w=0) to w=+1

Despite this, our projection still makes sense because the kinds of rotation we want are interchanges between imaginary pairs like jk, which look like well-behaved rotations in the projection space. But an interchange between an imaginary component and the real number line totally destroys this neat picture.

The one saving grace is that, because we’re always acting with unit quaternions on test subjects that are also unit quaternions, the product is always another unit quaternion, so at least they don’t disappear from the map entirely. Our map has no place for non-unit quaternions. It’s just a unit-only slice of the space of all possible quaternions, as we threw away non-unit quaternions to achieve a 3D projection. Any operation on a test quaternion that moves it away from the surface of the unit hypersphere will make it vanish entirely from our map, “into the fourth dimension”! A somewhat science-fictiony phrase that isn’t particularly helpful, because if something exists in a 4D space then obviously it has always been somewhere in the fourth dimension, just as it has always been somewhere in the other three. But it would no longer be sitting in the one 3D slice visible in our map.

So the action of a quaternion with an imaginary component, such as i, is in effect two simultaneous rotations:

  • the one we want: the quaternion i defines an axis around which the other two imaginary components rotate, so the jk plane tumbles nicely around it.
  • the one we don’t want: complex real-imaginary interchange that our projection converts into cyclical discontinuous teleportation through the ice wall.

Fortunately there’s a simple trick that fixes this. Quaternion multiplication is anti-commutative:

\vec{i}\vec{j} = -\vec{j}\vec{i}

We can apply a quaternion as a rotation operator on the left side and the right, and they have different effects. What we want to do is reinforce the good rotation (involving interchange between the imaginary components) and cancel out the unhelpful rotation (involving interchange with the real, scalar component).

Let’s see what happens when we multiply a general quaternion q on the left by \vec{i}:

\begin{eqnarray*} \vec{i} q &=& \vec{i} (w + x\vec{i} + y\vec{j} + z\vec{k}) \\ &=& w\vec{i} + x\vec{i}^2 + y\vec{i}\vec{j} + z\vec{i}\vec{k} \end{eqnarray*}

Notice how the effect of i on the w coordinate, as it’s just a real, will not depend on which side we multiplied \vec{i} on. Real/imaginary multiplication is commutative. But also notice how the same is true for the x coordinate, because there we just multiply \vec{i} by itself, so switching left and right can’t make any difference. It’s just \vec{i}^2 = -1.

Whereas for the remaining two coordinates, they now scale the products of two different imaginary units, \vec{i}\vec{j} = \vec{k} and \vec{i}\vec{k} = -\vec{j}, and we know that such products are anti-commutative: switching sides would switch signs. So substituting these identities:

\begin{eqnarray*} \vec{i} q &=& w\vec{i} - x + y\vec{k} - z\vec{j} \\ &=& -x + w\vec{i} - z\vec{j} + y\vec{k} \end{eqnarray*}

On that last line we just put the components in the usual order. Just to show explicitly how multiplying on the right disagrees:

\begin{eqnarray*} q \vec{i} &=& (w + x\vec{i} + y\vec{j} + z\vec{k}) \vec{i} \\ &=& w\vec{i} + x\vec{i}^2 + y\vec{j}\vec{i} + z\vec{k}\vec{i} \\ &=& w\vec{i} - x - y\vec{k} + z\vec{j} \\ &=& -x + w\ve

We can see how the two simultaneous rotations performed by \vec{i} are affected by the switching of sides. Or rather, only of them is affected: the rotation in the real/\vec{i}-plane stays exactly the same. The other one, the useful one, is sadly reversed. This means that if we performed both actions, multiplying by \vec{i} on both sides:

\vec{i}q\vec{i}

then the useful \vec{j}\vec{k}-plane rotation would be undone, and the irritating crazy conveyor belt effect would be reinforced. How infuriating. But if we knew how to make the multiplicative inverse of any quaternion, that would reverse both rotations. Then then we could multiply by the inverse on the right, and we would reinforce the useful rotation and cancel the irritating one! So we just need to know how to find the inverse of a quaternion.

Hamilton already figured this stuff out with algebra. He wanted quaternions to behave like numbers, so he needed to be able to divide as well as multiply, so given a quaternion r he wanted to find r^{-1} such that rr^{-1} = 1. What he discovered was that, exactly like conjugation with complex numbers, we can form the conjugate of a quaternion by flipping the sign of the imaginary parts:

r = w + x\vec{i} + y\vec{j} + z\vec{k} \quad \quad r^* = w - x\vec{i} - y\vec{j} - z\vec{k}

And as you’d expect, if we multiply them, we get a purely real value, the modulus-squared:

r r^* = w^2 + x^2 + y^2 + z^2

So to scale this back to 1, we just need to divide by the modulus-squared, giving:

r^{-1} = \frac{r^*}{|r|^2}

But we’re describing rotations with unit quaternions, so the modulus is always 1, and thus for our purposes we can use conjugation to get the inverse. This is extremely reminiscent of how the inverse of a unitary operator in matrix form can be found by the conjugate transpose, isn’t it?

So to perform a rotation by r, on the left we use r and on the right we use its conjugate, r^*, which can be found by flipping the signs of all the imaginary terms in r. This cancels out the unwanted conveyor belt effect along the direction of r, leaving just the desired proper rotation in the plane perpendicular to r’s vector part. Although now we’ve applied that rotation twice, and this explains the factor of 1/2 on the angle in the formula for building a general quaternion to rotate by:

r = \cos \left( \frac{\theta}{2} \right) + \sin \left( \frac{\theta}{2} \right) (u_x \vec{i} + u_y \vec{j} + u_z \vec{k})

So the full recipe to use r to rotate a point in 3D space is as follows. Represent that point p as a quaternion using the imaginary units to carry the point’s coordinates:

p = p_x \vec{i} + p_y \vec{j} + p_z \vec{k}

and then make a sandwich:

p^\prime = r p r^*

where r^* is just r with a minus sign on the vector terms, i.e.

r = \cos \left( \frac{\theta}{2} \right) - \sin \left( \frac{\theta}{2} \right) (u_x \vec{i} + u_y \vec{j} + u_z \vec{k})

This is probably enough mid-18th century geometry for now.




    Not yet regretting the time you've spent here?

    Keep reading:

  • Quantumania 24 - Learn from the Flerfers
  • Quantumania 23 - Turn! Turn! Turn!
  • Quantumania 22 - Three Dimensions
  • Quantumania 21 - Slot Machines
  • Quantumania 20 - Disentanglement