def main(): Get_Program(True) Format() basic_multivector_operations_3D() basic_multivector_operations_2D() xdvi('simple_test_latex.tex') return
def main(): Get_Program() Format() Maxwells_Equations_in_Geometric_Calculus() Dirac_Equation_in_Geometric_Calculus() Lorentz_Tranformation_in_Geometric_Algebra() xdvi() return
def main(): Get_Program() Test_Reciprocal_Frame() Distorted_manifold_with_scalar_function() Simple_manifold_with_scalar_function_derivative() Simple_manifold_with_vector_function_derivative() #Plot_Mobius_Strip_Manifold() xdvi() return
def main(): Format() a = Matrix(2, 2, (1, 2, 3, 4)) b = Matrix(2, 1, (5, 6)) c = a * b print(a, b, '=', c) x, y = symbols('x, y') d = Matrix(1, 2, (x**3, y**3)) e = Matrix(2, 2, (x**2, 2 * x * y, 2 * x * y, y**2)) f = d * e print('%', d, e, '=', f) xdvi() return
def main(): Format() a = Matrix( 2, 2, ( 1, 2, 3, 4 ) ) b = Matrix( 2, 1, ( 5, 6 ) ) c = a * b print(a, b, '=', c) x, y = symbols( 'x, y' ) d = Matrix( 1, 2, ( x ** 3, y ** 3 )) e = Matrix( 2, 2, ( x ** 2, 2 * x * y, 2 * x * y, y ** 2 ) ) f = d * e print('%', d, e, '=', f) xdvi() return
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() xdvi() return
def main(): Format() coords = (x, y, z) = symbols('x y z') (ex, ey, ez, grad) = MV.setup('e*x|y|z', '[1,1,1]', coords=coords) s = MV('s', 'scalar') v = MV('v', 'vector') b = MV('b', 'bivector') print(r'#3D Orthogonal Metric\newline') print('#Multvectors:') print('s =', s) print('v =', v) print('b =', b) print('#Products:') X = ((s, 's'), (v, 'v'), (b, 'b')) for xi in X: print('') for yi in X: print(xi[1] + '*' + yi[1] + ' =', xi[0]*yi[0]) print(xi[1] + '^' + yi[1] + ' =', xi[0] ^ yi[0]) print(xi[1] + '|' + yi[1] + ' =', xi[0] | yi[0]) print(xi[1] + '<' + yi[1] + ' =', xi[0] < yi[0]) print(xi[1] + '>' + yi[1] + ' =', xi[0] > yi[0]) fs = MV('s', 'scalar', fct=True) fv = MV('v', 'vector', fct=True) fb = MV('b', 'bivector', fct=True) print('#Multivector Functions:') print('s(X) =', fs) print('v(X) =', fv) print('b(X) =', fb) print('#Products:') fX = ((grad, 'grad'), (fs, 's'), (fv, 'v'), (fb, 'b')) for xi in fX: print('') for yi in fX: if xi[1] == 'grad' and yi[1] == 'grad': pass else: print(xi[1] + '*' + yi[1] + ' =', xi[0]*yi[0]) print(xi[1] + '^' + yi[1] + ' =', xi[0] ^ yi[0]) print(xi[1] + '|' + yi[1] + ' =', xi[0] | yi[0]) print(xi[1] + '<' + yi[1] + ' =', xi[0] < yi[0]) print(xi[1] + '>' + yi[1] + ' =', xi[0] > yi[0]) (ex, ey, grad) = MV.setup('e', coords=(x, y)) print(r'#General 2D Metric\newline') print('#Multivector Functions:') s = MV('s', 'scalar', fct=True) v = MV('v', 'vector', fct=True) b = MV('v', 'bivector', fct=True) print('s(X) =', s) print('v(X) =', v) print('b(X) =', b) X = ((grad, 'grad'), (s, 's'), (v, 'v')) print('#Products:') for xi in X: print('') for yi in X: if xi[1] == 'grad' and yi[1] == 'grad': pass else: print(xi[1] + '*' + yi[1] + ' =', xi[0]*yi[0]) print(xi[1] + '^' + yi[1] + ' =', xi[0] ^ yi[0]) print(xi[1] + '|' + yi[1] + ' =', xi[0] | yi[0]) print(xi[1] + '<' + yi[1] + ' =', xi[0] < yi[0]) print(xi[1] + '>' + yi[1] + ' =', xi[0] > yi[0]) xdvi(paper='letter') return
def main(): Format() (ex, ey, ez) = MV.setup('e*x|y|z') A = 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') (ex, ey, ez, grad) = MV.setup('e_x e_y e_z', metric='[1,1,1]', coords=X) f = MV('f', 'scalar', fct=True) A = MV('A', 'vector', fct=True) B = MV('B', 'grade2', fct=True) print(r'\bm{A} =', A) print(r'\bm{B} =', B) print('grad*f =', grad*f) print(r'grad|\bm{A} =', grad | A) print(r'grad*\bm{A} =', grad*A) print(r'-I*(grad^\bm{A}) =', -MV.I*(grad ^ A)) print(r'grad*\bm{B} =', grad*B) print(r'grad^\bm{B} =', grad ^ B) print(r'grad|\bm{B} =', grad | B) (a, b, c, d) = MV.setup('a b c d') print('g_{ij} =', MV.metric) 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)) metric = '1 # #,' + \ '# 1 #,' + \ '# # 1,' (e1, e2, e3) = MV.setup('e1 e2 e3', metric) 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') curv = [[r*cos(phi)*sin(th), r*sin(phi)*sin(th), r*cos(th)], [1, r, r*sin(th)]] (er, eth, ephi, grad) = MV.setup('e_r e_theta e_phi', metric='[1,1,1]', coords=X, curv=curv) f = MV('f', 'scalar', fct=True) A = MV('A', 'vector', fct=True) B = MV('B', 'grade2', fct=True) print('A =', A) print('B =', B) print('grad*f =', grad*f) print('grad|A =', grad | A) print('-I*(grad^A) =', -MV.I*(grad ^ A)) print('grad^B =', grad ^ B) vars = symbols('t x y z') (g0, g1, g2, g3, grad) = MV.setup('gamma*t|x|y|z', metric='[1,-1,-1,-1]', coords=vars) I = MV.I B = MV('B', 'vector', fct=True) E = MV('E', 'vector', fct=True) B.set_coef(1, 0, 0) E.set_coef(1, 0, 0) B *= g0 E *= g0 J = MV('J', 'vector', fct=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 = grad*F gradF.Fmt(3, 'grad*F') print('grad*F = J') (gradF.grade(1) - J).Fmt(3, '%\\grade{\\nabla F}_{1} -J = 0') (gradF.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'") (g0, g1) = MV.setup('gamma*t|x', metric='[1,-1]') 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([xp, tp]) Xpp = Xpp.subs({2*sinh(alpha/2)*cosh(alpha/2): sinh(alpha), sinh(alpha/2)**2 + cosh(alpha/2)**2: cosh(alpha)}) 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(gamma)) vars = symbols('t x y z') (g0, g1, g2, g3, grad) = MV.setup('gamma*t|x|y|z', metric='[1,-1,-1,-1]', coords=vars) I = MV.I (m, e) = symbols('m e') psi = MV('psi', 'spinor', fct=True) A = MV('A', 'vector', fct=True) sig_z = g3*g0 print('\\bm{A} =', A) print('\\bm{\\psi} =', psi) dirac_eq = (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') xdvi() return
def main(): Format() coords = (x, y, z) = symbols('x y z') (ex, ey, ez, grad) = MV.setup('e*x|y|z', '[1,1,1]', coords=coords) s = MV('s', 'scalar') v = MV('v', 'vector') b = MV('b', 'bivector') print(r'#3D Orthogonal Metric\newline') print('#Multvectors:') print('s =', s) print('v =', v) print('b =', b) print('#Products:') X = ((s, 's'), (v, 'v'), (b, 'b')) for xi in X: print('') for yi in X: print(xi[1] + '*' + yi[1] + ' =', xi[0] * yi[0]) print(xi[1] + '^' + yi[1] + ' =', xi[0] ^ yi[0]) print(xi[1] + '|' + yi[1] + ' =', xi[0] | yi[0]) print(xi[1] + '<' + yi[1] + ' =', xi[0] < yi[0]) print(xi[1] + '>' + yi[1] + ' =', xi[0] > yi[0]) fs = MV('s', 'scalar', fct=True) fv = MV('v', 'vector', fct=True) fb = MV('b', 'bivector', fct=True) print('#Multivector Functions:') print('s(X) =', fs) print('v(X) =', fv) print('b(X) =', fb) print('#Products:') fX = ((grad, 'grad'), (fs, 's'), (fv, 'v'), (fb, 'b')) for xi in fX: print('') for yi in fX: if xi[1] == 'grad' and yi[1] == 'grad': pass else: print(xi[1] + '*' + yi[1] + ' =', xi[0] * yi[0]) print(xi[1] + '^' + yi[1] + ' =', xi[0] ^ yi[0]) print(xi[1] + '|' + yi[1] + ' =', xi[0] | yi[0]) print(xi[1] + '<' + yi[1] + ' =', xi[0] < yi[0]) print(xi[1] + '>' + yi[1] + ' =', xi[0] > yi[0]) (ex, ey, grad) = MV.setup('e', coords=(x, y)) print(r'#General 2D Metric\newline') print('#Multivector Functions:') s = MV('s', 'scalar', fct=True) v = MV('v', 'vector', fct=True) b = MV('v', 'bivector', fct=True) print('s(X) =', s) print('v(X) =', v) print('b(X) =', b) X = ((grad, 'grad'), (s, 's'), (v, 'v')) print('#Products:') for xi in X: print('') for yi in X: if xi[1] == 'grad' and yi[1] == 'grad': pass else: print(xi[1] + '*' + yi[1] + ' =', xi[0] * yi[0]) print(xi[1] + '^' + yi[1] + ' =', xi[0] ^ yi[0]) print(xi[1] + '|' + yi[1] + ' =', xi[0] | yi[0]) print(xi[1] + '<' + yi[1] + ' =', xi[0] < yi[0]) print(xi[1] + '>' + yi[1] + ' =', xi[0] > yi[0]) xdvi(paper='letter') return
def main(): Format() (ex, ey, ez) = MV.setup('e*x|y|z') A = 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') (ex, ey, ez, grad) = MV.setup('e_x e_y e_z', metric='[1,1,1]', coords=X) f = MV('f', 'scalar', fct=True) A = MV('A', 'vector', fct=True) B = MV('B', 'grade2', fct=True) print(r'\bm{A} =', A) print(r'\bm{B} =', B) print('grad*f =', grad * f) print(r'grad|\bm{A} =', grad | A) print(r'grad*\bm{A} =', grad * A) print(r'-I*(grad^\bm{A}) =', -MV.I * (grad ^ A)) print(r'grad*\bm{B} =', grad * B) print(r'grad^\bm{B} =', grad ^ B) print(r'grad|\bm{B} =', grad | B) (a, b, c, d) = MV.setup('a b c d') print('g_{ij} =', MV.metric) 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)) metric = '1 # #,' + \ '# 1 #,' + \ '# # 1,' (e1, e2, e3) = MV.setup('e1 e2 e3', metric) 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') curv = [[r * cos(phi) * sin(th), r * sin(phi) * sin(th), r * cos(th)], [1, r, r * sin(th)]] (er, eth, ephi, grad) = MV.setup('e_r e_theta e_phi', metric='[1,1,1]', coords=X, curv=curv) f = MV('f', 'scalar', fct=True) A = MV('A', 'vector', fct=True) B = MV('B', 'grade2', fct=True) print('A =', A) print('B =', B) print('grad*f =', grad * f) print('grad|A =', grad | A) print('-I*(grad^A) =', -MV.I * (grad ^ A)) print('grad^B =', grad ^ B) vars = symbols('t x y z') (g0, g1, g2, g3, grad) = MV.setup('gamma*t|x|y|z', metric='[1,-1,-1,-1]', coords=vars) I = MV.I B = MV('B', 'vector', fct=True) E = MV('E', 'vector', fct=True) B.set_coef(1, 0, 0) E.set_coef(1, 0, 0) B *= g0 E *= g0 J = MV('J', 'vector', fct=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 = grad * F gradF.Fmt(3, 'grad*F') print('grad*F = J') (gradF.grade(1) - J).Fmt(3, '%\\grade{\\nabla F}_{1} -J = 0') (gradF.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'") (g0, g1) = MV.setup('gamma*t|x', metric='[1,-1]') 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([xp, tp]) Xpp = Xpp.subs({ 2 * sinh(alpha / 2) * cosh(alpha / 2): sinh(alpha), sinh(alpha / 2)**2 + cosh(alpha / 2)**2: cosh(alpha) }) 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(gamma)) vars = symbols('t x y z') (g0, g1, g2, g3, grad) = MV.setup('gamma*t|x|y|z', metric='[1,-1,-1,-1]', coords=vars) I = MV.I (m, e) = symbols('m e') psi = MV('psi', 'spinor', fct=True) A = MV('A', 'vector', fct=True) sig_z = g3 * g0 print('\\bm{A} =', A) print('\\bm{\\psi} =', psi) dirac_eq = (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' ) xdvi() return
def main(): Get_Program() Format() derivatives_in_spherical_coordinates() xdvi() return