This example is kindly contributed by FreddyBaudine for reproducing pygae/galgebra#15 with modifications by utensil.
In [1]:
import sys
from galgebra.printer import Format, xpdf, Fmt
Format()
from sympy import symbols, Rational, latex
from galgebra.ga import Ga
In [2]:
# st4: Spacetime Algebra I
st4coords = (t,x,y,z) = symbols('t x y z', real=True)
st4 = Ga('e_t e_x e_y e_z', g=[1,-1,-1,-1], coords=st4coords)
(e_t,e_x,e_y,e_z) = st4.mv()
(e__t,e__x,e__y,e__z) = st4.mvr(norm = False)
In [3]:
Format(Fmode = True, Dmode = True)
In [4]:
(grad,rgrad) = st4.grads()
In [5]:
s = st4.mv('s','scalar',f = True)
a = st4.mv('a','vector',f = True)
b = st4.mv('b','vector',f = True)
B = st4.mv('B','bivector',f = True)
C = st4.mv('C',3)
I = st4.mv('I','pseudo')
S = st4.mv('S','spinor',f = True)
M = st4.mv('M','mv',f = True)
M1inv = M.grade(1).inv()
M3inv = M.grade(3).inv()
In [6]:
a.Fmt(1,r'\mathbf{a}')
Out[6]:
In [7]:
(a*a).Fmt(2,r'\mathbf{a} \mathbf{a}')
Out[7]:
In [8]:
a.inv().Fmt(3,r'\mathbf{a}^{-1}')
Out[8]:
In [9]:
(M.grade(1) * M.grade(1)).\
Fmt(1,r'\langle \mathbf{M} \rangle _1 \langle \mathbf{M} \rangle _1')
Out[9]:
In [10]:
M1inv.Fmt(3,r'\langle \mathbf{M} \rangle _1 ^{-1}')
Out[10]:
In [11]:
M.grade(3).Fmt(2,r'\langle \mathbf{M} \rangle _3')
Out[11]:
In [12]:
(M.grade(3) * M.grade(3)).\
Fmt(1,r'\langle \mathbf{M} \rangle _3 \langle \mathbf{M} \rangle _3')
Out[12]:
In [13]:
M3inv.Fmt(3,r'\langle \mathbf{M} \rangle _3^{-1}')
Out[13]:
In [ ]: