## Clifford Algebras for Rotating, Scaling, and Translating the PlaneJune 8th, 2009 Patrick Stein

In my previous post, I reviewed how the complex numbers can be used to represent coordinates in the plane and how, once you’ve done that, complex arithmetic leads naturally to rotations, scalings, and translations of the plane. Today, we’re going to do the same with the Clifford algebra $\mathcal{C}\ell_2$.

### What are Clifford Algebras

In our previous post, we used two different ways to represent coordinates in the plane. We used an ordered pair of real numbers like $(3,5)$ and we used the real and imaginary parts of a complex number like $3 + 5i$. Another way we could have written the coordinates in the plane is as a vector. Typically, to express a vector, we pick an axis (say, the x-axis) and then pick a second axis perpendicular to it (say, the y-axis). Most physics books would call these $\hat{i}$ and $\hat{j}$. I am going to use $e_1$ and $e_2$ instead so that there is no confusion with $i = \sqrt{-1}$ and because it is a notation that we will continue throughout Clifford algebras. We could then express $(3,5)$ as $3e_1 + 5e_2$. Here, $e_1$ and $e_2$ are called unit vectors. We assume they have length one so that when we take three of them, we get something with length three (for arbitrary values of three).

Having done that, we can easily multiply any vector by a real number using the normal distributive law: $s \cdot \left(xe_1 + ye_2\right) = (sx)e_1 + (sy)e_2$. And, we can add vectors just like we added complex numbers: summing like parts. So, $(ae_1 + be_2) + (ce_1 + de_2) = (a+c)e_1 + (b+d)e_2$. Of course, subtraction goes the same way: $(ae_1 + be_2) - (ce_1 + de_2) = (a-c)e_1 + (b-d)e_2$.

Great. We can add and subtract vectors. We can multiply vectors by real numbers. But, what about multiplying a vector by a vector? Well, let’s try it: $(ae_1 + be_2)\cdot(ce_1 + de_2)$. Again, we’re going to use the F.O.I.L. method. We end up with: $ace_1^2 + ade_1e_2 + bce_2e_1 + bde_2^2$. So far, I have assumed that we can multiply real numbers by our unit vectors in any order, but that maybe multiplying $e_1e_2$ would be different than $e_2e_1$. Well, to get anywhere from here, we need to be able to evaluate things like $e_1^2$ and $e_1e_2$.

[Note: the F.O.I.L. method is nothing magical. It is simply the distributive law applied three times:

$(a + b)(c + d) = a(c+d) + b(c+d) = ac + ad + bc + bd$

Actually, this leaves me a good place to mention… if you’re better at hearing someone speak while doing math than you are reading along on your own, then you can review the complex arithmetic we did in the last post with these videos at KhanAcademy.org: i and Imaginary numbers, Complex Numbers (part 1), and Complex Numbers (part 2).]

So, where are we? If we want to multiply two vectors together, we need to decide how to multiply things like $e_1^2$ or $e_1e_2$. Well, there are probably lots of ways we could do this. But, we’re going to be trying to do geometric things with our vectors. What are some geometrically useful possibilities?

We could say that any vector multiplied by itself is just itself so that $e_1^2 = e_1$. This doesn’t really help us figure out anything about $e_1e_2$ and how it relates to $e_2e_1$.

Another possibility is that parallel vectors annihilate each other so that $e_1^2 = 0$ while perpendicular vectors do not. If that were the case, then $(e_1 + e_2)^2 = 0$. And, $(e_1 + e_2)^2 = e_1^2 + e_1e_2 + e_2e_1 + e_2^2 = e_1e_2 + e_2e_1$. so that $e_1e_2 = -\left(e_2e_1\right)$. This has some merits. This results in what is called the Exterior (or Grassmann) algebra. There is lots of interesting stuff to learn there, but Clifford algebras take a slightly different tack.

Another natural choice might be then that if we take some vector $r$ and multiply it by itself, maybe we should get a real number that is the square of the length of $r$. So, if we have a vector $xe_1 + ye_2$, its length is $\sqrt{x^2 + y^2}$. If we want the square of the vector to be $x^2 + y^2$, then we need to have the following:

$(xe_1 + ye_2)^2 = x^2 + y^2$

$x^2e_1^2 + xye_1e_2 + xye_2e_1 + y^2e_2^2 = x^2 + y^2$

To make this equation work out for every $x$ and $y$, we need to have $e_1e_2 = - \left(e_2e_1\right)$ and $e_1^2 = e_2^2 = 1$. This is the essence of Clifford algebra. All of the rest is deducible from here. But, we’re going to be a bit more explicit on some of the things this implies.

We can reduce $(ae_1 + be_2)\cdot(ce_1+de_2)$ further, now. When we multiplied it all out, we got: $ace_1^2 + ade_1e_2 + bce_2e_1 + bde_2^2$. Knowing now that $e_1^2 = e_2^2 = 1$ and $e_1e_2 = -\left(e_2e_1\right)$, we can rewrite this: $(ac + bd) + (ad - bc)e_1e_2$. So, we multiplied two vectors and got a real number plus a real number times this other thing: $e_1e_2$. We’re going to call this other thing a bivector.

### A bivector?

Let’s explore bivectors a little more. In particular, what is $(e_1e_2)^2 = e_1e_2e_1e_2$? Well, we’ve already decided that $e_1e_2 = -e_2e_1$. So, we know that $e_1e_2e_1e_2 = -e_2e_1e_1e_2$. And, we already decided that $e_1^2 = 1$, so $-e_2e_1^2e_2 = -e_2e_2$. And, we already decided that $e_2^2 = 1$. So, $(e_1e_2)^2 = -1$. When we square our unit bivector, we get $-1$. Our bivector is exactly like our $i$ from the complex numbers!

Recall that $(a + bi)\cdot(c+di) = (ac - bd) + (ad + bc)i$. Now, let’s multiply out $(a + be_1e_2)\cdot(c + de_1e_2)$. We get $ac + ade_1e_2 + bce_1e_2 + bd(e_1e_2)^2$ which is $(ac - bd) + (ad + bc)e_1e_2$.

So, we could stop right here if we wanted. We could represent our points in the plane as a real number plus a real number times $e_1e_2$ and do everything we did with the complex numbers. But, if we did that, then we’ve totally skipped over using the vector part of our Clifford algebra. We are only using the bivector part.

Now we’ve got real numbers and vectors and bivectors. What if we multiply $e_1\cdot(e_1e_2)$? Well, since $e_1^2 = 1$, we are just left with $e_2$. How about if we multiply $(e_1e_2)\cdot e_1$? Here, we have to make use of $e_1e_2 = -e_2e_1$, so we end up with $e_1e_2e_1 = -e_2e_1e_1 = -e_2$. So, our vectors and bivectors are a little weird compared to what we’re used to. We’re used to having $ab = ba$ for real numbers (and even complex numbers). But, this doesn’t work out for vectors times vectors or vectors times bivectors. And, it turns out, that will be a good thing later. In two-dimensions, it isn’t quite as big a deal. [Well, if you’re familiar with vector cross-products, then maybe it is a big deal to you since you already know that $a \times b = - b \times a$.]

Anyhow, an arbitrary element of the two-dimensional Clifford algebra $\mathcal{C}\ell_2$ is of the form $a + be_1 + ce_2 + de_1e_2$ for real numbers $a$, $b$, $c$, and $d$. It is a real number $a$ plus a two-dimensional vector with real coordinates $be_1 + ce_2$ plus a real number times our bivector $e_1e_2$.

### Transforming the Plane

It is common/natural/intuitive?/easy? to think of the coordinates of a point in the plane as a two-dimensional vector from the origin to the point. As such, we’re just going to use the coordinates as the coefficients of the unit vectors of our general element $a + be_1 + ce_2 + de_1e_2$. So, the point $(3,5)$ would be represented in our algebra as $3e_1 + 5e_2$. This is called a pure vector since it has zero for its real part and zero for its bivector part.

Now, what if we had a whole list of points $(x_1,y_1)$, $(x_2,y_2)$, $\ldots$, $(x_k,y_k)$? We can represent these as elements of our Clifford algebra as $z_1 = x_1e_1 + y_1e_2$, $z_2 = x_2e_1 + y_2e_2$, $\ldots$, $z_k = x_ke_1 + y_ke_2$. If we want to translate all of them by two units along the x-axis and seven units along the y-axis, then we can let $t = 2e_1 + 7e_2$ and just add $t$ to each of our points: $z_j^\prime = z_j + t$.

Now, what if we want to scale the whole plane up by a factor of six radiating from the origin? We can just let $s = 6$ and multiply it by each of our points: $z_j^\prime = s \cdot z_j$.

How about rotation by an angle $\theta$ around the origin? Well, drawing on what we did with complex numbers, let’s see if we can just get away with multiplying by $\cos\theta + \sin\theta e_1e_2$. Recall that we want a point $xe_1 + ye_2$ to go to a point $(x\cos\theta - y\sin\theta)e_1 + (x\sin\theta + y\cos\theta)e_2$ when rotated.

Let’s try multiplying $(\cos\theta + \sin\theta e_1e_2)\cdot(xe_1 + ye_2)$. Remember, we have to be careful to keep the $e_1$‘s and $e_2$‘s in the order they appear because every time we swap places on them, we need to swap the sign. When we multiply this out, we get:

$x\cos\theta e_1 + y\sin\theta e_1e_2e_2 + x\sin\theta e_1e_2e_1 + y\cos\theta e_2$

$x\cos\theta e_1 + y\sin\theta e_1 - x\sin\theta e_2e_1e_1 + y\cos\theta e_2$

$(x\cos\theta + y\sin\theta)e_1 + (-x\sin\theta + y\cos\theta)e_2$

This is really close. We just don’t have the sign right on the sine terms. Well, we could just use the fact that $\cos\theta = \cos(-\theta)$ and $\sin\theta = -\sin(-\theta)$. But, that would be funky weird to use $-\theta$ when you want to rotate by $\theta$. But, we’ve seen before how switching the order of multiplying things can change the sign. Let’s try this here. Instead of multiplying with the vector on the right, let’s multiply with the vector on the left:

$(xe_1 + ye_2)\cdot(\cos\theta + \sin\theta e_1e_2)$

$x\cos\theta e_1 + x\sin\theta e_1e_1e_2 + y\cos\theta e_2 + y\sin\theta e_2e_1e_2$

$(x\cos\theta - y\sin\theta)e_1 + (x\sin\theta + y\cos\theta)e_2$

There we have it. So, if we let $r = \cos\theta + \sin\theta e_1e_2$, then we can rotate all of our points by angle $\theta$ around the origin using: $z_j^\prime = z_j \cdot r$.

And, of course, if we want to scale or rotate around different points, we can translate, scale or rotate, and translate back again like we did with the complex numbers.

### Not so fast

It turns out that just multiplying with the vector on the left isn’t going to serve us well as we go up in dimensions. We’re going to do something that might look really awkward now, and will be somewhat awkward for this two-dimensional case, but it’s going to prepare us to do better things in three or more dimensions.

Let’s let $r = \cos\phi + \sin\phi e_1e_2$. And, let’s let $\overline{r} = \cos\phi - \sin\phi e_1e_2$. You might recognize this as just like the complex conjugate of $r$.

Let’s see what we get if we multiply $xe_1 + ye_2$ by $r$ on the left and by $\overline{r}$ on the right.

$(\cos\phi + \sin\phi e_1e_2)(xe_1 + ye_2)(\cos\phi - \sin\phi e_1e_2)$

$(x\cos\phi e_1 + x\sin\phi e_1e_2e_1 + y\cos\phi e_2 + y\sin\phi e_1e_2e_2)(\cos\phi - \sin\phi e_1e_2)$

$(x\cos\phi e_1 - x\sin\phi e_2 + y\cos\phi e_2 + y\sin\phi e_1)(\cos\phi - \sin\phi e_1e_2)$

$[(x\cos\phi + y\sin\phi)e_1 + (-x\sin\phi + y\cos\phi)e_2)](\cos\phi - \sin\phi e_1e_2)$

This is getting a bit large, so let’s just concentrate for a moment on the terms that are going to contribute to $e_1$ in the end: namely, the $e_1$ term in the first factor times the real part in the second factor and the $e_2$ term in the first factor times the bivector part in the second factor.

$(x\cos^2\phi + y\sin\phi\cos\phi)e_1 + (x\sin^2\phi - y\sin\phi\cos\phi)e_2e_1e_2$

$(x\cos^2\phi + y\sin\phi\cos\phi)e_1 - (x\sin^2\phi - y\sin\phi\cos\phi)e_1$

$[x(\cos^2\phi - sin^2\phi) - y(2\sin\phi\cos\phi)]e_1$

We can do a similar thing with the portions that contribute to $e_2$:

$(-x\sin\phi\cos\phi + y\cos^2\phi)e_2 - (x\sin\phi\cos\phi + y\sin^2\phi)e_1e_1e_2$

$(-x\sin\phi\cos\phi + y\cos^2\phi)e_2 - (x\sin\phi\cos\phi + y\sin^2\phi)e_2$

$[x(2\sin\phi\cos\phi) + y(\cos^2\phi - sin^2\phi)]e_2$

Now, we have to remember some trigonometric identities. In particular, we need to remember the double angle identities: $cos^2\phi - sin^2\phi = \cos(2\phi)$ and $2\sin\phi\cos\phi = \sin(2\phi)$. Taking advantage of those, we have our whole product:

$[x\cos(2\phi) - y\sin(2\phi)]e_1 + [x\sin(2\phi) + y\cos(2\phi)]e_2$

So, if we want to rotate by an angle $\theta$ around the origin, we can let $r = \cos\frac{\theta}{2} + \sin\frac{\theta}{2}e_1e_2$. Then, we can let $z_j^\prime = r\cdot z_j \cdot \overline{r}$. And, of course, if we want to rotate around a point $t$ instead, we can translate by $-t$, do this rotation, and translate $t$ back so that $z_j^\prime = r \cdot (z_j - t) \cdot \overline{r} + t$.

Now, we’ve used Clifford algebras to represent rotating, translating, and scaling the plane. In our next installment, we will move on to use quaternions to rotate three-dimensional space. From there, we will move to the Clifford algebra for three-dimensional vectors $\mathcal{C}\ell_3$.