Introducing geometric algebra to software developers
arxiv.org
arxiv.org
Intuitively I think the 5 secondorder terms would correlate to the 2-blades in (3,0) algebra but I've no idea whether or not it could simplify computation.
https://web.archive.org/web/20030521145638/http://www.resear...
For example, adding a scalar and a vector is a meaningful operation in geometric algebra, but it's most likely a programming error if it happens in the overwhelming majority of code. Linear algebra packages in most languages can often detect this error at compile time, or, for dynamic languages, at least detect it at runtime. But if you run a geometric algebra library it can't detect this kind of error, because this would be a legitimate (albeit error prone) operation.
What do geometric algebra enthusiasts think about this?
Imho the biggest problem in GA for CS is the lack of a good ecosystem of tools. Ganja.js is nice, probably the best in class when it comes to API design, but is completely useless when trying to work with other JS libraries because ganja.js has it's own weird transpiler.
[1]https://www.jeremyong.com/klein/ [2]https://github.com/wrnrlr/g3
That's nice!
This reminds of me things like, linear algebra libraries that will type-check matrices so that a 2x2 matrix can't be added to a 2x3 matrix (but then you can have a dynamic matrix that will error only in runtime), like https://nalgebra.org/ and others.
I have written a compiler which generates SIMD ready typed code for the desired GAs. You can then use that output as a normal library for your application.
Adding scalar and a vector may be a breach of model but it may also have several different meanings each of them pragmatic in its own context. It may mean concatenation, as with C++ strings or adding the same scalar to every vector's element as with APL tensors.
Geometric algebra imposes its own type relations and has all the rights to do so.
That being said I can't see why you can't make newtypes over the one geometric algebra type. But at that point, what's the advantage over plain old vectors and matrices?
vs.
2) Having to create or acquire lots of separate types for all the specialized types you (or others) need, along with all their operations, probably in inconsistent ways, and leaving potential types missing, including not having the general type.
Also, the separate type path does not help you cognitively understand the real relationships between the separately crafted types.
A really easy example is the convenience of having a big (unlimited size) integer type that can be parameterized to any size subtype you want.
You get all the arithmetic operations across all those fixed sizes for free, because those algorithms are just easily auto optimized versions of the general operations.
A good system could even auto optimize for an operation that took two integers of different fixed sizes.
Clean concrete closed general types are the powerhouse wonders of the mathematical world. They are just as great for algorithm use.
As long as you can subtype.
What I'm saying is, if my code is strongly typed and deals with these various geometric objects, what benefit do I get if they're internally implemented with geometric algebra as opposed to how they are now?
And you get all the subtype to subtype operations for free, bug free, since they are all just subtype operations themselves.
If you haven’t played around with geometric algebra, you should try it.
It is consistent across any. N dimensions.
And when you are using it in an application, it’s easier to see why things are related the way they are. You have fewer equations.
If you were starting greenfield, geometric algebra probably simplifies more than you would guess, and represents more.
When anything gets simpler, more consistent, and more powerful, most of us start having ideas that would never have occurred to us before.
Same story as any other significant language and/or notation improvements.
It is a mystery to me why it has taken so long to catch on and replace disparate less capable notations.
Inertia I guess. Hard to change geometry across education all at once, but piecemeal would be very messy.
I don’t know any reason it would be less efficient.
The purpose of static types is to catch type errors at compile time. If everything has a single type and all operations receive and return objects of this type, no type error is caught at compile time.
Other people mentioned that you can, indeed, implement geometric algebra operations with a family of types (for example, a type for lines, a type for planes, etc) rather than having a single type. And thus, operations like adding a scalar to a <something> return a type that isn't neither scalar nor <something>. Which will lead to a type error somewhere, hopefully!
It's amazing because that's the diametric opposite of what I'd consider to be true this is what the non-GA approach does, and which we avoid!
The modern approach to GA, eg https://en.wikipedia.org/wiki/Plane-based_geometric_algebra, distinguishes planes-through-the-origin, points, lines-through-the-origin, and lines-at-infinity. These four different types all get called "vectors" in the ordinary mindset. The cross product is said to take in two "vectors" and give you a "vector", but in reality it's generally taking two planes and giving you a line. This is talked about in the fourth paragraph of the wiki article :)
Someone else answered that they might be given a single data type, but it's possible to give more precise types, which seem cool!
(do you have any library to mention, alongside the ones already mentioned?)
My implementation generates a struct for each grade, even and odd grades (which perform transformations), and then a multivector type with everything. If you mistakenly add a scalar and a vector, you'll immediately see unexpected types in your inline type hints.
The downside to my approach is a combinatorial explosion in the number of types and operations between them. Anyone know a seamless way to do lazy code generation in Rust?
Have GA people tried anything along this direction?
Okay I've been thinking a lot about this problem of multiple representations.
Is there any language that actually uses this equivalence of types as a way to select between different ways to represent the same data?
An use case would be something like, a smart list type that will select between a growable linear vector, a copy on write persistent list, etc. and select between them based on a) which operations you do to the list (for example, if you use it in a linear fashion, it doesn't need to be persistent), and b) user annotations in code.
Another use case is to define unary peano numbers like data Nat = Zero | Succ Nat and have the type system understand automatically this doesn't need to be stored like this, and is in fact the same as a (big) int. Some languages have special-casing for this, but this could work generically as well.
It's actually a proof assistant, but you can still write code in it - and perhaps even export it to code in other languages.
Regarding the "smart" features you suggested, those sound interesting, but I'm not aware of any language having them. Could be useful.
Traditional vector math gives the output of the cross-product of two vectors the same type. (That's why it's only meaningful in 3d.) The input and output lives in the same space, you can presumably do meaningful math with them and get a result that's still a vector. The types do not help us.
GA treats this operation differently. The cross-product-equivalent-operation returns a completely different type. Sure, you can add the inputs and outputs, but that returns a third type! If we built an intuition for this type system, it would help us.
I also think the more abstract you get, the smaller portion of the population can understand and work with it. Lots of people understand numbers. Some of those understand vectors. Some of those can understand a transformation matrix. Some of those can understand quaternions. Some of those can understand GA. I'm not sure it's a question of teaching it earlier in school either. Go watch the 3-blue-one-brown video on visualizing quaternion rotation, and try to really appreciate how abstract and hard to understand that is compared to multiplying s set of (ortho-normal) basis vectors by some coordinates to do rotation. Then remember that quaternions are in some sense a subset of the GA abstractions people want us to use. This isn't going to happen any time soon.
That video was not actually very good unfortunately (surprisingly, I might add). I doubt it helped people understand the matter much but just repeated the old "weird incomprehensible 4d number" story.
Numbers -> Complex Numbers -> Vectors -> Matrices -> Quaternions -> SO(2) -> SO(3) -> Lie Algebras -> GA
(The last 3 might need air quotes around "learned")
But I actually think it could be taught:
Numbers -> Vectors -> GA -> Maybe Matrices?
Discover complex number and quaternions naturally, by playing with rotations. Discover e the same way! (They taught me e through finance.) This would have explained so many of the weird quirks of math I had questions about. I bet it would have made relativity easier.
Indeed, this isn't going to happen anytime soon.
The thing with geometric algebra is that the function is the same regardless of what you're working with. In projective geometric algebra, joining two points into a line is the same function as joining a point and line into a plane. Intersections, projections, rejections, and transformations all have the same function, regardless of the objects involved. Reflecting across a plane, around a line, about a point, really any transformation, uses the same A * B / A, formula, regardless of whether B is a point, line, plane or transformation. You still need to learn it, but you only need to learn it once.
>I also think the more abstract you get, the smaller portion of the population can understand and work with it.
That's exactly the point. Geometric algebra is a large step down in abstraction from quaternions, yet explains them fully. The rules of geometric algebra build directly from vector algebra and could be taught in a single lecture, with several semesters worth of material in geometry, calculus and physics that follow from those simple rules. But the people who use quaternions already know quaternions, and the physicists who work with complex matrices already know complex matrices. They think they're standing on isolated towers of knowledge they had to scale by their own hard work, and see geometric algebra as a separate height that offers no advantage on its own, when it was actually a shallower ascent, that once climbed, reveals that what had appeared to be distinct areas of study were actually linked and could be understood together.
Projective geometry and special relativity might seem like different subjects from the outside, or from within either, but when viewed from geometric algebra, they're just algebras with different signatures (whether the basis vectors square to 1, -1, or 0). A Lorentz transformation is little different than rotation around a line, and if you can work with one, your knowledge transfers directly to the other. All built from the building blocks of vectors, no complex matrices or generators required.
That is not really the reason. Relevant trivia: that cross product is defined only in dimensions 3 and 7 (not only in 3) has to do with existence of certain algebraic objects — division algebras — which only exist in dimensions 1 (reals), 2 (complex), 4 (quaternions), and 8 (octonions).
https://en.wikipedia.org/wiki/Seven-dimensional_cross_produc...
https://en.wikipedia.org/wiki/Hurwitz%27s_theorem_(compositi...
You could say there is cross product in 1d by analogy, but of course it is always equal to 0.
I often use the cross product in 2d too, don't tell anybody.
Before doing that I was always very firmly in the visual/geometric side of the spectrum (vs the abstract/algebraic side) of understanding math and physics but the geometric algebra taught me the value of algebraic modes of thinking.
Example: Two boxes are in contact face to face. Think two 2x4s laying one on top of the other to form a cross. If I want to create a union of these objects, the surfaces that are in contact need to be cut into 3 areas each - one on each side of the other box, and a middle (contact) area that will be discarded. Where do I split the edges? Obviously where they intersect the plane of the other object. But the plane we need to intersect is the one parallel to the edge. We can often get away with splitting against the orthogonal plane, but only if it's a sharp edge. If it's rounded we end up with 3 surfaces all tangent at the intersection. So maybe I should look for edge-edge intersections. Right. But what if some code splits a line against a line, but another line is split against a plane? numerically these may be different results, but I know they should be the same point. I'm rambling because this is exactly a problem I was working on last night (aiming to fix a bug in Solvespace) and the solution has absolutely nothing to do with details like what abstraction is used to represent the geometric primitives, and everything to do with numerical precision and topological representations. These are the hard problems GA does not address.
Complex numbers cover SO(2). Useful for rotations in 2d.
Geometric algebra contains both of these and a bunch of others. Useful for generalizable operations in any number of dimensions.
As an example, you might be able to apply your intuition for quaternions to spacetime geometry.
My experience with learning complex numbers in an undergraduate electrical engineering class was that these were baffling mathematical objects that make the equations work, but understanding why or how was best left to the mathematicians. Names like "complex" and "imaginary" didn't help.
I would imagine that learning quaternions on their own would be similar. Quaternions are like complex number, but more so, and they have this i*j=k property that you just have to accept as part of how they operate. So you have this four-dimensional object that performs rotation in three dimensions, and that's just how it is.
The geometric algebra construction explains all of these mysterious properties and gives an intuitive algebraic and geometric sense for why they behave that way.
And this intuition extends beyond quaternions. Projective, conformal, and spacetime geometric algebras all have equivalent objects that behave differently but according to the same fundamental rules.
Offer to mentor other students who want to use it.
Write some clean libraries for others to use. Either charge for commercial use or use it to get a job in scientific, special computing or games.
Just random thoughts.
Use it to unify quantum mechanics and general relativity. GA simplifies the notation for both considerably.
That one might be a stretch!