digitaldomain / Multivectors.jl

Multivectors for geometric algebra
Other
24 stars 3 forks source link

wedge malfunction with e3 ∧ e1 #4

Closed peeterjoot closed 2 years ago

peeterjoot commented 2 years ago

Ran:

using Multivectors;

@generate_basis("+++", true) # generate blades for euclidean 3D-space

e1 = e₁ e2 = e₂ e3 = e₃

e1 ∧ e2 e2 ∧ e3 e3 ∧ e1 e1 ∧ e3

This produced:

julia> using Multivectors;

julia> @generate_basis("+++", true) # generate blades for euclidean 3D-space

julia> e1 = e₁ e₁

julia> e2 = e₂ e₂

julia> e3 = e₃ e₃

julia> e1 ∧ e2 e₁₂

julia> e2 ∧ e3 e₂₃

julia> e3 ∧ e1 Nothing

julia> e1 ∧ e3 e₁₃

I expected:

-e₁₃

Not 'Nothing' for e3 ∧ e1.

moble commented 2 years ago

Not solving the problem, but hopefully some useful info. Technically, this is documented behavior — though I agree it's surprising and undesirable.

Note that typeof(e1), etc., is UnionAll, which is not a type we want to see very often. In any case, we find the specific wedge function that gets called here, and it does indeed state that "indices must be in acending order". That function just calls the * function directly above it, which returns Nothing if the indices are not in ascending order, which is why you see what you see.

What you've done here seems like one of the most natural things you could want to do with a GA package, so it seems like room for improvement. However, also note that multiplying these basis elements by a number gives you more useful things:

julia> 1e₃ ∧ 1e₂
-1e₂₃

Also note that e1, etc., are not the handiest names for these variables, since 1e1 is parsed as 10.0, 1e2 as 100.0, etc. So you'd have to say 1*e1 — but * has lower precedence than , so you'd have to write this as

julia> (1*e3) ∧ (1*e2)
-1e₂₃
peeterjoot commented 2 years ago

Thanks Mike. I've submitted a pull request with a trivial adjustment to the docs to clarify.