chakravala / Grassmann.jl

⟨Grassmann-Clifford-Hodge⟩ multilinear differential geometric algebra

Home Page:https://grassmann.crucialflow.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inverse of vectors with negative square

karlwessel opened this issue · comments

The inverse of a vector a works like expected for vectors with positive square a² > 0 in the way that baa⁻¹ = b:

julia> using Grassmann

julia> basis"-+++"
(⟨-+++⟩, v, v₁, v₂, v₃, v₄, v₁₂, v₁₃, v₁₄, v₂₃, v₂₄, v₃₄, v₁₂₃, v₁₂₄, v₁₃₄, v₂₃₄, v₁₂₃₄)

julia> v2^2
v

julia> v1*v2*inv(v2), v1
(v₁, v₁)

It however does not give the correct result, I think, for vectors with negative square a² < 0:

julia> v1^2
-1v

julia> v2*v1*inv(v1), v2
(-1v₂, v₂)

The inverse should be negative, according to the formula I am using

julia> (~v1)/((~v1)v1)
-1.0v₁

However, the formula for Basis elements is a more simple variant and doesn't take the whole formula into account yet. That can be fixed easily by just using the formula above.

It is fixed now, but I think the same problem also exists for SValue (and MValue?):

julia> a = 2v1
2v₁

julia> typeof(a)
SValue{⟨-+⟩,1,v₁,Int64}

julia> v2*a*inv(a), v2
(-1.0v₂, v₂)

Now the error is gone, but it is still not the expected result:

julia> using Test

julia> @test v2*(a*inv(a)) == v2
Test Failed at REPL[14]:1
  Expression: v2 * (a * inv(a)) == v2
   Evaluated: 2.0v₂ == v₂
ERROR: There was an error during testing