Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
This notebook is a tutorial on how to use Clifford Algebras and SageMath. In it, we derive the trigonometric parametrization, curvature, and volume for the sphere.
Image: ubuntu2204
Clifford Algebra Tutorial
This notebook is a tutorial on how to use Clifford Algebras and SageMath. To run it, you will need either a local sage executable, or to run it on cocalc. I’ve tested it with Sage 10.2. Clifford algebras represent geometric objects such as vectors in an algebraic manner which is amenable to direct computation. SageMath allows me to run these computations symbolically so that we can end up with generic formulas rather than just final numerical answers.
Mathematical Preliminaries
Clifford algebras start with an associative and distributive multiplication operation over vectors and the additional constraint that for all vectors v, for some fixed symmetric matrix .
For example, if M is the 3 by 3 identity matrix, then for any basis vector we have . So then we can rewrite a string such as .
But we have enough information to derive other rewrite rules as well. Consider , an arbitrary diagonal matrix, so that if then . Let’s calculate . We can simplify this expression two different ways:
(i) .
(ii)
Equating (i) and (ii) tells us that . So now we can make calculations like .
Notice that if , then we have . In 2D, turns out to be analogous to the complex unit , and in 3D , , , and turn out to be analogous to , , , and of the quaternions. We call bivectors and think of them as oriented areas in the plane spanned by and .
The grade of a Clifford algebra term is the number of basis elements in each reduced term — for instance is grade 0, is grade 1, is grade 2, and so on ( is called mixed grade). We can generalize the complex numbers and the quaternions by considering even-grade subalgebras of Clifford algebras with more basis elements. We keep associativity in these higher dimensional algebras by giving up totality of the inverse operation (I think).
Notebook Contents
In this notebook, I will demonstrate the use of a Clifford algebra by deriving:
Rational and irrational parametrizations for the surface of a sphere
Curvature of the sphere
Volume of the sphere
Clifford Algebra Sage Setup
This is some boilerplate to get SageMath to run simplic manipulation of a Clifford algebra term. Using this lift function, trigonometric simplification and differentiation work as expected.
Since for any vector v we have , we can invert a vector via .
The operation reflects across the (hyper) plane which is orthogonal to . Since reflection preserves a vector’s size and is unit length, we get a (rational) parametrization of the unit sphere. Then we show that the sphere’s parametrization is simplified by translating the sphere to touch the origin. We also define a general bivector.
We would like to have a notion of inner and outer product, but so far we only have a notion of inner product on vectors specifically (via ). We can more general inner and outer products on arbitrary vectors via and , respectively, but it turns out that this is not the cleanest generalization (in terms of equational laws / how much it acts like our expectations of an inner and outer product). Instead, Dorst suggests using the outer product and left contraction operations as defined below:
We mentioned earlier that will reflect across the hyperplane orthogonal to . We can then express rotations via an even number of reflections, such as . This product will expand into a bivector , which in general can be written as . So we can express rotations via .
However, consider . Then . Each application of or rotated the target vector by a quarter turn, Making a collective turn of . But what if we wanted to do this same rotation incrementally — as in by degrees in the plane?
We can use that and taylor expansion to derive an analogue for Euler’s formula but with instead of .
Below we check that up to degree 7.
Using a similar derivation, we can extend Euler’s formula to an arbitrary bivector .
Namely, we check that .
I. Parameterization of the Sphere
Now that we have an analogue for Euler’s formula in the Clifford algebra, we can automatically compute rotations.
First we calculate .
Then we calculate a trigonometric parametrization for the radius sphere by rotating by in the plane, followed by a rotation by in the plane. Notice that this derivation will proceed identically in higher dimensions by continuing to apply rotations in the planes.
II. Gaussian Curvature
Next we calculate Gaussian Curvature by following the formulas for the first and second fundamental forms of a surface. Notice that where the instructions call for an inner product, we instead use the left contraction that we defined earlier. Also we replace the cross product with the negative pseudoscalar () times our generalized outer product.
III. Volume of the Sphere
We want to calculate the volume of the sphere by integrating in spherical coordinates. In order to do so, we can integrate with an approriate extra factor for the relative shape of the infinitesimal volume elements we are integrating over. That extra factor is the determinant of the Jacobian of the surface parameterization. We can express this determinant using the outer product of the surface’s gradient vectors, and like earlier we convert it into a vector by multiplying by the negative pseudoscalar.
Now we can calculate the volume of the sphere by integrating!
Future Work
In the future I plan to extend this notebook to obtain:
Formulas for surface of ellipse and torus
Volumes of these shapes by deriving the determinant of the Jacobian of the surface parameterization
Curvature for these shapes