Esempio n. 1
0
def main():
    #Get_Program()
    Format()

    #EM_Waves_in_Geom_Calculus_Complex()
    EM_Waves_in_Geom_Calculus_Real()
    xpdf()
    return
Esempio n. 2
0
def main():
    #Get_Program()
    Format()

    EM_Waves_in_Geom_Calculus()

    xpdf()
    return
Esempio n. 3
0
def main():
    Get_Program()
    Format()

    basic_multivector_operations_3D()
    basic_multivector_operations_2D()

    xpdf()
    return
Esempio n. 4
0
def main():
    Get_Program()
    Format()

    Maxwells_Equations_in_Geom_Calculus()
    Dirac_Equation_in_Geog_Calculus()
    Lorentz_Tranformation_in_Geog_Algebra()

    xpdf()
    return
Esempio n. 5
0
def main():
    Get_Program()
    Format()
    """
    The uncommented examples take about 3'20" to run on an i7 in turbo
    mode (3.8 GHz).  I have never waited long enough to run the commented
    out examples.
    """
    derivatives_in_spherical_coordinates()
    derivatives_in_paraboloidal_coordinates()
    derivatives_in_elliptic_cylindrical_coordinates()
    derivatives_in_prolate_spheroidal_coordinates()
    #derivatives_in_oblate_spheroidal_coordinates()
    #derivatives_in_bipolar_coordinates()
    #derivatives_in_toroidal_coordinates()

    xpdf(paper=(20,11))
    return
Esempio n. 6
0
def main():
    Get_Program()

    Format()
    basic_multivector_operations_3D()
    basic_multivector_operations_2D()
    basic_multivector_operations_2D_orthogonal()
    check_generalized_BAC_CAB_formulas()
    rounding_numerical_components()
    derivatives_in_rectangular_coordinates()
    derivatives_in_spherical_coordinates()
    noneuclidian_distance_calculation()
    conformal_representations_of_circles_lines_spheres_and_planes()
    properties_of_geometric_objects()
    extracting_vectors_from_conformal_2_blade()
    reciprocal_frame_test()

    xpdf()
    return
Esempio n. 7
0
print '#2d general ($A,\\;B$ are linear transformations)'
A2d = g2d.lt('A')
print 'A =', A2d
print '\\f{\\det}{A} =', A2d.det()
#A2d.adj().Fmt(4,'\\overline{A}')
print '\\f{\\Tr}{A} =', A2d.tr()
print '\\f{A}{e_u^e_v} =', A2d(eu^ev)
print '\\f{A}{e_u}^\\f{A}{e_v} =', A2d(eu)^A2d(ev)
B2d = g2d.lt('B')
print 'B =', B2d
print 'A + B =', A2d + B2d
print 'AB =', A2d * B2d
print 'A - B =', A2d - B2d
a = g2d.mv('a','vector')
b = g2d.mv('b','vector')
print r'a|\f{\overline{A}}{b}-b|\f{\underline{A}}{a} =',((a|A2d.adj()(b))-(b|A2d(a))).simplify()

print '#4d Minkowski spaqce (Space Time)'
m4d = Ga('e_t e_x e_y e_z', g=[1, -1, -1, -1],coords=symbols('t,x,y,z',real=True))
T = m4d.lt('T')
print 'g =', m4d.g
print r'\underline{T} =',T
print r'\overline{T} =',T.adj()
#m4d.mv(T.det()).Fmt(4,r'\f{\det}{\underline{T}}')
print r'\f{\mbox{tr}}{\underline{T}} =',T.tr()
a = m4d.mv('a','vector')
b = m4d.mv('b','vector')
print r'a|\f{\overline{T}}{b}-b|\f{\underline{T}}{a} =',((a|T.adj()(b))-(b|T(a))).simplify()
xpdf(paper='landscape')
Esempio n. 8
0
import sys
from sympy import symbols,sin,cos
from sympy.galgebra.printer import Format,xpdf,Get_Program,Print_Function
from sympy.galgebra.ga import Ga

Format()
coords = symbols('t x y z',real=True)
(st4d,g0,g1,g2,g3) = Ga.build('gamma*t|x|y|z',g=[1,-1,-1,-1],coords=coords)
I = st4d.i

(m,e) = symbols('m e')

psi = st4d.mv('psi','spinor',f=True)
A = st4d.mv('A','vector',f=True)
sig_z = g3*g0

print '\\text{4-Vector Potential\\;\\;}\\bm{A} =',A
print '\\text{8-component real spinor\\;\\;}\\bm{\\psi} =',psi

dirac_eq = (st4d.grad*psi)*I*sig_z-e*A*psi-m*psi*g0
dirac_eq = dirac_eq.simplify()

dirac_eq.Fmt(3,r'%\text{Dirac Equation\;\;}\nabla \bm{\psi}'+\
               r' I \sigma_{z}-e\bm{A}\bm{\psi}-m\bm{\psi}\gamma_{t} = 0')
xpdf(paper='landscape',prog=True)
Esempio n. 9
0
w = E2 | e1
w = w.expand()
print "E2|e1 =", w

w = E2 | e3
w = w.expand()
print "E2|e3 =", w

w = E3 | e1
w = w.expand()
print "E3|e1 =", w

w = E3 | e2
w = w.expand()
print "E3|e2 =", w

w = E1 | e1
w = (w.expand()).scalar()
Esq = expand(Esq)
print "%(E1\\cdot e1)/E^{2} =", simplify(w / Esq)

w = E2 | e2
w = (w.expand()).scalar()
print "%(E2\\cdot e2)/E^{2} =", simplify(w / Esq)

w = E3 | e3
w = (w.expand()).scalar()
print "%(E3\\cdot e3)/E^{2} =", simplify(w / Esq)

xpdf(paper="letter")
Esempio n. 10
0
print '\\f{\\det}{A} =', A2d.det()
print '\\f{\\Tr}{A} =', A2d.tr()

B2d = g2d.lt('B')

print 'B =', B2d
print 'A + B =', A2d + B2d
print 'AB =', A2d * B2d
print 'A - B =', A2d - B2d

a = g2d.mv('a','vector')
b = g2d.mv('b','vector')

print r'a|\f{\overline{A}}{b}-b|\f{\underline{A}}{a} =',((a|A2d.adj()(b))-(b|A2d(a))).simplify()

m4d = Ga('e_t e_x e_y e_z', g=[1, -1, -1, -1],coords=symbols('t,x,y,z',real=True))

T = m4d.lt('T')

print '#$T$ is a linear transformation in Minkowski space'
print r'\underline{T} =',T
print r'\overline{T} =',T.adj()
print r'\f{\mbox{tr}}{\underline{T}} =',T.tr()

a = m4d.mv('a','vector')
b = m4d.mv('b','vector')

print r'a|\f{\overline{T}}{b}-b|\f{\underline{T}}{a} =',((a|T.adj()(b))-(b|T(a))).simplify()

xpdf(paper='landscape',crop=True)
Esempio n. 11
0
    print 'grad*F =',grad_uv * F

    tp = (th,phi) = symbols('theta,phi',real=True)

    smap = [sin(th)*cos(phi),sin(th)*sin(phi),cos(th)]

    sph2dr = o3d.sm(smap,tp,norm=True)
    (eth, ephi) = sph2dr.mv()
    grad_tp = sph2dr.grad

    F = sph2dr.mv('F','vector',f=True)
    f = sph2dr.mv('f','scalar',f=True)

    print 'f =',f
    print 'grad*f =',grad_tp * f

    print 'F =',F
    print 'grad*F =',grad_tp * F

    return

def dummy():
    return

if __name__ == "__main__":

    Format()
    Get_Program()
    main()
    xpdf(paper=(22,11))
Esempio n. 12
0
def main():
    Format()
    (g3d,ex,ey,ez) = Ga.build('e*x|y|z')
    A = g3d.mv('A','mv')
    print r'\bm{A} =',A
    A.Fmt(2,r'\bm{A}')
    A.Fmt(3,r'\bm{A}')

    X = (x,y,z) = symbols('x y z',real=True)
    o3d = Ga('e_x e_y e_z',g=[1,1,1],coords=X)
    (ex,ey,ez) = o3d.mv()

    f = o3d.mv('f','scalar',f=True)
    A = o3d.mv('A','vector',f=True)
    B = o3d.mv('B','bivector',f=True)

    print r'\bm{A} =',A
    print r'\bm{B} =',B

    print 'grad*f =',o3d.grad*f
    print r'grad|\bm{A} =',o3d.grad|A
    print r'grad*\bm{A} =',o3d.grad*A

    print r'-I*(grad^\bm{A}) =',-o3d.i*(o3d.grad^A)
    print r'grad*\bm{B} =',o3d.grad*B
    print r'grad^\bm{B} =',o3d.grad^B
    print r'grad|\bm{B} =',o3d.grad|B

    g4d = Ga('a b c d')

    (a,b,c,d) = g4d.mv()

    print 'g_{ij} =',g4d.g

    print '\\bm{a|(b*c)} =',a|(b*c)
    print '\\bm{a|(b^c)} =',a|(b^c)
    print '\\bm{a|(b^c^d)} =',a|(b^c^d)
    print '\\bm{a|(b^c)+c|(a^b)+b|(c^a)} =',(a|(b^c))+(c|(a^b))+(b|(c^a))
    print '\\bm{a*(b^c)-b*(a^c)+c*(a^b)} =',a*(b^c)-b*(a^c)+c*(a^b)
    print '\\bm{a*(b^c^d)-b*(a^c^d)+c*(a^b^d)-d*(a^b^c)} =',a*(b^c^d)-b*(a^c^d)+c*(a^b^d)-d*(a^b^c)
    print '\\bm{(a^b)|(c^d)} =',(a^b)|(c^d)
    print '\\bm{((a^b)|c)|d} =',((a^b)|c)|d
    print '\\bm{(a^b)\\times (c^d)} =',Com(a^b,c^d)

    g = '1 # #,'+ \
         '# 1 #,'+ \
         '# # 1'

    ng3d = Ga('e1 e2 e3',g=g)
    (e1,e2,e3) = ng3d.mv()

    E = e1^e2^e3
    Esq = (E*E).scalar()
    print 'E =',E
    print '%E^{2} =',Esq
    Esq_inv = 1/Esq

    E1 = (e2^e3)*E
    E2 = (-1)*(e1^e3)*E
    E3 = (e1^e2)*E

    print 'E1 = (e2^e3)*E =',E1
    print 'E2 =-(e1^e3)*E =',E2
    print 'E3 = (e1^e2)*E =',E3

    print 'E1|e2 =',(E1|e2).expand()
    print 'E1|e3 =',(E1|e3).expand()
    print 'E2|e1 =',(E2|e1).expand()
    print 'E2|e3 =',(E2|e3).expand()
    print 'E3|e1 =',(E3|e1).expand()
    print 'E3|e2 =',(E3|e2).expand()
    w = ((E1|e1).expand()).scalar()
    Esq = expand(Esq)
    print '%(E1\\cdot e1)/E^{2} =',simplify(w/Esq)
    w = ((E2|e2).expand()).scalar()
    print '%(E2\\cdot e2)/E^{2} =',simplify(w/Esq)
    w = ((E3|e3).expand()).scalar()
    print '%(E3\\cdot e3)/E^{2} =',simplify(w/Esq)

    X = (r,th,phi) = symbols('r theta phi')
    s3d = Ga('e_r e_theta e_phi',g=[1,r**2,r**2*sin(th)**2],coords=X,norm=True)
    (er,eth,ephi) = s3d.mv()

    f = s3d.mv('f','scalar',f=True)
    A = s3d.mv('A','vector',f=True)
    B = s3d.mv('B','bivector',f=True)

    print 'A =',A
    print 'B =',B

    print 'grad*f =',s3d.grad*f
    print 'grad|A =',s3d.grad|A
    print '-I*(grad^A) =',-s3d.i*(s3d.grad^A)
    print 'grad^B =',s3d.grad^B

    coords = symbols('t x y z')
    m4d = Ga('gamma*t|x|y|z',g=[1,-1,-1,-1],coords=coords)
    (g0,g1,g2,g3) = m4d.mv()
    I = m4d.i

    B = m4d.mv('B','vector',f=True)
    E = m4d.mv('E','vector',f=True)
    B.set_coef(1,0,0)
    E.set_coef(1,0,0)
    B *= g0
    E *= g0
    J = m4d.mv('J','vector',f=True)
    F = E+I*B

    print 'B = \\bm{B\\gamma_{t}} =',B
    print 'E = \\bm{E\\gamma_{t}} =',E
    print 'F = E+IB =',F
    print 'J =',J
    gradF = m4d.grad*F
    gradF.Fmt(3,'grad*F')

    print 'grad*F = J'
    (gradF.get_grade(1)-J).Fmt(3,'%\\grade{\\nabla F}_{1} -J = 0')
    (gradF.get_grade(3)).Fmt(3,'%\\grade{\\nabla F}_{3} = 0')

    (alpha,beta,gamma) = symbols('alpha beta gamma')

    (x,t,xp,tp) = symbols("x t x' t'")
    m2d = Ga('gamma*t|x',g=[1,-1])
    (g0,g1) = m2d.mv()

    R = cosh(alpha/2)+sinh(alpha/2)*(g0^g1)
    X = t*g0+x*g1
    Xp = tp*g0+xp*g1
    print 'R =',R

    print r"#%t\bm{\gamma_{t}}+x\bm{\gamma_{x}} = t'\bm{\gamma'_{t}}+x'\bm{\gamma'_{x}} = R\lp t'\bm{\gamma_{t}}+x'\bm{\gamma_{x}}\rp R^{\dagger}"

    Xpp = R*Xp*R.rev()
    Xpp = Xpp.collect()
    Xpp = Xpp.trigsimp()
    print r"%t\bm{\gamma_{t}}+x\bm{\gamma_{x}} =",Xpp
    Xpp = Xpp.subs({sinh(alpha):gamma*beta,cosh(alpha):gamma})

    print r'%\f{\sinh}{\alpha} = \gamma\beta'
    print r'%\f{\cosh}{\alpha} = \gamma'

    print r"%t\bm{\gamma_{t}}+x\bm{\gamma_{x}} =",Xpp.collect()

    coords = symbols('t x y z')
    m4d = Ga('gamma*t|x|y|z',g=[1,-1,-1,-1],coords=coords)
    (g0,g1,g2,g3) = m4d.mv()
    I = m4d.i
    (m,e) = symbols('m e')

    psi = m4d.mv('psi','spinor',f=True)
    A = m4d.mv('A','vector',f=True)
    sig_z = g3*g0
    print '\\bm{A} =',A
    print '\\bm{\\psi} =',psi

    dirac_eq = (m4d.grad*psi)*I*sig_z-e*A*psi-m*psi*g0
    dirac_eq.simplify()

    dirac_eq.Fmt(3,r'\nabla \bm{\psi} I \sigma_{z}-e\bm{A}\bm{\psi}-m\bm{\psi}\gamma_{t} = 0')

    xpdf()
    return
Esempio n. 13
0
print '#2d general ($A,\\;B$ are linear transformations)'
A2d = g2d.lt('A')
print 'A =', A2d
print '\\f{\\det}{A} =', A2d.det()
#A2d.adj().Fmt(4,'\\overline{A}')
print '\\f{\\Tr}{A} =', A2d.tr()
print '\\f{A}{e_u^e_v} =', A2d(eu^ev)
print '\\f{A}{e_u}^\\f{A}{e_v} =', A2d(eu)^A2d(ev)
B2d = g2d.lt('B')
print 'B =', B2d
print 'A + B =', A2d + B2d
print 'AB =', A2d * B2d
print 'A - B =', A2d - B2d
a = g2d.mv('a','vector')
b = g2d.mv('b','vector')
print r'a|\f{\overline{A}}{b}-b|\f{\underline{A}}{a} =',((a|A2d.adj()(b))-(b|A2d(a))).simplify()

print '#4d Minkowski spaqce (Space Time)'
m4d = Ga('e_t e_x e_y e_z', g=[1, -1, -1, -1],coords=symbols('t,x,y,z',real=True))
T = m4d.lt('T')
print 'g =', m4d.g
print r'\underline{T} =',T
print r'\overline{T} =',T.adj()
#m4d.mv(T.det()).Fmt(4,r'\f{\det}{\underline{T}}')
print r'\f{\mbox{tr}}{\underline{T}} =',T.tr()
a = m4d.mv('a','vector')
b = m4d.mv('b','vector')
print r'a|\f{\overline{T}}{b}-b|\f{\underline{T}}{a} =',((a|T.adj()(b))-(b|T(a))).simplify()
xpdf(paper=(10,12))
Esempio n. 14
0
from sympy import symbols, sin
from sympy.galgebra.printer import Format, xpdf
from sympy.galgebra.ga import Ga

Format()

X = (r,th,phi) = symbols('r theta phi')
s3d = Ga('e_r e_theta e_phi',g=[1,r**2,r**2*sin(th)**2],coords=X,norm=True)
(er,eth,ephi) = s3d.mv()
grad = s3d.grad

f = s3d.mv('f','scalar',f=True)
A = s3d.mv('A','vector',f=True)
B = s3d.mv('B','bivector',f=True)

print 'f =',f
print 'A =',A
print 'B =',B

print 'grad*f =',grad*f
print 'grad|A =',grad|A
print '-I*(grad^A) =',(-s3d.i*(grad^A)).simplify()
print 'grad^B =',grad^B

xpdf(paper='letter')
Esempio n. 15
0
        self.Fij = []
        self.Ki = []
        for i in range(n):
            self.Ki.append(self.e[i] * self.ebar[i])
            print r'%F_{'+str(i)+'} =',self.Ki[-1] * self.Ki[-1].rev()
            for j in range(i):
                self.Eij.append(self.e[i] * self.e[j] - self.ebar[i] * self.ebar[j])
                self.Fij.append(self.e[i] * self.ebar[j] - self.ebar[i] * self.e[j])
                print r'%E_{'+str(i)+str(j)+'} =',self.Eij[-1] * self.Eij[-1].rev()
                print r'%F_{'+str(i)+str(j)+'} =',self.Fij[-1] * self.Fij[-1].rev()

        print 'K_{i} =',self.Ki
        print 'E_{ij} =',self.Eij
        print 'F_{ij} =',self.Fij

        E = self.Eij[0]/2

        for i in range(2*n):
            print E
            E *= self.Eij[0]/2



if __name__ == "__main__":

    Format()
    la = LieAlgebra(6)
    print la.e
    print la.ebar
    xpdf()
Esempio n. 16
0
Format()
coords = (r, th, phi) = symbols('r,theta,phi', real=True)
sp3d = Ga('e_r e_th e_ph', g=[1, r**2, r**2*sin(th)**2], \
       coords=coords, norm=True)

sph_uv = (u, v) = symbols('u,v', real=True)
sph_map = [1, u, v]  # Coordinate map for sphere of r = 1
sph2d = sp3d.sm(sph_map,sph_uv)

print r'(u,v)\rightarrow (r,\theta,\phi) = ',latex(sph_map)
print 'g =',latex(sph2d.g)
F = sph2d.mv('F','vector',f=True) #scalar function
f = sph2d.mv('f','scalar',f=True) #vector function
print r'\nabla f =',sph2d.grad * f
print 'F =',F
print r'\nabla F = ',sph2d.grad * F

cir_s = s = symbols('s',real=True)
cir_map = [pi/8,s]
cir1d = sph2d.sm(cir_map,(cir_s,))

print 'g =',latex(cir1d.g)
h = cir1d.mv('h','scalar',f=True)
H = cir1d.mv('H','vector',f=True)
print r'(s)\rightarrow (u,v) = ',latex(cir_map)
print 'H =', H
print latex(H)
print r'\nabla h =', cir1d.grad * h
print r'\nabla H =', cir1d.grad * H
xpdf(filename='submanifold.tex',paper=(6,5),crop=True)
Esempio n. 17
0
import sys
from sympy import symbols,sin
from sympy.galgebra.printer import Format,xpdf
from sympy.galgebra.ga import Ga

Format()
X = (r,th,phi) = symbols('r theta phi')
s3d = Ga('e_r e_theta e_phi',g=[1,r**2,r**2*sin(th)**2],coords=X,norm=True)
(er,eth,ephi) = s3d.mv()
grad = s3d.grad

f = s3d.mv('f','scalar',f=True)
A = s3d.mv('A','vector',f=True)
B = s3d.mv('B','bivector',f=True)

print 'f =',f
print 'A =',A
print 'B =',B

print 'grad*f =',grad*f
print 'grad|A =',grad|A
print '-I*(grad^A) =',(-s3d.i*(grad^A)).simplify()
print 'grad^B =',grad^B
print r'%\nabla\cdot\lp\nabla f\rp =', s3d.grad|(s3d.grad*f)
xpdf(paper='letter',prog=True)
Esempio n. 18
0
File: Dop.py Progetto: brombo/sympy
print r'grad =', o3d.grad
print r'%\nabla^{2} = \nabla\cdot\nabla =', lap
print r'%\lp\nabla^{2}\rp f =', lap*f
print r'%\nabla\cdot\lp\nabla f\rp =', o3d.grad | (o3d.grad * f)

sph_coords = (r, th, phi) = symbols('r theta phi', real=True)
(sp3d, er, eth, ephi) = Ga.build('e', g=[1, r**2, r**2 * sin(th)**2], coords=sph_coords, norm=True)
f = sp3d.mv('f', 'scalar', f=True)
lap = sp3d.grad*sp3d.grad
print r'%\nabla =', sp3d.grad
print r'%\nabla^{2} = \nabla\cdot\nabla =', lap
print r'%\lp\nabla^{2}\rp f =', lap*f
print r'%\nabla\cdot\lp\nabla f\rp =', sp3d.grad | (sp3d.grad * f)
A = o3d.mv('A','vector')
K = o3d.mv('K','vector')
xs = o3d.mv(x)
X = o3d.X()

print o3d.grad*A
print A*o3d.grad
print o3d.grad*xs
print xs*o3d.grad
print o3d.grad*(o3d.grad+xs)
print (o3d.grad+xs)*o3d.grad

print X
print X^o3d.grad
print (X^o3d.grad).components()

xpdf(filename='prod.tex')
Esempio n. 19
0
File: Dop.py Progetto: brombo/sympy
Format()
coords = (x, y, z) = symbols("x y z", real=True)
(o3d, ex, ey, ez) = Ga.build("e*x|y|z", g=[1, 1, 1], coords=coords)
X = x * ex + y * ey + z * ez
I = o3d.i
v = o3d.mv("v", "vector")
f = o3d.mv("f", "scalar", f=True)
A = o3d.mv("A", "vector", f=True)
dd = v | o3d.grad
lap = o3d.grad * o3d.grad
print r"\bm{X} =", X
print r"\bm{v} =", v
print r"\bm{A} =", A
print r"%\bm{v}\cdot\nabla =", dd
print r"%\nabla^{2} =", lap
print r"%\bm{v}\cdot\nabla f =", dd * f
print r"%\nabla^{2} f =", lap * f
print r"%\nabla^{2} \bm{A} =", lap * A
print r"%\bar{\nabla}\cdot v =", o3d.rgrad | v
Xgrad = X | o3d.grad
rgradX = o3d.rgrad | X
sph_coords = (r, th, phi) = symbols("r theta phi", real=True)
(sp3d, er, eth, ephi) = Ga.build("e", g=[1, r ** 2, r ** 2 * sin(th) ** 2], coords=sph_coords, norm=True)
f = sp3d.mv("f", "scalar", f=True)
lap = sp3d.grad * sp3d.grad
print r"%\nabla^{2} = \nabla\cdot\nabla =", lap
print r"%\lp\nabla^{2}\rp f =", lap * f
print r"%\nabla\cdot\lp\nabla f\rp =", sp3d.grad | (sp3d.grad * f)
xpdf(paper="landscape", crop=True)
Esempio n. 20
0
File: GLG.py Progetto: brombo/sympy
    return

Format()

(glg,ei,ej,em,en,ebi,ebj,ebm,ebn) = Ga.build(r'e_i e_j e_k e_l \bar{e}_i \bar{e}_j \bar{e}_k \bar{e}_l',g=[1,1,1,1,-1,-1,-1,-1])

e = {'i':ei,'j':ej,'k':em,'l':en}
eb = {'i':ebi,'j':ebj,'k':ebm,'l':ebn}

print r'#\center{General Linear Group of Order $n$\newline}'
print r'#Lie Algebra Generators: $1\le i < j \le n$ and $1 \le i < l \le n$'

Eij = E('i','j')
Fij = F('i','j')
Ki = K('i')
Eil = E('i','l')
Fil = F('i','l')

print r'#Non Zero Commutators'

ComP(Eij,Fij)
ComP(Eij,Ki)
ComP(Fij,Ki)
ComP(Eij,Eil)
ComP(Fij,Fil)
ComP(Fij,Eil)

xpdf(paper='letter',pt='12pt',debug=True,prog=True)