
Geometric Algebra for Python - alex_hirner
https://github.com/pygae/clifford
======
hugohadfield
Hi everyone, I'm Hugo one of the maintainers of this package, glad to see lots
of interest! If anyone is interested in some of the applications of GA in
robotics etc then check out the talk Eric and I gave at GAME2020 back in
February
[https://www.youtube.com/watch?v=bj9JslblYPU](https://www.youtube.com/watch?v=bj9JslblYPU)

~~~
dbcurtis
A few months back I made an effort to learn GA. I did get some traction, but
eventually shelved the effort. The thing that put me off is that no one could
explain how to do units analysis in GA. I am mainly interested in physics and
engineering applications, especially robotics and also RF engineering to some
extent. Without being able to see how dimensions combine in GA, I have zero
confidence in the correctness of my results. Arithmetic without dimensional
analysis is not physics. Full. Stop.

So, if you could point to any resources that show how to properly dimension GA
values, and how GA operators combine dimensions, that would get me started on
GA again.

~~~
jacobolus
The units work just how you’d expect; as far as I can tell there’s nothing new
or unique about units in GA.

If you multiply two vectors with units of meters, you get a scalar + a
bivector, both with units of square meters.

If you divide two vectors with units of meters, you get a scalar + a bivector
which are both dimensionless.

Etc.

~~~
sixo
What are units of the geometric product of two vectors?

Edit: didn't read clearly. Better question is why would we want to have a
scalar with units of square meters in this case? Shouldn't 0-grade objects all
have the same units?

~~~
jwmerrill
> Shouldn't 0-grade objects all have the same units?

No, and this is a really important point. Scalars can have any units. For
example, you can have a scalar with units of time, or mass, and you can take
the dot product of a force vector and a displacement vector to get a scalar
with units of [force]·[distance] = [work].

If you instead form the wedge product of those vectors, you get a bivector
with the same units: [force]·[distance] = [torque] (note that the units of
[work], [torque], and [energy] are all the same).

If you take the geometric product of a force vector and a displacement vector,
the result is the sum of a scalar and a bivector, both with the same units of
[force]·[distance].

~~~
a1369209993
> If you take the geometric product of a force vector and a displacement
> vector, the result is the sum of a scalar and a bivector, both with the same
> units of [force]·[distance].

This part is where I have problem with GA: what the hell is the physical[0]
interpretation of such a sum? For example, a four-vector <p_x,p_y,p_z,c·E_k>
(momentum and kinetic energy) can be thought of as kinetic energy being the
temporal component of (4-)momentum, but no similar interpretation seems viable
to combine work and torque into a logically unified quantity.

0: I'm not sure if this is the right word - the interpretation as single
unified value with no special-case treatment of its components might be
another, equally not-quite-right way of putting it.

~~~
jacobolus
The physical interpretation depends on context, but the concrete arithmetic is
the same whether you write it using GA language or some other mathematical
formalism (matrices, Gibbs–Heaviside style vectors, differential forms,
tensors, complex numbers, ...), so if you have a problem with it your problem
is with the physics.

Like with any expressive language (e.g. English, C++, or matrix algebra), GA
makes it possible to state a wide variety of nonsensical things. But that’s
not the fault of the language.

Where GA really shines IMO is in the ability to divide by vectors, something
that is extremely useful but gets super cumbersome using other mathematical
languages.

The biggest “problem” I have with GA is that it takes a lot of practice to get
familiarity with all of the powerful stuff it can do. There are pages and
pages of (extremely powerful and useful) short identities which are impossible
to memorize by just looking at them, and can only be learned as far as I can
tell through years of hard-won experience. I feel like I still only really
have a handle on the most basic stuff.

I find regularly myself working on some complicated coordinate-based
calculation for 3 pages of scratch paper full of mistakes and wrong turns,
only to experience déjà vu, re-express the original thing in GA language, and
end up with a clear and geometrically interpretable 4 lines of simple
algebraic identities which solve the problem. But I’m not always sure if I’d
be able to figure out which 4 lines to use right off the bat, without first
going through the coordinate slog.

~~~
a1369209993
> some complicated coordinate-based calculation

Isn't that just what distinguishing scalar/vector/bivector/trivector/etc is
for? I don't have problems with coordinates because I don't bother with
coordinate-based calculations in the first place. What I don't get is how
adding two multivectors of different [ranks? eg scalar + bivector] is supposed
to simplify anything.

> > > the geometric product [...] is the sum of a scalar and a bivector

> any expressive language [...] makes it possible to state a wide variety of
> nonsensical things.

Yes, but if _everything_ the language makes it possible to state is
nonsensical, then what's the point?

I assume there's _some_ sort of point to geometric algebra, but I have yet to
encounter any convincing explanation of what that point is, and why I
shouldn't keep my dot and wedge products properly separated.

~~~
jacobolus
I just said that for many single calculations, GA has saved me literally hours
of headaches, in addition to making the result dramatically clearer and more
insightful.

Nobody is going to force you to try something you don’t want to try. I don’t
think I’ll be able to convince you.

~~~
a1369209993
> I just said that for many single calculations, GA has saved me literally
> hours of headaches, in addition to making the result dramatically clearer
> and more insightful.

Er, right; I was[0] asking for a example of a such a dramatically clearer and
more insightful result, relative to just using normal dot and wedge products.
_Using vectors at all_ saves hours of headaches if all it's being compared to
is coordinate-based calculations.

0: Well, the comment before that one was asking about the _interpretation_ of
the geometric product.

------
francasso
I don't understand the "geometric algebra" goal. The people that I've seen
pushing for it usually say kids in high school are being taught the wrong
thing, we should do away with the cross product and start teaching this
geometric algebra. I'm not too familiar with the content, but to a superficial
look it seems they are just using exterior algebras and (maybe?) clifford
algebras? Assuming that is the case then why the rebranding (and sometime
change of standard notation) to "geometric algebra" for concepts that already
had a name at the end of the nineteenth century (that is bound to piss the
general math community off)? Also why are people so against teaching the cross
product? There are many reasons why Hodge duality is important, not just in
abstract math but also in physics (it enables the most geometric definition of
Maxwell equations for example)

~~~
greggman3
AFAICT the proponents of GA claim it explains lots of things that don't make a
whole lot of sense without it.

One example is why you multiply normals by the world_inverse_tranpose.
Apparently the reason is because normals are actually bivectors, not
directional vectors as they are usually explained.

another is that at least in code, they apparently solve lots of issues that
other methods don't

See:
[https://marctenbosch.com/quaternions/](https://marctenbosch.com/quaternions/)

[https://marctenbosch.com/quaternions/code.htm](https://marctenbosch.com/quaternions/code.htm)

and: [https://bivector.net/](https://bivector.net/)

and
[https://www.youtube.com/watch?v=tX4H_ctggYo](https://www.youtube.com/watch?v=tX4H_ctggYo)

~~~
MiroF
> One example is why you multiply normals by the world_inverse_tranpose

I know linear algebra but I have no idea what the heck this means. Is this a
gaming thing?

~~~
sixo
Computer graphics. When transforming a coordinate system by a linear
transformation represented by a matrix, normal vectors to surfaces transform
differently than regular vectors. GA/exterior algebra explains this: the
useful thing we call normals is represented by the same data (a 3d vector) but
actually has to have a a different "type" to make sense. In higher dimensions
they are not interchangeable with vectors.

~~~
MiroF
Ah gotcha, why don't bivectors transform normally

e: I'm restating the question in a form I understand, not asking it.

~~~
ogogmad
If T:V->V is a linear transformation and "^" is the exterior product then
T(u^v)=T(u)^T(v).

For example, let T be a reflection about the plane spanned by e1 and e2. Then
T(e1^e2)=e1^e2, but T(e1 x e2) = -e1 x e2, where "x" denotes the cross
product.

~~~
MiroF
I should have been clear, I was restating their question, not asking it again.

------
sago
It's great to see some geometric algebra.

But I'm not quite sure what the package is for.

Is it for playing with geometric algebra? It is really rather simple to
implement geometric algebra. As easy as understanding the internals of this
package (which is not small for what it does). And in some ways a necessity
for understanding the math. Like I wouldn't expect someone to just use
quaternions and matrices to do 3-D, without learning how a matrix or
quaternion multiplies. And I wouldn't start with a package of dozens and
dozens of files in multiple directories, with a ton of inter-imports†.

So I'm assuming the package is for practical use, so it will be nice to see
what they envisage it for. The only example is a single trivial operation. I'm
aware it can be used for quantum physics. But my experience has been 3-D
graphics. And there it is very meh.

So my long-standing problem with geometric algebra in software engineering has
been... why? A frustration because it is a lot of fun.

My (imho) advice if you find it fun: you can write your own version in an
evening.

\---

† I wonder if packages are equivalent of books 20 years ago. I remember that
temptation to buy a book, as if that was how you acquired some knowledge. I
was guilty of that so many times. Now, want to get geometric algebra? There is
a package for that.

~~~
apricot
> I remember that temptation to buy a book, as if that was how you acquired
> some knowledge.

yeah... what foolish things we believed 20 years ago...

(tries not to look at the large pile of books accumulating dust in the corner
of the room)

~~~
wrycoder
Tsundoku

------
adamnemecek
You should check out the bivector community
[https://bivector.net/](https://bivector.net/).

Join the discord [https://discord.gg/vGY6pPk](https://discord.gg/vGY6pPk).

Check out a demo [https://observablehq.com/@enkimute/animated-
orbits](https://observablehq.com/@enkimute/animated-orbits)

------
Scene_Cast2
I work with ML. Even a dense vector can be relatively high-dimensional
(something like 128-D is common) I'd love to use Geometric / Clifford algebra
for rotations of these vectors; the notation is much more intuitive. However,
last time I tried using this library, it insists on generating all the
N-vectors, of which there's a combinatoral amount w.r.t. the number of
dimensions. For rotations, I really only need bivectors (IIRC)

Is there a way to use Geometric Algebra for higher dimensions?

~~~
hugohadfield
High dimensional GAs are a relatively hot topic of research but something we
haven't aimed to target with this library (mostly because its not our main
research area). My personal preference for working with high d algebras would
be Stéphane Breuils and Vincent Nozick's GARAMON library
([https://github.com/vincentnozick/garamon](https://github.com/vincentnozick/garamon))
([https://link.springer.com/article/10.1007/s00006-019-0987-7](https://link.springer.com/article/10.1007/s00006-019-0987-7)),
it is efficient and easy to use, and the authors are very friendly and
helpful. You could also try out TbGAL ([https://github.com/Prograf-
UFF/TbGAL](https://github.com/Prograf-UFF/TbGAL)), I haven't used it myself
but the work of the Leandro Fernandes is typically high quality.

------
nikivi
What are the applications of Geometric Algebra aside from computer graphics?

~~~
enkimute
The GAME2020 event (Geometric Algebra Mini Event) showcased applications in
graphics, physics, robotics, neural networks, mathematics. The lectures (from
Cambridge, UVA, UPEM, TU Delft, ..) are all available here :
[https://www.youtube.com/playlist?list=PLsSPBzvBkYjzcQ4eCVAnt...](https://www.youtube.com/playlist?list=PLsSPBzvBkYjzcQ4eCVAntETNNVD2d5S79)

~~~
SiempreViernes
"Mini Event" = several 1 hour long talks

Was hoping for more (time wise) digestible introductions.

------
markisus
If anyone wants to play around with the geometric algebra over R^3 in C++, I
wrote a little library a while back which handles vectors (3d), quaternions
(4d), bivectors (3d, quaternions without the scalar part), multivectors (8d)

[https://github.com/markisus/g3](https://github.com/markisus/g3)

------
DreamScatter
Please check out my geometric algebra software at
[https://github.com/chakravala/Grassmann.jl](https://github.com/chakravala/Grassmann.jl)

------
laurentoget
I find it fascinating that geometric algebra and algebraic geometry are two
distincts and totally different things and i wonder which term came first.

~~~
DreamScatter
haha, well they are both probably about equally old i believe.. i think the
two topics can be inter-related, but they are indeed separate areas of study
with different emphasis, and I don't believe that many algebraic geometers
know about the geometric algebra historically, since GA was quite obscure and
hard to utilize until computer algebra made it easier

~~~
laurentoget
whereas AG is just as obscure and hard to utilize, even with a computer...

------
OneGuy123
Geometric Algebra is useful because it's a generalization of complex number
and quaternions.

It explains complex numbers and quaternions intuitively.

~~~
gugagore
I agree with the first sentence.

But I don't think it's intuitive to learn about complex numbers through GA.
Complex numbers are a great jumping-off point to learn GA since it is simple
and most people eventually accept that the imaginary unit squares to -1, and
because complex numbers have a striking geometric interpretation.

But I feel almost certain that people should learn about the special case of
complex numbers before they ever learn about geometric algebra.

