### 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
$\begin{array}{}\text{(1)}& up\left(x\right)=1{e}_{0}+x{e}_{1}+{x}^{2}{e}_{2}-y{e}_{3}\end{array}$
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\left(x\right)=y=a{x}^{2}+bx+c$. Then, given a point represented by the vector$u=up\left({u}_{x},f\left({u}_{y}\right)\right)$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.
$\begin{array}{}\text{(2)}& u\wedge v=up\left({u}_{x},f\left({u}_{x}\right)\right)\wedge up\left({u}_{x}+{\delta }_{x},f\left({u}_{x}+{\delta }_{x}\right)\right)\end{array}$
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.
$\begin{array}{}\text{(3)}& t=u\wedge v\wedge {e}_{2}=up\left({u}_{x},f\left({u}_{x}\right)\right)\wedge up\left({u}_{x}+{\delta }_{x},f\left({u}_{x}+{\delta }_{x}\right)\right)\wedge {e}_{2}\end{array}$
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.

#### Examining the tangent line object

To examine$t$we will apply the JNS equation to it, which is wedging (joining) a variable point$up\left(x,y\right)$with it.
$\begin{array}{}\text{(4)}& \begin{array}{rl}t\wedge up\left(x,y\right)& =up\left({u}_{x},f\left({u}_{x}\right)\right)\wedge up\left({u}_{x}+{\delta }_{x},f\left({u}_{x}+{\delta }_{x}\right)\right)\wedge {e}_{3}\wedge up\left(x,y\right)=\\ & ={\delta }_{x}\left(-{\delta }_{x}a{u}_{x}+{\delta }_{x}ax-a{u}_{x}^{2}+2a{u}_{x}x+bx+c-y\right)=0\end{array}\end{array}$
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$.
$\begin{array}{}\text{(5)}& \begin{array}{r}y=\left(2a{u}_{x}+b\right)x+\left(a{u}_{x}^{2}-c\right)\end{array}\end{array}$
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\left(x\right)=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.
$\begin{array}{}\text{(6)}& \begin{array}{r}y=0\end{array}\end{array}$
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
$\begin{array}{}\text{(7)}& \begin{array}{r}2a{u}_{x}+b\end{array}\end{array}$
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:
1. Choose basis vectors and an$up\left(x,y\right)$function to map 2D points to vectors
2. Choose an equation for a curve$y=f\left(x\right)$
3. Choose a point on the curve$\left(x,f\left(x\right)\right)$and another point close the first$\left(x+{\delta }_{x},f\left(x+{\delta }_{x}\right)\right)$where${\delta }_{x}^{2}=0$
4. Join the two points and also the basis vectors that do not belong to lines (just the one for${x}^{2}$in our parabola example)
5. 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.
1. Start with an M-dimensional GA and an up function$up\left({x}_{1},...,{x}_{n}\right)$that can represent our O-dimensional objects embedded in N-dimensional space, including the tangent objects. In our parabola example,$M=4$(the GA has 4 basis vectors),$O=1$(a 1D curve) and$N=2$(the curve lies in a 2D space).
2. We have an object defined by$N-O$intrinsic equations${f}_{i}\left({x}_{1},...,{x}_{O}\right)$(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
3. Choose a point$u=\left({u}_{1},...,{u}_{O},{f}_{1}\left({u}_{1},...,{u}_{O}\right),...,{f}_{1+N-O}\left({u}_{1},...,{u}_{O}\right)\right)$which lies on the object and is where we want to find the tangent object.
4. Choose$O-1$points that are close to the chosen point$u$. Do this by introducing${\delta }_{x},{\delta }_{y},...$that square to zero and adding them to the independent cooordinates of the first point (eg. for a 2D surface in 3D space$v=\left({u}_{x}+{\delta }_{x},{u}_{y},f\left({u}_{x}+{\delta }_{x},{u}_{y}\right)\right)$,$w=\left({u}_{x},{u}_{y}+{\delta }_{y},f\left({u}_{x},{u}_{y}+{\delta }_{y}\right)\right)$).
5. 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$1,x,y,...$and aren't arguments to${f}_{i}$, there are$M-O$of them).
6. The resulting pseudovector (because we wedged$O-1+\left(M-O\right)=M-1$vectors) represents the tangent object including position offset. Its slopes (terms proportional to$x,y,...$which are independent in$f$) are the derivatives in each direction on the object.

#### 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\left(x,y\right)={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.