### Designing Geometric Algebras - Tangent Objects

With part 1 of this series we are successfully able to represent any shape as a GA element. One thing we might want is an object representing the tangent space on the object.

In a curve in 2 dimensional space, the tangent space at a point would just be the tangent line at it. In 3 dimensions, the tangent space of a curve would still be a tangent line, but this time it is a line in 3 dimensions instead of 2. If we look at a surface in 3 dimensions, its tangent space at a point on it would be a plane at that point tangent to the surface.

The tangent space is also related to derivatives. In 2D, the derivative of a curve is the slope of it. We can represent the derivative at a specific point by drawing a tangent line at it. For a surface in 3D we can take the derivative in two non-parallel directions on the surface, which will give us tangent lines that together span the tangent plane of the surface.

It would be nice if we had a simple procedure for getting objects representing the tangent space at a point of another object. In the next part we will start by examining parabolas as a concrete example for all of this. In the end we will have a general procedure.

#### Parabola example

Suppose we want to represent parabolas$y=a{x}^{2}+bx+c$ in GA. The equation contains four terms$1,x,{x}^{2},y$ , so we need four basis vectors and the up function mapping from points to vectors will be

We could now join three points together into a parabola that goes through all three of them, and extract the intrinsic equation by looking at its Outer Product Null Space / Join Null Space (JNS).

#### Derivatives and tangent lines

Next we want to figure out the derivative of the parabola. We already know that tangent lines are related to derivatives, so we will try to find the object representing the tangent line at a point on the parabola.

We start by defining a parabola$f(x)=y=a{x}^{2}+bx+c$ . Then, given a point represented by the vector$u=up({u}_{x},f({u}_{y}))$ on the parabola, how can we get an object representing the line that is tangent the parabola at that point?

The first thing we need to do is make sure the line is actually tangent to the parabola. We could achieve this by taking the point$u$ and taking a small step${\delta}_{x}$ along the parabola. We call the slightly offset point$v$ . Then we need to build up the object representing the line that goes through those two points, so we start by joining the two points.

This will result in a bivector. But curves, including lines, are represented by pseudovectors (trivectors in this case) in our algebra, not bivectors. To get a trivector that represents a line curve, what we need to do is join the${x}^{2}$ basis vector${e}_{2}$ with our bivector. This ensures that when we look at the JNS, we will only have$1,x,y$ terms remaining because wedging the trivector with the${x}^{2}$ basis vector again will give zero.

So we arrive at the object we call$t$ that will (hopefully) represent the tangent line. The result of wedging three points into a parabola, and the tangent line through two close points on it is visualized below.

_{Link to CoffeeShop with code}

#### Examining the tangent line object

To examine$t$ we will apply the JNS equation to it, which is wedging (joining) a variable point$up(x,y)$ with it.

The result contains the small step${\delta}_{x}$ , the x coordinate${u}_{x}$ of the point at which we want the tangent line, the parabola parameters$a,b,c$ and the variable x parameter of the parabola itself.

If we now define the small step to square to$0$ , we can simplify and solve for$y$ .

What does this result mean?

Let's start examining by taking the parabola with parameters$a=1,b=0,c=0$ . This would be the parabola$f(x)=y={x}^{2}$ . For it, we would expect the tangent line at$x=0$ to be the straight horizontal line$y=0$ .

For equation$\text{(5)}$ this means${u}_{x}=0$ because${u}_{x}$ is the x coordinate of the point where we wanted to have the tangent line.

This is indeed what we expected, so equation$\text{(5)}$ and thus the object$t$ from$\text{(3)}$ passes this sanity check.

Another check we can make is that the tangent line somehow encodes the derivative. Usually we say that the derivative is the slope of a function at a point on it. In our case our tangent line not only contains the slope, but also the vertical offset.

If we only look at the slope of$\text{(5)}$ , that is, the part proportional to$x$ , we have

This is indeed the derivative of the parabola${y}^{\prime}=2ax+b$ evaluated at$x={u}_{x}$ .

We conclude the example with a way to find the tangent space of a curve in 2 dimensions. As a recap, here is what we did:

- Choose basis vectors and an
function to map 2D points to vectors$up(x,y)$ - Choose an equation for a curve
$y=f(x)$ - Choose a point on the curve
and another point close the first$(x,f(x))$ where$(x+{\delta}_{x},f(x+{\delta}_{x}))$ ${\delta}_{x}^{2}=0$ - Join the two points and also the basis vectors that do not belong to lines (just the one for
in our parabola example)${x}^{2}$ - The resulting object represents our tangent line including position offset, its slope is the derivative of the object

#### Tangent spaces for objects in general

There are two ways we need to generalize here:

First we need to generalize from 2 dimensional space to O dimensional objects (curves are 1D, surfaces are 2D, regardless of the space they lie in). Instead of just just one close point we now have$O-1$ close points offset by${\delta}_{x},{\delta}_{y},...$ .

Second, We can have$O$ dimensional objects in spaces of dimension$N$ where$N>O$ , so there are$N-O$ "extra" dimensions. This means for each extra dimension we need functions${f}_{i}$ that map from the object's parameters to the values in the extra dimensions. In the parabola example, the parabola is a 1D object in 2D space, so we had$N=2,O=1$ and we got$2-1=1$ function for describing the$y$ coordinate of the parabola which depends on$x$ . For curves in 3D space however we would get$3-1=2$ functions for the$y$ and$z$ coordinate depending on$x$ .

Third, to build a pseudovector for representing our object, we need to join all the basis vectors not belonging to lines. If$M$ represents the dimensionality of our GA then pseudovectors are$M-1$ dimensional. We wedged$O$ points (the point for the tangent and$O-1$ directions), so to get$M-1$ we need to wedge with$M-O-1$ additional basis vectors. These are all the basis vectors that aren't contained in lines that make up the tangent object. This includes not only those terms with${x}^{2}$ etc., but also those that aren't parameters to the${f}_{i}$ functions.

Another important point is that we need to make sure the basis vectors for representing tangent objects are present in the up function in the first place. If we do not have those, we can not represent the tangent objects at all with our GA.

#### Algorithm for finding tangent objects

Below I summarize the algorithm for finding tangent objects which we just derived.

- Start with an M-dimensional GA and an up function
that can represent our O-dimensional objects embedded in N-dimensional space, including the tangent objects. In our parabola example,$up({x}_{1},...,{x}_{n})$ (the GA has 4 basis vectors),$M=4$ (a 1D curve) and$O=1$ (the curve lies in a 2D space).$N=2$ - We have an object defined by
intrinsic equations$N-O$ (one for each extra "physical" dimension higher than the object itself) for which we want to find the tangent object at arbitrary points on it${f}_{i}({x}_{1},...,{x}_{O})$ - Choose a point
which lies on the object and is where we want to find the tangent object.$u=({u}_{1},...,{u}_{O},{f}_{1}({u}_{1},...,{u}_{O}),...,{f}_{1+N-O}({u}_{1},...,{u}_{O}))$ - Choose
points that are close to the chosen point$O-1$ . Do this by introducing$u$ that square to zero and adding them to the independent cooordinates of the first point (eg. for a 2D surface in 3D space${\delta}_{x},{\delta}_{y},...$ ,$v=({u}_{x}+{\delta}_{x},{u}_{y},f({u}_{x}+{\delta}_{x},{u}_{y}))$ ).$w=({u}_{x},{u}_{y}+{\delta}_{y},f({u}_{x},{u}_{y}+{\delta}_{y}))$ - Wedge together all the points, and also all the basis vectors that do not correspond to basis vectors for the lines of the object (those that aren't
and aren't arguments to$1,x,y,...$ , there are${f}_{i}$ of them).$M-O$ - The resulting pseudovector (because we wedged
vectors) represents the tangent object including position offset. Its slopes (terms proportional to$O-1+(M-O)=M-1$ which are independent in$x,y,...$ ) are the derivatives in each direction on the object.$f$

#### Further improvements and ideas

##### Small step as a basis vector

For doing the small step sizes we used variable$\delta $ that square to zero. As a short note, we are already using GA, so we can just introduce new basis vectors for these which square to zero. This makes it very easy to do all of this if you already have access to a GA framework that can deal with basis vectors squaring to zero.

##### Higher order "tangent" spaces

If you have read my article on automatic differentiation you might remember that we can do higher order automatic differentiation by making the small steps equal to zero when raised to a certain power instead of two (squaring).

We could do the same here to represent not only the first order derivatives (tangents) but also second order and higher ones. For a curve, this would give us a parabola at every point that represents not only represents first order change, but also the second order one-dimensional curvature. For a surface, we would get a paraboloid at every point which also encodes curvature.

#### Conclusion

We started our quest with objects represented in a GA and wanting to find tangent objects on them, which are also represented in our GA. We derived a method for achieving this by looking at a parabola example. Then we generalized the method so it works in any dimension and on shapes of any number of parameters. Finally we looked some more ideas for improving or expanding on this.

#### Bonus: Paraboloid surface in 3D and its tangent plane

I tried doing what I did for the parabola above, but for 3D space and a paraboloid in it ($f(x,y)={x}^{2}+{y}^{2}$ ). Its tangent space will be a plane. However, Coffeeshop isn't great at rendering these yet. Here it is anyway. Rotate the camera to see the teal paraboloid, the pink one is the tangent surface, red are points making up the paraboloid and the green points are the three close points making up the tangent plane.

_{Link to CoffeeShop with code}