In [9]:
using PyCall

In [19]:
cd("/Users/utensil/experiments/")

In [13]:
run(`git clone https://github.com/brombo/galgebra.git`)


Cloning into 'galgebra'...

In [20]:
cd("galgebra")

In [14]:
run(`python setup.py install`)


running install
running bdist_egg
running egg_info
creating galgebra.egg-info
writing requirements to galgebra.egg-info/requires.txt
writing galgebra.egg-info/PKG-INFO
writing top-level names to galgebra.egg-info/top_level.txt
writing dependency_links to galgebra.egg-info/dependency_links.txt
writing manifest file 'galgebra.egg-info/SOURCES.txt'
reading manifest file 'galgebra.egg-info/SOURCES.txt'
writing manifest file 'galgebra.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.5-x86_64/egg
running install_lib
running build_py
creating build
creating build/lib
creating build/lib/galgebra
copying galgebra/__init__.py -> build/lib/galgebra
copying galgebra/ga.py -> build/lib/galgebra
copying galgebra/lt.py -> build/lib/galgebra
copying galgebra/metric.py -> build/lib/galgebra
copying galgebra/mv.py -> build/lib/galgebra
copying galgebra/printer.py -> build/lib/galgebra
copying galgebra/setgapth.py -> build/lib/galgebra
creating build/lib/tests
copying tests/__init__.py -> build/lib/tests
copying tests/test_mv.py -> build/lib/tests
copying tests/test_test.py -> build/lib/tests
creating build/bdist.macosx-10.5-x86_64
creating build/bdist.macosx-10.5-x86_64/egg
creating build/bdist.macosx-10.5-x86_64/egg/galgebra
copying build/lib/galgebra/__init__.py -> build/bdist.macosx-10.5-x86_64/egg/galgebra
copying build/lib/galgebra/ga.py -> build/bdist.macosx-10.5-x86_64/egg/galgebra
copying build/lib/galgebra/lt.py -> build/bdist.macosx-10.5-x86_64/egg/galgebra
copying build/lib/galgebra/metric.py -> build/bdist.macosx-10.5-x86_64/egg/galgebra
copying build/lib/galgebra/mv.py -> build/bdist.macosx-10.5-x86_64/egg/galgebra
copying build/lib/galgebra/printer.py -> build/bdist.macosx-10.5-x86_64/egg/galgebra
copying build/lib/galgebra/setgapth.py -> build/bdist.macosx-10.5-x86_64/egg/galgebra
creating build/bdist.macosx-10.5-x86_64/egg/tests
copying build/lib/tests/__init__.py -> build/bdist.macosx-10.5-x86_64/egg/tests
copying build/lib/tests/test_mv.py -> build/bdist.macosx-10.5-x86_64/egg/tests
copying build/lib/tests/test_test.py -> build/bdist.macosx-10.5-x86_64/egg/tests
byte-compiling build/bdist.macosx-10.5-x86_64/egg/galgebra/__init__.py to __init__.pyc
byte-compiling build/bdist.macosx-10.5-x86_64/egg/galgebra/ga.py to ga.pyc
byte-compiling build/bdist.macosx-10.5-x86_64/egg/galgebra/lt.py to lt.pyc
byte-compiling build/bdist.macosx-10.5-x86_64/egg/galgebra/metric.py to metric.pyc
byte-compiling build/bdist.macosx-10.5-x86_64/egg/galgebra/mv.py to mv.pyc
byte-compiling build/bdist.macosx-10.5-x86_64/egg/galgebra/printer.py to printer.pyc
byte-compiling build/bdist.macosx-10.5-x86_64/egg/galgebra/setgapth.py to setgapth.pyc
byte-compiling build/bdist.macosx-10.5-x86_64/egg/tests/__init__.py to __init__.pyc
byte-compiling build/bdist.macosx-10.5-x86_64/egg/tests/test_mv.py to test_mv.pyc
byte-compiling build/bdist.macosx-10.5-x86_64/egg/tests/test_test.py to test_test.pyc
creating build/bdist.macosx-10.5-x86_64/egg/EGG-INFO
copying galgebra.egg-info/PKG-INFO -> build/bdist.macosx-10.5-x86_64/egg/EGG-INFO
copying galgebra.egg-info/SOURCES.txt -> build/bdist.macosx-10.5-x86_64/egg/EGG-INFO
copying galgebra.egg-info/dependency_links.txt -> build/bdist.macosx-10.5-x86_64/egg/EGG-INFO
copying galgebra.egg-info/requires.txt -> build/bdist.macosx-10.5-x86_64/egg/EGG-INFO
copying galgebra.egg-info/top_level.txt -> build/bdist.macosx-10.5-x86_64/egg/EGG-INFO
creating dist
creating 'dist/galgebra-0.4.0-py2.7.egg' and adding 'build/bdist.macosx-10.5-x86_64/egg' to it
zip_safe flag not set; analyzing archive contents...
galgebra.printer: module MAY be using inspect.getouterframes
removing 'build/bdist.macosx-10.5-x86_64/egg' (and everything under it)
Processing galgebra-0.4.0-py2.7.egg
creating /Users/utensil/miniconda2/lib/python2.7/site-packages/galgebra-0.4.0-py2.7.egg
Extracting galgebra-0.4.0-py2.7.egg to /Users/utensil/miniconda2/lib/python2.7/site-packages
Adding galgebra 0.4.0 to easy-install.pth file

Installed /Users/utensil/miniconda2/lib/python2.7/site-packages/galgebra-0.4.0-py2.7.egg
Processing dependencies for galgebra==0.4.0
Searching for numpy==1.9.2
Best match: numpy 1.9.2
Adding numpy 1.9.2 to easy-install.pth file

Using /Users/utensil/miniconda2/lib/python2.7/site-packages
Searching for sympy==1.0
Best match: sympy 1.0
Adding sympy 1.0 to easy-install.pth file

Using /Users/utensil/miniconda2/lib/python2.7/site-packages
Finished processing dependencies for galgebra==0.4.0

In [21]:
run(`python setup.py test`)


running test
running egg_info
writing requirements to galgebra.egg-info/requires.txt
writing galgebra.egg-info/PKG-INFO
writing top-level names to galgebra.egg-info/top_level.txt
writing dependency_links to galgebra.egg-info/dependency_links.txt
reading manifest file 'galgebra.egg-info/SOURCES.txt'
writing manifest file 'galgebra.egg-info/SOURCES.txt'
running build_ext
----------------------------------------------------------------------
Ran 0 tests in 0.000s

OK

In [3]:
basis = "a0 a1 a2 n nbar"


Out[3]:
"a0 a1 a2 n nbar"

In [4]:
metric = "# # # 0 0, # # # 0 0, # # # 0 0, 0 0 0 0 2, 0 0 0 2 0"


Out[4]:
"# # # 0 0, # # # 0 0, # # # 0 0, 0 0 0 0 2, 0 0 0 2 0"

In [22]:
@pyimport sympy
@pyimport galgebra as ga

In [24]:
coords=sympy.symbols("x,y,z",real=true)
base=ga.Ga("e0 e1 e2",g=[1,1,1],coords=coords)


LoadError: UndefVarError: Ga not defined
while loading In[24], in expression starting on line 2

In [25]:
ga


Out[25]:
__anon__

In [27]:
inspect.ismodule(ga)


Out[27]:
false

In [31]:
cd("/Users/utensil/experiments/")

In [32]:
run(`git clone https://github.com/andrioni/GeoAlg.jl.git`)


Cloning into 'GeoAlg.jl'...

In [33]:
cd("GeoAlg.jl")

In [34]:
include("src/GeoAlg.jl")


LoadError: LoadError: TypeError: Metric: in type definition, expected Type{T}, got Tuple{DataType,DataType}
while loading /Users/utensil/experiments/GeoAlg.jl/src/GeoAlg.jl, in expression starting on line 90
while loading In[34], in expression starting on line 1

In [83]:
cd("/Users/utensil/experiments/")

In [84]:
cd("galgebra/galgebra")

In [85]:
filter(readdir(".")) do file_name
    ismatch(r"\.py$", file_name)
end


Out[85]:
7-element Array{ByteString,1}:
 "__init__.py"
 "ga.py"      
 "lt.py"      
 "metric.py"  
 "mv.py"      
 "printer.py" 
 "setgapth.py"

In [86]:
@pyimport site

In [87]:
dist_pkgs = site.getsitepackages()[end]


Out[87]:
"/Users/utensil/miniconda2/lib/site-python"

In [88]:
mkpath(dist_pkgs)

In [89]:
run(`python setgapth.py`)


#Path of Ga module
/Users/utensil/experiments/galgebra/galgebraos name: posix
site-packages directory: /Users/utensil/miniconda2/lib/site-python/Ga.pth
Ga.pth:
0

Python pth file Ga.pth for all modules of galgebra has been created and
placed in directory appropriate for Linux, Windows, or OSX.  Note that
if Ga.pth already exists the old version will be deleted.


In [96]:
cd("/Users/utensil/experiments/galgebra/examples");readdir(".")


Out[96]:
5-element Array{ByteString,1}:
 "LaTeX"     
 "Old Format"
 "Terminal"  
 "ipython"   
 "macdonal"  

In [97]:
cd("Terminal");readdir(".")


Out[97]:
11-element Array{ByteString,1}:
 "1d_grad.py"            
 "ConformalConsole.py"   
 "coefs_test.py"         
 "exp_check.py"          
 "lt_check.py"           
 "lt_test.py"            
 "mv_setup_options.py"   
 "prob_not_solenoidal.py"
 "reciprocal.py"         
 "rotations.py"          
 "terminal_check.py"     

In [98]:
run(`python terminal_check.py`)


A = A + A__x*e_x + A__y*e_y + A__z*e_z + A__xy*e_x^e_y + A__xz*e_x^e_z + A__yz*e_y^e_z + A__xyz*e_x^e_y^e_z
A =  A
 + A__x*e_x + A__y*e_y + A__z*e_z
 + A__xy*e_x^e_y + A__xz*e_x^e_z + A__yz*e_y^e_z
 + A__xyz*e_x^e_y^e_z
A =  A
 + A__x*e_x
 + A__y*e_y
 + A__z*e_z
 + A__xy*e_x^e_y
 + A__xz*e_x^e_z
 + A__yz*e_y^e_z
 + A__xyz*e_x^e_y^e_z
g_{ij} =
Matrix([
[(e_x.e_x), (e_x.e_y), (e_x.e_z)],
[(e_x.e_y), (e_y.e_y), (e_y.e_z)],
[(e_x.e_z), (e_y.e_z), (e_z.e_z)]])
X = X__x*e_x + X__y*e_y + X__z*e_z
Y = Y__x*e_x + Y__y*e_y + Y__z*e_z
X*Y =  (e_x.e_x)*X__x*Y__x + (e_x.e_y)*X__x*Y__y + (e_x.e_y)*X__y*Y__x + (e_x.e_z)*X__x*Y__z + (e_x.e_z)*X__z*Y__x + (e_y.e_y)*X__y*Y__y + (e_y.e_z)*X__y*Y__z + (e_y.e_z)*X__z*Y__y + (e_z.e_z)*X__z*Y__z
 + (X__x*Y__y - X__y*Y__x)*e_x^e_y + (X__x*Y__z - X__z*Y__x)*e_x^e_z + (X__y*Y__z - X__z*Y__y)*e_y^e_z
X^Y =  (X__x*Y__y - X__y*Y__x)*e_x^e_y + (X__x*Y__z - X__z*Y__x)*e_x^e_z + (X__y*Y__z - X__z*Y__y)*e_y^e_z
X|Y = (e_x.e_x)*X__x*Y__x + (e_x.e_y)*X__x*Y__y + (e_x.e_y)*X__y*Y__x + (e_x.e_z)*X__x*Y__z + (e_x.e_z)*X__z*Y__x + (e_y.e_y)*X__y*Y__y + (e_y.e_z)*X__y*Y__z + (e_y.e_z)*X__z*Y__y + (e_z.e_z)*X__z*Y__z
g_{ij} =
Matrix([
[(e_x.e_x), (e_x.e_y)],
[(e_x.e_y), (e_y.e_y)]])
X = X__x*e_x + X__y*e_y
A = A + A__xy*e_x^e_y
X|A =  -A__xy*((e_x.e_y)*X__x + (e_y.e_y)*X__y)*e_x + A__xy*((e_x.e_x)*X__x + (e_x.e_y)*X__y)*e_y
X<A =  -A__xy*((e_x.e_y)*X__x + (e_y.e_y)*X__y)*e_x + A__xy*((e_x.e_x)*X__x + (e_x.e_y)*X__y)*e_y
A>X =  A__xy*((e_x.e_y)*X__x + (e_y.e_y)*X__y)*e_x - A__xy*((e_x.e_x)*X__x + (e_x.e_y)*X__y)*e_y
g_{ii} =
Matrix([
[1, 0],
[0, 1]])
X = X__x*e_x + X__y*e_y
A = A + A__xy*e_x^e_y
X*A =  (A*X__x - A__xy*X__y)*e_x + (A*X__y + A__xy*X__x)*e_y
X|A =  -A__xy*X__y*e_x + A__xy*X__x*e_y
X<A =  -A__xy*X__y*e_x + A__xy*X__x*e_y
X>A =  A*X__x*e_x + A*X__y*e_y
A*X =  (A*X__x + A__xy*X__y)*e_x + (A*X__y - A__xy*X__x)*e_y
A|X =  A__xy*X__y*e_x - A__xy*X__x*e_y
A<X =  A*X__x*e_x + A*X__y*e_y
A>X =  A__xy*X__y*e_x - A__xy*X__x*e_y
g_{ij} =
Matrix([
[(a.a), (a.b), (a.c), (a.d), (a.e)],
[(a.b), (b.b), (b.c), (b.d), (b.e)],
[(a.c), (b.c), (c.c), (c.d), (c.e)],
[(a.d), (b.d), (c.d), (d.d), (d.e)],
[(a.e), (b.e), (c.e), (d.e), (e.e)]])
a|(b*c) = -(a.c)*b + (a.b)*c
a|(b^c) = -(a.c)*b + (a.b)*c
a|(b^c^d) = (a.d)*b^c - (a.c)*b^d + (a.b)*c^d
a|(b^c)+c|(a^b)+b|(c^a) = (a.b)*c - (b.c)*a - ((a.b)*c - (b.c)*a)
a*(b^c)-b*(a^c)+c*(a^b) = 3*a^b^c
a*(b^c^d)-b*(a^c^d)+c*(a^b^d)-d*(a^b^c) = 4*a^b^c^d
(a^b)|(c^d) = -(a.c)*(b.d) + (a.d)*(b.c)
((a^b)|c)|d = -(a.c)*(b.d) + (a.d)*(b.c)
(a^b)x(c^d) = -(b.d)*a^c + (b.c)*a^d + (a.d)*b^c - (a.c)*b^d
(a|(b^c))|(d^e) = (-(a.b)*(c.e) + (a.c)*(b.e))*d + ((a.b)*(c.d) - (a.c)*(b.d))*e
f = f
A = A__x*e_x + A__y*e_y + A__z*e_z
B = B__xy*e_x^e_y + B__xz*e_x^e_z + B__yz*e_y^e_z
C = C + C__x*e_x + C__y*e_y + C__z*e_z + C__xy*e_x^e_y + C__xz*e_x^e_z + C__yz*e_y^e_z + C__xyz*e_x^e_y^e_z
grad*f = D{x}f*e_x + D{y}f*e_y + D{z}f*e_z
grad|A = D{x}A__x + D{y}A__y + D{z}A__z
grad*A = D{x}A__x + D{y}A__y + D{z}A__z + (-D{y}A__x + D{x}A__y)*e_x^e_y + (-D{z}A__x + D{x}A__z)*e_x^e_z + (-D{z}A__y + D{y}A__z)*e_y^e_z
-I*(grad^A) = (-D{z}A__y + D{y}A__z)*e_x + (D{z}A__x - D{x}A__z)*e_y + (-D{y}A__x + D{x}A__y)*e_z
grad*B = (-D{y}B__xy - D{z}B__xz)*e_x + (D{x}B__xy - D{z}B__yz)*e_y + (D{x}B__xz + D{y}B__yz)*e_z + (D{z}B__xy - D{y}B__xz + D{x}B__yz)*e_x^e_y^e_z
grad^B = (D{z}B__xy - D{y}B__xz + D{x}B__yz)*e_x^e_y^e_z
grad|B = (-D{y}B__xy - D{z}B__xz)*e_x + (D{x}B__xy - D{z}B__yz)*e_y + (D{x}B__xz + D{y}B__yz)*e_z
grad<A = D{x}A__x + D{y}A__y + D{z}A__z
grad>A = D{x}A__x + D{y}A__y + D{z}A__z
grad<B = (-D{y}B__xy - D{z}B__xz)*e_x + (D{x}B__xy - D{z}B__yz)*e_y + (D{x}B__xz + D{y}B__yz)*e_z
grad>B = 0
grad<C = D{x}C__x + D{y}C__y + D{z}C__z + (-D{y}C__xy - D{z}C__xz)*e_x + (D{x}C__xy - D{z}C__yz)*e_y + (D{x}C__xz + D{y}C__yz)*e_z + D{z}C__xyz*e_x^e_y - D{y}C__xyz*e_x^e_z + D{x}C__xyz*e_y^e_z
grad>C = D{x}C__x + D{y}C__y + D{z}C__z + D{x}C*e_x + D{y}C*e_y + D{z}C*e_z
f = f
A = A__r*e_r + A__theta*e_theta + A__phi*e_phi
B = B__rtheta*e_r^e_theta + B__rphi*e_r^e_phi + B__thetaphi*e_theta^e_phi
grad*f = D{r}f*e_r + D{theta}f*e_theta/r + D{phi}f*e_phi/(r*sin(theta))
grad|A = D{r}A__r + (A__r + D{theta}A__theta)/r + (A__r*sin(theta) + A__theta*cos(theta) + D{phi}A__phi)/(r*sin(theta))
-I*(grad^A) = (A__phi/tan(theta) + D{theta}A__phi - D{phi}A__theta/sin(theta))*e_r/r + (-r*D{r}A__phi - A__phi + D{phi}A__r/sin(theta))*e_theta/r + (r*D{r}A__theta + A__theta - D{theta}A__r)*e_phi/r
grad^B = (r*D{r}B__thetaphi - B__rphi/tan(theta) + 2*B__thetaphi - D{theta}B__rphi + D{phi}B__rtheta/sin(theta))*e_r^e_theta^e_phi/r
X = 1.2*e_x + 2.34*e_y + 0.555*e_z
Nga(X,2) = 1.2*e_x + 2.3*e_y + 0.55*e_z
X*Y = 12.7011000000000 + 4.02078*e_x^e_y + 6.175185*e_x^e_z + 10.182*e_y^e_z
Nga(X*Y,2) = 13. + 4.0*e_x^e_y + 6.2*e_x^e_z + 10.0*e_y^e_z
g_{ij} = Matrix([
[                          0, (X.Y), (X.e)],
[(X.Y),                           0, (Y.e)],
[(X.e), (Y.e),                           1]])
(X^Y)**2 = (X.Y)**2
B = X^Y - (Y.e)*X^e + (X.e)*Y^e
B**2 = 3*(X.Y)**2 - 2*(X.Y)*(X.e)*(Y.e) + 2*(X.Y)*(X.e)*Y^e - 2*(X.Y)*(X.e)*((Y.e) + Y^e) - 2*(X.Y)*(Y.e)*X^e + 2*(X.Y)*(Y.e)*((X.e) + X^e) + 2*(X.Y)*X^Y - 2*(X.Y)*((X.Y) + X^Y)
#L = X^Y^e is a non-euclidian line
B = L*e = X^Y - (Y.e)*X^e + (X.e)*Y^e
B*e*B.rev() = (X.Y)*(-(X.Y) + 2*(X.e)*(Y.e))*e
B**2 = (X.Y)*((X.Y) - 2*(X.e)*(Y.e))
L**2 = (X.Y)**2 - 2*(X.Y)*(X.e)*(Y.e)
s = sinh(alpha/2) and c = cosh(alpha/2)
exp(alpha*B/(2*|B|)) = c + (1/B)*s*X^Y - (Y.e)*(1/B)*s*X^e + (X.e)*(1/B)*s*Y^e
R*X*R.rev() =  ((X.Y)**2*(1/B)**2*s**2 - 2*(X.Y)*(X.e)*(Y.e)*(1/B)**2*s**2 + 2*(X.Y)*(1/B)*c*s - 2*(X.e)*(Y.e)*(1/B)*c*s + c**2)*X
 + 2*(X.e)**2*(1/B)*c*s*Y
 + 2*(X.Y)*(X.e)*(1/B)*s*(-(X.Y)*(1/B)*s + 2*(X.e)*(Y.e)*(1/B)*s - c)*e
Objective is to determine value of C = cosh(alpha) such that W = 0
Z|Y = (X.Y)**3*(1/B)**2*s**2 - 4*(X.Y)**2*(X.e)*(Y.e)*(1/B)**2*s**2 + 2*(X.Y)**2*(1/B)*c*s + 4*(X.Y)*(X.e)**2*(Y.e)**2*(1/B)**2*s**2 - 4*(X.Y)*(X.e)*(Y.e)*(1/B)*c*s + (X.Y)*c**2
S = sinh(alpha) and C = cosh(alpha)
W = (X.Y)*(1/B)*C*sqrt((X.Y)**2 - 2*(X.Y)*(X.e)*(Y.e)) - (X.e)*(Y.e)*(1/B)*C*sqrt((X.Y)**2 - 2*(X.Y)*(X.e)*(Y.e)) + (X.e)*(Y.e)*(1/B)*sqrt((X.Y)**2 - 2*(X.Y)*(X.e)*(Y.e)) + S*sqrt((X.Y)**2 - 2*(X.Y)*(X.e)*(Y.e))
Wd = {S: sqrt((X.Y)**2 - 2*(X.Y)*(X.e)*(Y.e)), C: (X.Y)*(1/B)*sqrt((X.Y)**2 - 2*(X.Y)*(X.e)*(Y.e)) - (X.e)*(Y.e)*(1/B)*sqrt((X.Y)**2 - 2*(X.Y)*(X.e)*(Y.e)), 1: (X.e)*(Y.e)*(1/B)*sqrt((X.Y)**2 - 2*(X.Y)*(X.e)*(Y.e))}
Scalar Coefficient = (X.e)*(Y.e)*(1/B)*sqrt((X.Y)**2 - 2*(X.Y)*(X.e)*(Y.e))
Cosh Coefficient = (X.Y)*(1/B)*sqrt((X.Y)**2 - 2*(X.Y)*(X.e)*(Y.e)) - (X.e)*(Y.e)*(1/B)*sqrt((X.Y)**2 - 2*(X.Y)*(X.e)*(Y.e))
Sinh Coefficient = sqrt((X.Y)**2 - 2*(X.Y)*(X.e)*(Y.e))
|B| = sqrt((X.Y)**2 - 2*(X.Y)*(X.e)*(Y.e))
Require a*C**2+b*C+c = 0
a = (X.e)**2*(Y.e)**2
b = 2*(X.e)*(Y.e)*((X.Y) - (X.e)*(Y.e))
c = (X.Y)**2 - 2*(X.Y)*(X.e)*(Y.e) + (X.e)**2*(Y.e)**2
cosh(alpha) = C = -b/(2*a) = -(X.Y)/((X.e)*(Y.e)) + 1
g_{ij} =
Matrix([
[1, 0, 0, 0, 0],
[0, 1, 0, 0, 0],
[0, 0, 1, 0, 0],
[0, 0, 0, 0, 2],
[0, 0, 0, 2, 0]])
F(a) = e_1 + n/2 - nbar/2
F(b) = e_2 + n/2 - nbar/2
F(c) = -e_1 + n/2 - nbar/2
F(d) = e_3 + n/2 - nbar/2
F(x) = x1*e_1 + x2*e_2 + x3*e_3 + (x1**2/2 + x2**2/2 + x3**2/2)*n - nbar/2
a = e1, b = e2, c = -e1, and d = e3
A = F(a) = 1/2*(a*a*n+2*a-nbar), etc.
Circle through a, b, and c
Circle: A^B^C^X = 0 = -x3*e_1^e_2^e_3^n + x3*e_1^e_2^e_3^nbar + (x1**2/2 + x2**2/2 + x3**2/2 - 1/2)*e_1^e_2^n^nbar
Line through a and b
Line  : A^B^n^X = 0 = -x3*e_1^e_2^e_3^n + (x1/2 + x2/2 - 1/2)*e_1^e_2^n^nbar + x3*e_1^e_3^n^nbar/2 - x3*e_2^e_3^n^nbar/2
Sphere through a, b, c, and d
Sphere: A^B^C^D^X = 0 = (-x1**2/2 - x2**2/2 - x3**2/2 + 1/2)*e_1^e_2^e_3^n^nbar
Plane through a, b, and d
Plane : A^B^n^D^X = 0 = (-x1/2 - x2/2 - x3/2 + 1/2)*e_1^e_2^e_3^n^nbar
Hyperbolic Circle: (A^B^e)^X = 0 = =  -x3*e_1^e_2^e_3^n
 - x3*e_1^e_2^e_3^nbar
 + (-x1**2/2 + x1 - x2**2/2 + x2 - x3**2/2 - 1/2)*e_1^e_2^n^nbar
 + x3*e_1^e_3^n^nbar
 - x3*e_2^e_3^n^nbar
g_{ij} =
Matrix([
[(p1.p1), (p1.p2), (p1.p3), 0, 0],
[(p1.p2), (p2.p2), (p2.p3), 0, 0],
[(p1.p3), (p2.p3), (p3.p3), 0, 0],
[                            0,                             0,                             0, 0, 2],
[                            0,                             0,                             0, 2, 0]])
Extracting direction of line from L = P1^P2^n
(L|n)|nbar = 2*p1 - 2*p2
Extracting plane of circle from C = P1^P2^P3
((C^n)|n)|nbar = 2*p1^p2 - 2*p1^p3 + 2*p2^p3
(p2-p1)^(p3-p1) = p1^p2 - p1^p3 + p2^p3
g_{ij} =
Matrix([
[                           0,                           -1, (P1.a)],
[                          -1,                            0, (P2.a)],
[(P1.a), (P2.a),  (a.a)]])
B**2 = 1
a' = a-(a^B)*B = -(P2.a)*P1 - (P1.a)*P2
A+ = a'+a'*B = -2*(P2.a)*P1
A- = a'-a'*B = -2*(P1.a)*P2
(A+)^2 = 0
(A-)^2 = 0
a|B = -(P2.a)*P1 + (P1.a)*P2
g_{ij} =
Matrix([
[                            1, (e1.e2), (e1.e3)],
[(e1.e2),                             1, (e2.e3)],
[(e1.e3), (e2.e3),                             1]])
E = e1^e2^e3
E**2 = (e1.e2)**2 - 2*(e1.e2)*(e1.e3)*(e2.e3) + (e1.e3)**2 + (e2.e3)**2 - 1
E1 = (e2^e3)*E = ((e2.e3)**2 - 1)*e1 + ((e1.e2) - (e1.e3)*(e2.e3))*e2 + (-(e1.e2)*(e2.e3) + (e1.e3))*e3
E2 =-(e1^e3)*E = ((e1.e2) - (e1.e3)*(e2.e3))*e1 + ((e1.e3)**2 - 1)*e2 + (-(e1.e2)*(e1.e3) + (e2.e3))*e3
E3 = (e1^e2)*E = (-(e1.e2)*(e2.e3) + (e1.e3))*e1 + (-(e1.e2)*(e1.e3) + (e2.e3))*e2 + ((e1.e2)**2 - 1)*e3
E1|e2 = 0
E1|e3 = 0
E2|e1 = 0
E2|e3 = 0
E3|e1 = 0
E3|e2 = 0
(E1|e1)/E**2 = 1
(E2|e2)/E**2 = 1
(E3|e3)/E**2 = 1
e3d.g = Matrix([
[1, 0, 0],
[0, 1, 0],
[0, 0, 1]])
Signature = (3,0) I = e1^e2^e3  I**2 = -1
e3d.g = Matrix([
[2, 0, 0],
[0, 2, 0],
[0, 0, 2]])
Signature = (3,0) I = sqrt(2)*e1^e2^e3/4  I**2 = -1
e3d.g = Matrix([
[1,  0,  0,  0],
[0, -1,  0,  0],
[0,  0, -1,  0],
[0,  0,  0, -1]])
Signature = (1,3) I = e1^e2^e3^e4  I**2 = -1
e3d.g = Matrix([
[2,  0,  0,  0],
[0, -2,  0,  0],
[0,  0, -2,  0],
[0,  0,  0, -2]])
Signature = (1,3) I = e1^e2^e3^e4/4  I**2 = -1
e4d.g = Matrix([
[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[0, 0, 0, 1]])
Signature = (4,0) I = e1^e2^e3^e4  I**2 = 1
cf4d.g = Matrix([
[1, 0, 0, 0,  0],
[0, 1, 0, 0,  0],
[0, 0, 1, 0,  0],
[0, 0, 0, 1,  0],
[0, 0, 0, 0, -1]])
Signature = (4,1) I = e1^e2^e3^e4^e5  I**2 = -1
cf4d.g = Matrix([
[2, 0, 0, 0,  0],
[0, 2, 0, 0,  0],
[0, 0, 2, 0,  0],
[0, 0, 0, 2,  0],
[0, 0, 0, 0, -2]])
Signature = (4,1) I = sqrt(2)*e1^e2^e3^e4^e5/8  I**2 = -1

In [2]:
using PyCall
@pyimport sympy
@pyimport ga


sys:1: SymPyDeprecationWarning: 

C, including its class ClassRegistry, has been deprecated since SymPy
1.0. It will be last supported in SymPy version 1.0. Use direct
imports from the defining module instead. See
https://github.com/sympy/sympy/issues/9371 for more info.


In [3]:
g3d = ga.Ga("e*x|y|z")
(ex, ey, ez) = g3d[:mv]()
A = g3d[:mv]("A", "mv")


Out[3]:
\begin{equation*} A = A + A^{x} \boldsymbol{e}_{x} + A^{y} \boldsymbol{e}_{y} + A^{z} \boldsymbol{e}_{z} + A^{xy} \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y} + A^{xz} \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{z} + A^{yz} \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} + A^{xyz} \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} \end{equation*}

In [4]:
[display(symbol) for symbol in (ex, ey, ez)]


\begin{equation*} \boldsymbol{e}_{x} \end{equation*}
\begin{equation*} \boldsymbol{e}_{y} \end{equation*}
\begin{equation*} \boldsymbol{e}_{z} \end{equation*}
Out[4]:
3-element Array{Any,1}:
 nothing
 nothing
 nothing

In [5]:
X = g3d[:mv]("X", "vector")


Out[5]:
\begin{equation*} X = X^{x} \boldsymbol{e}_{x} + X^{y} \boldsymbol{e}_{y} + X^{z} \boldsymbol{e}_{z} \end{equation*}

In [6]:
Y = g3d[:mv]("Y", "vector")


Out[6]:
\begin{equation*} Y = Y^{x} \boldsymbol{e}_{x} + Y^{y} \boldsymbol{e}_{y} + Y^{z} \boldsymbol{e}_{z} \end{equation*}

In [7]:
g3d[:g]


Out[7]:
PyObject Matrix([
[(e_x.e_x), (e_x.e_y), (e_x.e_z)],
[(e_x.e_y), (e_y.e_y), (e_y.e_z)],
[(e_x.e_z), (e_y.e_z), (e_z.e_z)]])

In [8]:
g3d[:I]()


Out[8]:
\begin{equation*} \frac{1}{\sqrt{\left ( e_{x}\cdot e_{x}\right ) \left ( e_{y}\cdot e_{y}\right ) \left ( e_{z}\cdot e_{z}\right ) - \left ( e_{x}\cdot e_{x}\right ) \left ( e_{y}\cdot e_{z}\right ) ^{2} - \left ( e_{x}\cdot e_{y}\right ) ^{2} \left ( e_{z}\cdot e_{z}\right ) + 2 \left ( e_{x}\cdot e_{y}\right ) \left ( e_{x}\cdot e_{z}\right ) \left ( e_{y}\cdot e_{z}\right ) - \left ( e_{x}\cdot e_{z}\right ) ^{2} \left ( e_{y}\cdot e_{y}\right ) }} \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} \end{equation*}

In [9]:
g3d[:E]()


Out[9]:
\begin{equation*} \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} \end{equation*}

In [10]:
mv = g3d[:mv]


Out[10]:
PyObject <bound method Ga.mv of <ga.Ga object at 0x30cc07b90>>

In [11]:
C = mv("C", "scalar")


Out[11]:
\begin{equation*} C = C \end{equation*}

In [12]:
B = mv("B", "bivector")


Out[12]:
\begin{equation*} B = B^{xy} \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y} + B^{xz} \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{z} + B^{yz} \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} \end{equation*}

In [13]:
V3 = mv("V3", 3)


Out[13]:
\begin{equation*} V3 = V^{xyz}_{3} \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} \end{equation*}

In [14]:
V2 = mv("V2", 2)


Out[14]:
\begin{equation*} V2 = V^{xy}_{2} \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y} + V^{xz}_{2} \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{z} + V^{yz}_{2} \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} \end{equation*}

In [15]:
V1 = mv("V1", 1)


Out[15]:
\begin{equation*} V1 = V^{x}_{1} \boldsymbol{e}_{x} + V^{y}_{1} \boldsymbol{e}_{y} + V^{z}_{1} \boldsymbol{e}_{z} \end{equation*}

In [16]:
V0 = mv("V0", 0)


Out[16]:
\begin{equation*} V0 = V_{0} \end{equation*}

In [17]:
S = mv("S", "spinor")


Out[17]:
\begin{equation*} S = S + S^{xy} \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y} + S^{xz} \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{z} + S^{yz} \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} \end{equation*}

In [18]:
I2 = mv("I2", "pseudo")


Out[18]:
\begin{equation*} I2 = I^{xyz}_{2} \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} \end{equation*}

In [19]:
I2 == g3d[:I]()


Out[19]:
false

In [20]:
@pyimport operator

In [21]:
operator.mul(X, Y) # X * Y


Out[21]:
\begin{equation*} \left ( \left ( e_{x}\cdot e_{x}\right ) X^{x} Y^{x} + \left ( e_{x}\cdot e_{y}\right ) X^{x} Y^{y} + \left ( e_{x}\cdot e_{y}\right ) X^{y} Y^{x} + \left ( e_{x}\cdot e_{z}\right ) X^{x} Y^{z} + \left ( e_{x}\cdot e_{z}\right ) X^{z} Y^{x} + \left ( e_{y}\cdot e_{y}\right ) X^{y} Y^{y} + \left ( e_{y}\cdot e_{z}\right ) X^{y} Y^{z} + \left ( e_{y}\cdot e_{z}\right ) X^{z} Y^{y} + \left ( e_{z}\cdot e_{z}\right ) X^{z} Y^{z}\right ) + \left ( X^{x} Y^{y} - X^{y} Y^{x}\right ) \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y} + \left ( X^{x} Y^{z} - X^{z} Y^{x}\right ) \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{z} + \left ( X^{y} Y^{z} - X^{z} Y^{y}\right ) \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} \end{equation*}

In [22]:
operator.xor(X, Y) # X ^ Y


Out[22]:
\begin{equation*} \left ( X^{x} Y^{y} - X^{y} Y^{x}\right ) \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y} + \left ( X^{x} Y^{z} - X^{z} Y^{x}\right ) \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{z} + \left ( X^{y} Y^{z} - X^{z} Y^{y}\right ) \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} \end{equation*}

In [23]:
operator.or_(X, Y) # X | Y


Out[23]:
\begin{equation*} \left ( e_{x}\cdot e_{x}\right ) X^{x} Y^{x} + \left ( e_{x}\cdot e_{y}\right ) X^{x} Y^{y} + \left ( e_{x}\cdot e_{y}\right ) X^{y} Y^{x} + \left ( e_{x}\cdot e_{z}\right ) X^{x} Y^{z} + \left ( e_{x}\cdot e_{z}\right ) X^{z} Y^{x} + \left ( e_{y}\cdot e_{y}\right ) X^{y} Y^{y} + \left ( e_{y}\cdot e_{z}\right ) X^{y} Y^{z} + \left ( e_{y}\cdot e_{z}\right ) X^{z} Y^{y} + \left ( e_{z}\cdot e_{z}\right ) X^{z} Y^{z} \end{equation*}

In [24]:
operator.lt(X, Y) # X < Y


Out[24]:
\begin{equation*} \left ( e_{x}\cdot e_{x}\right ) X^{x} Y^{x} + \left ( e_{x}\cdot e_{y}\right ) X^{x} Y^{y} + \left ( e_{x}\cdot e_{y}\right ) X^{y} Y^{x} + \left ( e_{x}\cdot e_{z}\right ) X^{x} Y^{z} + \left ( e_{x}\cdot e_{z}\right ) X^{z} Y^{x} + \left ( e_{y}\cdot e_{y}\right ) X^{y} Y^{y} + \left ( e_{y}\cdot e_{z}\right ) X^{y} Y^{z} + \left ( e_{y}\cdot e_{z}\right ) X^{z} Y^{y} + \left ( e_{z}\cdot e_{z}\right ) X^{z} Y^{z} \end{equation*}

In [25]:
operator.add(V0, V1)


Out[25]:
\begin{equation*} V_{0} + V^{x}_{1} \boldsymbol{e}_{x} + V^{y}_{1} \boldsymbol{e}_{y} + V^{z}_{1} \boldsymbol{e}_{z} \end{equation*}

In [26]:
operator.eq(I2[:norm](), g3d[:I]()[:norm]())


Out[26]:
false

In [27]:
operator.sub(I2[:norm](), g3d[:I]())


Out[27]:
\begin{equation*} \left|{I^{xyz}_{2}}\right| \sqrt{\left|{- \left ( e_{x}\cdot e_{x}\right ) \left ( e_{y}\cdot e_{y}\right ) \left ( e_{z}\cdot e_{z}\right ) + \left ( e_{x}\cdot e_{x}\right ) \left ( e_{y}\cdot e_{z}\right ) ^{2} + \left ( e_{x}\cdot e_{y}\right ) ^{2} \left ( e_{z}\cdot e_{z}\right ) - 2 \left ( e_{x}\cdot e_{y}\right ) \left ( e_{x}\cdot e_{z}\right ) \left ( e_{y}\cdot e_{z}\right ) + \left ( e_{x}\cdot e_{z}\right ) ^{2} \left ( e_{y}\cdot e_{y}\right ) }\right|} - \frac{1}{\sqrt{\left ( e_{x}\cdot e_{x}\right ) \left ( e_{y}\cdot e_{y}\right ) \left ( e_{z}\cdot e_{z}\right ) - \left ( e_{x}\cdot e_{x}\right ) \left ( e_{y}\cdot e_{z}\right ) ^{2} - \left ( e_{x}\cdot e_{y}\right ) ^{2} \left ( e_{z}\cdot e_{z}\right ) + 2 \left ( e_{x}\cdot e_{y}\right ) \left ( e_{x}\cdot e_{z}\right ) \left ( e_{y}\cdot e_{z}\right ) - \left ( e_{x}\cdot e_{z}\right ) ^{2} \left ( e_{y}\cdot e_{y}\right ) }} \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} \end{equation*}

In [28]:
symbols=sympy.symbols
Ga=ga.Ga
o3d = Ga("e_x e_y e_z", g=[1, 1, 1], coords=symbols("x y z"))


Out[28]:
PyObject <ga.Ga object at 0x318908d10>

In [29]:
(ex, ey, ez) = o3d[:mv]()


Out[29]:
3-element Array{Any,1}:
 PyObject e_x
 PyObject e_y
 PyObject e_z

In [30]:
[display(e) for e in (ex, ey, ez)]


\begin{equation*} \boldsymbol{e}_{x} \end{equation*}
\begin{equation*} \boldsymbol{e}_{y} \end{equation*}
\begin{equation*} \boldsymbol{e}_{z} \end{equation*}
Out[30]:
3-element Array{Any,1}:
 nothing
 nothing
 nothing

In [31]:
o3dmv=o3d[:mv]


Out[31]:
PyObject <bound method Ga.mv of <ga.Ga object at 0x318908d10>>

In [32]:
f = o3dmv("f", "scalar", f=true)


Out[32]:
\begin{equation*} f = f {\left (x,y,z \right )} \end{equation*}

In [33]:
A = o3dmv("A", "vector", f=true)


Out[33]:
\begin{equation*} A = A^{x} {\left (x,y,z \right )} \boldsymbol{e}_{x} + A^{y} {\left (x,y,z \right )} \boldsymbol{e}_{y} + A^{z} {\left (x,y,z \right )} \boldsymbol{e}_{z} \end{equation*}

In [34]:
B = o3dmv("B", "bivector", f=true)


Out[34]:
\begin{equation*} B = B^{xy} {\left (x,y,z \right )} \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y} + B^{xz} {\left (x,y,z \right )} \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{z} + B^{yz} {\left (x,y,z \right )} \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} \end{equation*}

In [35]:
C = o3dmv("C", "mv", f=true)


Out[35]:
\begin{equation*} C = C {\left (x,y,z \right )} + C^{x} {\left (x,y,z \right )} \boldsymbol{e}_{x} + C^{y} {\left (x,y,z \right )} \boldsymbol{e}_{y} + C^{z} {\left (x,y,z \right )} \boldsymbol{e}_{z} + C^{xy} {\left (x,y,z \right )} \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y} + C^{xz} {\left (x,y,z \right )} \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{z} + C^{yz} {\left (x,y,z \right )} \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} + C^{xyz} {\left (x,y,z \right )} \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} \end{equation*}

In [36]:
grad = o3d[:grad]


Out[36]:
\begin{equation*} e_x D{x} + e_y D{y} + e_z D{z} \end{equation*}

In [37]:
operator.mul(grad, f)


Out[37]:
\begin{equation*} \frac{\partial}{\partial x} f {\left (x,y,z \right )} \boldsymbol{e}_{x} + \frac{\partial}{\partial y} f {\left (x,y,z \right )} \boldsymbol{e}_{y} + \frac{\partial}{\partial z} f {\left (x,y,z \right )} \boldsymbol{e}_{z} \end{equation*}

In [38]:
operator.or_(grad, A)


Out[38]:
\begin{equation*} \frac{\partial}{\partial x} A^{x} {\left (x,y,z \right )} + \frac{\partial}{\partial y} A^{y} {\left (x,y,z \right )} + \frac{\partial}{\partial z} A^{z} {\left (x,y,z \right )} \end{equation*}

In [39]:
operator.mul(grad, A)


Out[39]:
\begin{equation*} \left ( \frac{\partial}{\partial x} A^{x} {\left (x,y,z \right )} + \frac{\partial}{\partial y} A^{y} {\left (x,y,z \right )} + \frac{\partial}{\partial z} A^{z} {\left (x,y,z \right )}\right ) + \left ( - \frac{\partial}{\partial y} A^{x} {\left (x,y,z \right )} + \frac{\partial}{\partial x} A^{y} {\left (x,y,z \right )}\right ) \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y} + \left ( - \frac{\partial}{\partial z} A^{x} {\left (x,y,z \right )} + \frac{\partial}{\partial x} A^{z} {\left (x,y,z \right )}\right ) \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{z} + \left ( - \frac{\partial}{\partial z} A^{y} {\left (x,y,z \right )} + \frac{\partial}{\partial y} A^{z} {\left (x,y,z \right )}\right ) \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} \end{equation*}

In [40]:
o3d[:E]()


Out[40]:
\begin{equation*} \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} \end{equation*}

In [41]:
o3d[:I]()


Out[41]:
\begin{equation*} \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} \end{equation*}

In [42]:
o3d[:E]() == o3d[:I]()


Out[42]:
true

In [43]:
for op in [operator.mul, operator.xor, operator.or_]
    op_name = op[:__name__]
    display(IJulia.text_markdown,"operator.$op_name(grad, B)=")
    display(op(grad, B))
end


operator.mul(grad, B)=

\begin{equation*} \left ( - \frac{\partial}{\partial y} B^{xy} {\left (x,y,z \right )} - \frac{\partial}{\partial z} B^{xz} {\left (x,y,z \right )}\right ) \boldsymbol{e}_{x} + \left ( \frac{\partial}{\partial x} B^{xy} {\left (x,y,z \right )} - \frac{\partial}{\partial z} B^{yz} {\left (x,y,z \right )}\right ) \boldsymbol{e}_{y} + \left ( \frac{\partial}{\partial x} B^{xz} {\left (x,y,z \right )} + \frac{\partial}{\partial y} B^{yz} {\left (x,y,z \right )}\right ) \boldsymbol{e}_{z} + \left ( \frac{\partial}{\partial z} B^{xy} {\left (x,y,z \right )} - \frac{\partial}{\partial y} B^{xz} {\left (x,y,z \right )} + \frac{\partial}{\partial x} B^{yz} {\left (x,y,z \right )}\right ) \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} \end{equation*}

operator.xor(grad, B)=

\begin{equation*} \left ( \frac{\partial}{\partial z} B^{xy} {\left (x,y,z \right )} - \frac{\partial}{\partial y} B^{xz} {\left (x,y,z \right )} + \frac{\partial}{\partial x} B^{yz} {\left (x,y,z \right )}\right ) \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} \end{equation*}

operator.or_(grad, B)=

\begin{equation*} \left ( - \frac{\partial}{\partial y} B^{xy} {\left (x,y,z \right )} - \frac{\partial}{\partial z} B^{xz} {\left (x,y,z \right )}\right ) \boldsymbol{e}_{x} + \left ( \frac{\partial}{\partial x} B^{xy} {\left (x,y,z \right )} - \frac{\partial}{\partial z} B^{yz} {\left (x,y,z \right )}\right ) \boldsymbol{e}_{y} + \left ( \frac{\partial}{\partial x} B^{xz} {\left (x,y,z \right )} + \frac{\partial}{\partial y} B^{yz} {\left (x,y,z \right )}\right ) \boldsymbol{e}_{z} \end{equation*}

In [44]:
using PyCall
@pyimport ga
@pyimport printer

pyeval("""
Ga('e*x|y|z')
""", Ga=ga.Ga)


Out[44]:
PyObject <ga.Ga object at 0x3191046d0>

In [45]:
pyeval("""
A|B
""", A=A, B=B)


Out[45]:
\begin{equation*} \left ( - A^{y} {\left (x,y,z \right )} B^{xy} {\left (x,y,z \right )} - A^{z} {\left (x,y,z \right )} B^{xz} {\left (x,y,z \right )}\right ) \boldsymbol{e}_{x} + \left ( A^{x} {\left (x,y,z \right )} B^{xy} {\left (x,y,z \right )} - A^{z} {\left (x,y,z \right )} B^{yz} {\left (x,y,z \right )}\right ) \boldsymbol{e}_{y} + \left ( A^{x} {\left (x,y,z \right )} B^{xz} {\left (x,y,z \right )} + A^{y} {\left (x,y,z \right )} B^{yz} {\left (x,y,z \right )}\right ) \boldsymbol{e}_{z} \end{equation*}

In [46]:
[display(v) for v in [grad, f, A, B, C]]


\begin{equation*} e_x D{x} + e_y D{y} + e_z D{z} \end{equation*}
\begin{equation*} f = f {\left (x,y,z \right )} \end{equation*}
\begin{equation*} A = A^{x} {\left (x,y,z \right )} \boldsymbol{e}_{x} + A^{y} {\left (x,y,z \right )} \boldsymbol{e}_{y} + A^{z} {\left (x,y,z \right )} \boldsymbol{e}_{z} \end{equation*}
\begin{equation*} B = B^{xy} {\left (x,y,z \right )} \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y} + B^{xz} {\left (x,y,z \right )} \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{z} + B^{yz} {\left (x,y,z \right )} \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} \end{equation*}
\begin{equation*} C = C {\left (x,y,z \right )} + C^{x} {\left (x,y,z \right )} \boldsymbol{e}_{x} + C^{y} {\left (x,y,z \right )} \boldsymbol{e}_{y} + C^{z} {\left (x,y,z \right )} \boldsymbol{e}_{z} + C^{xy} {\left (x,y,z \right )} \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y} + C^{xz} {\left (x,y,z \right )} \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{z} + C^{yz} {\left (x,y,z \right )} \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} + C^{xyz} {\left (x,y,z \right )} \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} \end{equation*}
Out[46]:
5-element Array{Any,1}:
 nothing
 nothing
 nothing
 nothing
 nothing

In [47]:
for expr in ["grad * f",
"grad | A",
"grad * A",
"-o3d.E() * (grad ^ A)",
"grad * B",
"grad ^ B",
"grad | B",
"grad < A",
"grad > A",
"grad < B",
"grad > B",
"grad < C",
"grad > C"]
    display(IJulia.text_markdown, "`$expr` = ")
    display(pyeval(expr, grad=grad, A=A, B=B, C=C, f=f, o3d=o3d))
end


grad * f =

\begin{equation*} \frac{\partial}{\partial x} f {\left (x,y,z \right )} \boldsymbol{e}_{x} + \frac{\partial}{\partial y} f {\left (x,y,z \right )} \boldsymbol{e}_{y} + \frac{\partial}{\partial z} f {\left (x,y,z \right )} \boldsymbol{e}_{z} \end{equation*}

grad | A =

\begin{equation*} \frac{\partial}{\partial x} A^{x} {\left (x,y,z \right )} + \frac{\partial}{\partial y} A^{y} {\left (x,y,z \right )} + \frac{\partial}{\partial z} A^{z} {\left (x,y,z \right )} \end{equation*}

grad * A =

\begin{equation*} \left ( \frac{\partial}{\partial x} A^{x} {\left (x,y,z \right )} + \frac{\partial}{\partial y} A^{y} {\left (x,y,z \right )} + \frac{\partial}{\partial z} A^{z} {\left (x,y,z \right )}\right ) + \left ( - \frac{\partial}{\partial y} A^{x} {\left (x,y,z \right )} + \frac{\partial}{\partial x} A^{y} {\left (x,y,z \right )}\right ) \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y} + \left ( - \frac{\partial}{\partial z} A^{x} {\left (x,y,z \right )} + \frac{\partial}{\partial x} A^{z} {\left (x,y,z \right )}\right ) \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{z} + \left ( - \frac{\partial}{\partial z} A^{y} {\left (x,y,z \right )} + \frac{\partial}{\partial y} A^{z} {\left (x,y,z \right )}\right ) \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} \end{equation*}

-o3d.E() * (grad ^ A) =

\begin{equation*} \left ( - \frac{\partial}{\partial z} A^{y} {\left (x,y,z \right )} + \frac{\partial}{\partial y} A^{z} {\left (x,y,z \right )}\right ) \boldsymbol{e}_{x} + \left ( \frac{\partial}{\partial z} A^{x} {\left (x,y,z \right )} - \frac{\partial}{\partial x} A^{z} {\left (x,y,z \right )}\right ) \boldsymbol{e}_{y} + \left ( - \frac{\partial}{\partial y} A^{x} {\left (x,y,z \right )} + \frac{\partial}{\partial x} A^{y} {\left (x,y,z \right )}\right ) \boldsymbol{e}_{z} \end{equation*}

grad * B =

\begin{equation*} \left ( - \frac{\partial}{\partial y} B^{xy} {\left (x,y,z \right )} - \frac{\partial}{\partial z} B^{xz} {\left (x,y,z \right )}\right ) \boldsymbol{e}_{x} + \left ( \frac{\partial}{\partial x} B^{xy} {\left (x,y,z \right )} - \frac{\partial}{\partial z} B^{yz} {\left (x,y,z \right )}\right ) \boldsymbol{e}_{y} + \left ( \frac{\partial}{\partial x} B^{xz} {\left (x,y,z \right )} + \frac{\partial}{\partial y} B^{yz} {\left (x,y,z \right )}\right ) \boldsymbol{e}_{z} + \left ( \frac{\partial}{\partial z} B^{xy} {\left (x,y,z \right )} - \frac{\partial}{\partial y} B^{xz} {\left (x,y,z \right )} + \frac{\partial}{\partial x} B^{yz} {\left (x,y,z \right )}\right ) \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} \end{equation*}

grad ^ B =

\begin{equation*} \left ( \frac{\partial}{\partial z} B^{xy} {\left (x,y,z \right )} - \frac{\partial}{\partial y} B^{xz} {\left (x,y,z \right )} + \frac{\partial}{\partial x} B^{yz} {\left (x,y,z \right )}\right ) \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} \end{equation*}

grad | B =

\begin{equation*} \left ( - \frac{\partial}{\partial y} B^{xy} {\left (x,y,z \right )} - \frac{\partial}{\partial z} B^{xz} {\left (x,y,z \right )}\right ) \boldsymbol{e}_{x} + \left ( \frac{\partial}{\partial x} B^{xy} {\left (x,y,z \right )} - \frac{\partial}{\partial z} B^{yz} {\left (x,y,z \right )}\right ) \boldsymbol{e}_{y} + \left ( \frac{\partial}{\partial x} B^{xz} {\left (x,y,z \right )} + \frac{\partial}{\partial y} B^{yz} {\left (x,y,z \right )}\right ) \boldsymbol{e}_{z} \end{equation*}

grad < A =

\begin{equation*} \frac{\partial}{\partial x} A^{x} {\left (x,y,z \right )} + \frac{\partial}{\partial y} A^{y} {\left (x,y,z \right )} + \frac{\partial}{\partial z} A^{z} {\left (x,y,z \right )} \end{equation*}

grad > A =

\begin{equation*} \frac{\partial}{\partial x} A^{x} {\left (x,y,z \right )} + \frac{\partial}{\partial y} A^{y} {\left (x,y,z \right )} + \frac{\partial}{\partial z} A^{z} {\left (x,y,z \right )} \end{equation*}

grad < B =

\begin{equation*} \left ( - \frac{\partial}{\partial y} B^{xy} {\left (x,y,z \right )} - \frac{\partial}{\partial z} B^{xz} {\left (x,y,z \right )}\right ) \boldsymbol{e}_{x} + \left ( \frac{\partial}{\partial x} B^{xy} {\left (x,y,z \right )} - \frac{\partial}{\partial z} B^{yz} {\left (x,y,z \right )}\right ) \boldsymbol{e}_{y} + \left ( \frac{\partial}{\partial x} B^{xz} {\left (x,y,z \right )} + \frac{\partial}{\partial y} B^{yz} {\left (x,y,z \right )}\right ) \boldsymbol{e}_{z} \end{equation*}

grad > B =

\begin{equation*} 0 \end{equation*}

grad < C =

\begin{equation*} \left ( \frac{\partial}{\partial x} C^{x} {\left (x,y,z \right )} + \frac{\partial}{\partial y} C^{y} {\left (x,y,z \right )} + \frac{\partial}{\partial z} C^{z} {\left (x,y,z \right )}\right ) + \left ( - \frac{\partial}{\partial y} C^{xy} {\left (x,y,z \right )} - \frac{\partial}{\partial z} C^{xz} {\left (x,y,z \right )}\right ) \boldsymbol{e}_{x} + \left ( \frac{\partial}{\partial x} C^{xy} {\left (x,y,z \right )} - \frac{\partial}{\partial z} C^{yz} {\left (x,y,z \right )}\right ) \boldsymbol{e}_{y} + \left ( \frac{\partial}{\partial x} C^{xz} {\left (x,y,z \right )} + \frac{\partial}{\partial y} C^{yz} {\left (x,y,z \right )}\right ) \boldsymbol{e}_{z} + \frac{\partial}{\partial z} C^{xyz} {\left (x,y,z \right )} \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y} - \frac{\partial}{\partial y} C^{xyz} {\left (x,y,z \right )} \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{z} + \frac{\partial}{\partial x} C^{xyz} {\left (x,y,z \right )} \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} \end{equation*}

grad > C =

\begin{equation*} \left ( \frac{\partial}{\partial x} C^{x} {\left (x,y,z \right )} + \frac{\partial}{\partial y} C^{y} {\left (x,y,z \right )} + \frac{\partial}{\partial z} C^{z} {\left (x,y,z \right )}\right ) + \frac{\partial}{\partial x} C {\left (x,y,z \right )} \boldsymbol{e}_{x} + \frac{\partial}{\partial y} C {\left (x,y,z \right )} \boldsymbol{e}_{y} + \frac{\partial}{\partial z} C {\left (x,y,z \right )} \boldsymbol{e}_{z} \end{equation*}

In [48]:
locals = PyDict(Dict(:grad=>grad, :f=>f))
for expr in ["grad * f"]
    display(IJulia.text_markdown, "`$expr` = ")
    display(PyCall.pyeval_(expr, locals, PyCall.Py_eval_input))
end


grad * f =

\begin{equation*} \frac{\partial}{\partial x} f {\left (x,y,z \right )} \boldsymbol{e}_{x} + \frac{\partial}{\partial y} f {\left (x,y,z \right )} \boldsymbol{e}_{y} + \frac{\partial}{\partial z} f {\left (x,y,z \right )} \boldsymbol{e}_{z} \end{equation*}

In [49]:
locals = PyDict(Dict(:grad=>grad, :f=>f))
for expr in ["grad * f"]
    display(IJulia.text_markdown, "`$expr` = ")
    display(PyCall.pyeval_(expr, locals, PyCall.Py_single_input))
end


grad * f =

PyObject None
D{x}f*e_x + D{y}f*e_y + D{z}f*e_z

In [50]:
locals = PyDict(Dict(:grad=>grad, :f=>f))
for expr in ["grad * f"]
    display(IJulia.text_markdown, "`$expr` = ")
    display(PyCall.pyeval_(expr, locals, PyCall.Py_file_input))
end


grad * f =

PyObject None

In [51]:
vara = 1;varb = 2;
local_vars = PyDict(Dict(:vara=>vara, :varb=>varb))
PyCall.pyeval_("vara + varb", local_vars, PyCall.Py_single_input)


3
Out[51]:
PyObject None

In [52]:
vara = 1;varb = 2;
local_vars = PyDict(Dict(:vara=>vara, :varb=>varb))
PyCall.pyeval_("vara + varb", local_vars, PyCall.Py_eval_input)


Out[52]:
PyObject 3

In [53]:
vara = 1;varb = 2;
local_vars = PyDict(Dict(:vara=>vara, :varb=>varb))
PyCall.pyeval_("vara + varb", local_vars, PyCall.Py_file_input)


Out[53]:
PyObject None

In [54]:
X = (r, th, phi) = symbols("r theta phi")


Out[54]:
(PyObject r,PyObject theta,PyObject phi)

In [55]:
s3d = pyeval("""
Ga('e_r e_theta e_phi', g=[1, r ** 2, r ** 2 * sin(th) ** 2], coords=X, norm=True)
""", r=r, th=th, phi=phi, X=X, Ga=ga.Ga, sin=sympy.sin)


Out[55]:
PyObject <ga.Ga object at 0x31910e890>

In [56]:
(er, eth, ephi) = s3d[:mv]()


Out[56]:
3-element Array{Any,1}:
 PyObject e_r    
 PyObject e_theta
 PyObject e_phi  

In [57]:
grad = s3d[:grad]


Out[57]:
\begin{equation*} e_r D{r} + e_theta 1/r*D{theta} + e_phi 1/(r*sin(theta))*D{phi} \end{equation*}

In [58]:
f = s3d[:mv]("f", "scalar", f=true)
A = s3d[:mv]("A", "vector", f=true)
B = s3d[:mv]("B", "bivector", f=true)


Out[58]:
\begin{equation*} B = B^{r\theta } {\left (r,\theta ,\phi \right )} \boldsymbol{e}_{r}\wedge \boldsymbol{e}_{\theta } + B^{r\phi } {\left (r,\theta ,\phi \right )} \boldsymbol{e}_{r}\wedge \boldsymbol{e}_{\phi } + B^{\phi \phi } {\left (r,\theta ,\phi \right )} \boldsymbol{e}_{\theta }\wedge \boldsymbol{e}_{\phi } \end{equation*}

In [59]:
pyeval("grad*f", grad=grad, f=f)


Out[59]:
\begin{equation*} \frac{\partial}{\partial r} f {\left (r,\theta ,\phi \right )} \boldsymbol{e}_{r} + \frac{1}{r} \frac{\partial}{\partial \theta } f {\left (r,\theta ,\phi \right )} \boldsymbol{e}_{\theta } + \frac{\frac{\partial}{\partial \phi } f {\left (r,\theta ,\phi \right )}}{r \sin{\left (\theta \right )}} \boldsymbol{e}_{\phi } \end{equation*}

In [60]:
pyeval("grad|A", grad=grad, A=A)


Out[60]:
\begin{equation*} \frac{1}{r} \left(r \frac{\partial}{\partial r} A^{r} {\left (r,\theta ,\phi \right )} + 2 A^{r} {\left (r,\theta ,\phi \right )} + \frac{A^{\theta } {\left (r,\theta ,\phi \right )}}{\tan{\left (\theta \right )}} + \frac{\partial}{\partial \theta } A^{\theta } {\left (r,\theta ,\phi \right )} + \frac{1}{\sin{\left (\theta \right )}} \frac{\partial}{\partial \phi } A^{\phi } {\left (r,\theta ,\phi \right )}\right) \end{equation*}

In [61]:
pyeval("(grad|A).simplify()", grad=grad, A=A)


Out[61]:
\begin{equation*} \frac{1}{r} \left(r \frac{\partial}{\partial r} A^{r} {\left (r,\theta ,\phi \right )} + 2 A^{r} {\left (r,\theta ,\phi \right )} + \frac{A^{\theta } {\left (r,\theta ,\phi \right )}}{\tan{\left (\theta \right )}} + \frac{\partial}{\partial \theta } A^{\theta } {\left (r,\theta ,\phi \right )} + \frac{1}{\sin{\left (\theta \right )}} \frac{\partial}{\partial \phi } A^{\phi } {\left (r,\theta ,\phi \right )}\right) \end{equation*}

In [62]:
pyeval("str(grad|A)", grad=grad, A=A)


Out[62]:
"D{r}A__r + (A__r + D{theta}A__theta)/r + (A__r*sin(theta) + A__theta*cos(theta) + D{phi}A__phi)/(r*sin(theta))"

In [63]:
pyeval("str((grad|A).simplify())", grad=grad, A=A)


Out[63]:
"(r*D{r}A__r + 2*A__r + A__theta/tan(theta) + D{theta}A__theta + D{phi}A__phi/sin(theta))/r"

In [64]:
pyeval("-s3d.I()*(grad^A)", A=A, grad=grad, s3d=s3d)


Out[64]:
\begin{equation*} \frac{1}{r} \left(\frac{A^{\phi } {\left (r,\theta ,\phi \right )}}{\tan{\left (\theta \right )}} + \frac{\partial}{\partial \theta } A^{\phi } {\left (r,\theta ,\phi \right )} - \frac{1}{\sin{\left (\theta \right )}} \frac{\partial}{\partial \phi } A^{\theta } {\left (r,\theta ,\phi \right )}\right) \boldsymbol{e}_{r} + \frac{1}{r} \left(- r \frac{\partial}{\partial r} A^{\phi } {\left (r,\theta ,\phi \right )} - A^{\phi } {\left (r,\theta ,\phi \right )} + \frac{1}{\sin{\left (\theta \right )}} \frac{\partial}{\partial \phi } A^{r} {\left (r,\theta ,\phi \right )}\right) \boldsymbol{e}_{\theta } + \frac{1}{r} \left(r \frac{\partial}{\partial r} A^{\theta } {\left (r,\theta ,\phi \right )} + A^{\theta } {\left (r,\theta ,\phi \right )} - \frac{\partial}{\partial \theta } A^{r} {\left (r,\theta ,\phi \right )}\right) \boldsymbol{e}_{\phi } \end{equation*}

In [65]:
assertion = "((A__phi*cos(theta)/sin(theta) + D{theta}A__phi - D{phi}A__theta/sin(theta))/r)*e_r + (-D{r}A__phi - A__phi/r + D{phi}A__r/(r*sin(theta)))*e_theta + (D{r}A__theta + A__theta/r - D{theta}A__r/r)*e_phi"


Out[65]:
"((A__phi*cos(theta)/sin(theta) + D{theta}A__phi - D{phi}A__theta/sin(theta))/r)*e_r + (-D{r}A__phi - A__phi/r + D{phi}A__r/(r*sin(theta)))*e_theta + (D{r}A__theta + A__theta/r - D{theta}A__r/r)*e_phi"

In [66]:
pyeval("str(-s3d.I()*(grad^A))", A=A, grad=grad, s3d=s3d)


Out[66]:
"(A__phi/tan(theta) + D{theta}A__phi - D{phi}A__theta/sin(theta))*e_r/r + (-r*D{r}A__phi - A__phi + D{phi}A__r/sin(theta))*e_theta/r + (r*D{r}A__theta + A__theta - D{theta}A__r)*e_phi/r"

In [67]:
pyeval("str((-s3d.I()*(grad^A)).simplify())", A=A, grad=grad, s3d=s3d)


Out[67]:
"(A__phi/tan(theta) + D{theta}A__phi - D{phi}A__theta/sin(theta))*e_r/r + (-r*D{r}A__phi - A__phi + D{phi}A__r/sin(theta))*e_theta/r + (r*D{r}A__theta + A__theta - D{theta}A__r)*e_phi/r"

In [68]:
assertion = "(D{r}B__thetaphi - B__rphi*cos(theta)/(r*sin(theta)) + 2*B__thetaphi/r - D{theta}B__rphi/r + D{phi}B__rtheta/(r*sin(theta)))*e_r^e_theta^e_phi"


Out[68]:
"(D{r}B__thetaphi - B__rphi*cos(theta)/(r*sin(theta)) + 2*B__thetaphi/r - D{theta}B__rphi/r + D{phi}B__rtheta/(r*sin(theta)))*e_r^e_theta^e_phi"

In [69]:
pyeval("grad^B", grad=grad, B=B)


Out[69]:
\begin{equation*} \frac{1}{r} \left(r \frac{\partial}{\partial r} B^{\phi \phi } {\left (r,\theta ,\phi \right )} - \frac{B^{r\phi } {\left (r,\theta ,\phi \right )}}{\tan{\left (\theta \right )}} + 2 B^{\phi \phi } {\left (r,\theta ,\phi \right )} - \frac{\partial}{\partial \theta } B^{r\phi } {\left (r,\theta ,\phi \right )} + \frac{1}{\sin{\left (\theta \right )}} \frac{\partial}{\partial \phi } B^{r\theta } {\left (r,\theta ,\phi \right )}\right) \boldsymbol{e}_{r}\wedge \boldsymbol{e}_{\theta }\wedge \boldsymbol{e}_{\phi } \end{equation*}

In [70]:
@pyimport printer

In [71]:
printer.print_latex


Out[71]:
PyObject <function print_latex at 0x30cc139b0>

In [72]:
pyeval("print_latex(grad^B)", grad=grad, B=B, print_latex=printer.print_latex)


\frac{1}{r} \left(r \frac{\partial}{\partial r} B^{\phi \phi } {\left (r,\theta ,\phi  \right )} - \frac{B^{r\phi } {\left (r,\theta ,\phi  \right )}}{\tan{\left (\theta  \right )}} + 2 B^{\phi \phi } {\left (r,\theta ,\phi  \right )} - \frac{\partial}{\partial \theta } B^{r\phi } {\left (r,\theta ,\phi  \right )} + \frac{1}{\sin{\left (\theta  \right )}} \frac{\partial}{\partial \phi } B^{r\theta } {\left (r,\theta ,\phi  \right )}\right) \boldsymbol{e}_{r}\wedge \boldsymbol{e}_{\theta }\wedge \boldsymbol{e}_{\phi }

In [73]:
pyeval("str(grad^B)", grad=grad, B=B)


Out[73]:
"(r*D{r}B__thetaphi - B__rphi/tan(theta) + 2*B__thetaphi - D{theta}B__rphi + D{phi}B__rtheta/sin(theta))*e_r^e_theta^e_phi/r"

In [74]:
printer.GaLatexPrinter[:split_super_sub]("B__thetaphi")


Out[74]:
("*",Any["B"],
1x1 Array{Any,2}:
 "thetaphi",

1x0 Array{Any,2})

In [75]:
printer.GaLatexPrinter[:latex]("B__thetaphi")


Out[75]:
"B__thetaphi"

In [76]:
printer.GaLatexPrinter[:special_alphabet]


Out[76]:
34-element Array{Any,1}:
 "upsilon"
 "omicron"
 "epsilon"
 "hslash" 
 "daleth" 
 "lambda" 
 "aleph"  
 "infty"  
 "gimel"  
 "gamma"  
 "sigma"  
 "kappa"  
 "omega"  
 ⋮        
 "ell"    
 "mho"    
 "eta"    
 "rho"    
 "psi"    
 "phi"    
 "chi"    
 "tau"    
 "mu"     
 "nu"     
 "pi"     
 "xi"     

In [79]:
pyeval("B", grad=grad, B=B)


Out[79]:
\begin{equation*} B = B^{r\theta } {\left (r,\theta ,\phi \right )} \boldsymbol{e}_{r}\wedge \boldsymbol{e}_{\theta } + B^{r\phi } {\left (r,\theta ,\phi \right )} \boldsymbol{e}_{r}\wedge \boldsymbol{e}_{\phi } + B^{\phi \phi } {\left (r,\theta ,\phi \right )} \boldsymbol{e}_{\theta }\wedge \boldsymbol{e}_{\phi } \end{equation*}

In [81]:
pyeval("B|(eth^ephi)", grad=grad, B=B, er=er, eth=eth, ephi=ephi)


Out[81]:
\begin{equation*} - B^{\phi \phi } {\left (r,\theta ,\phi \right )} \end{equation*}

In [82]:
pyeval("str(B|(eth^ephi))", grad=grad, B=B, er=er, eth=eth, ephi=ephi)


Out[82]:
"-B__thetaphi"

In [83]:
pyeval("print_latex(B|(eth^ephi))", grad=grad, B=B, er=er, eth=eth, ephi=ephi, print_latex=printer.print_latex)


- B^{\phi \phi } {\left (r,\theta ,\phi  \right )}

In [87]:
pyeval("GaLatexPrinter().", GaLatexPrinter=printer.GaLatexPrinter)


Out[87]:
PyObject <printer.GaLatexPrinter object at 0x3191216d0>

In [91]:
g = "0 # #,# 0 #,# # 1"
necl = Ga("X Y e",g=g)
(X,Y,e) = necl[:mv]()


Out[91]:
3-element Array{Any,1}:
 PyObject X
 PyObject Y
 PyObject e

In [92]:
pyeval("str((X^Y)*(X^Y))", X=X, Y=Y)


Out[92]:
"(X.Y)**2"

In [93]:
L = pyeval("X^Y^e", X=X, Y=Y, e=e)


Out[93]:
\begin{equation*} \boldsymbol{X}\wedge \boldsymbol{Y}\wedge \boldsymbol{e} \end{equation*}

In [94]:
B = pyeval("L*e", X=X, Y=Y, e=e, L=L)


Out[94]:
\begin{equation*} \boldsymbol{X}\wedge \boldsymbol{Y} - \left ( Y\cdot e\right ) \boldsymbol{X}\wedge \boldsymbol{e} + \left ( X\cdot e\right ) \boldsymbol{Y}\wedge \boldsymbol{e} \end{equation*}

In [96]:
pyeval("str(B)", B=B)


Out[96]:
"X^Y - (Y.e)*X^e + (X.e)*Y^e"

In [97]:
Bsq = pyeval("B * B", B=B)


Out[97]:
\begin{equation*} \left ( X\cdot Y\right ) \left(\left ( X\cdot Y\right ) - 2 \left ( X\cdot e\right ) \left ( Y\cdot e\right ) \right) \end{equation*}

In [98]:
Bsq[:scalar]()


Out[98]:
PyObject (X.Y)**2 - 2*(X.Y)*(X.e)*(Y.e)

In [99]:
BeBr = pyeval("B*e*B.rev()", B=B, e=e)


Out[99]:
\begin{equation*} \left ( X\cdot Y\right ) \left(- \left ( X\cdot Y\right ) + 2 \left ( X\cdot e\right ) \left ( Y\cdot e\right ) \right) \boldsymbol{e} \end{equation*}

In [100]:
pyeval("str(BeBr)", BeBr=BeBr)


Out[100]:
"(X.Y)*(-(X.Y) + 2*(X.e)*(Y.e))*e"

In [101]:
pyeval("str(L * L)", L=L)


Out[101]:
"(X.Y)**2 - 2*(X.Y)*(X.e)*(Y.e)"

In [102]:
(s,c,Binv,M,S,C,alpha,XdotY,Xdote,Ydote) = symbols("s c (1/B) M S C alpha (X.Y) (X.e) (Y.e)")


Out[102]:
(PyObject s,PyObject c,PyObject (1/B),PyObject M,PyObject S,PyObject C,PyObject alpha,PyObject (X.Y),PyObject (X.e),PyObject (Y.e))

In [103]:
Bhat = pyeval("Binv*B", Binv=Binv, B=B)


Out[103]:
\begin{equation*} (1/B) \boldsymbol{X}\wedge \boldsymbol{Y} - (1/B) \left ( Y\cdot e\right ) \boldsymbol{X}\wedge \boldsymbol{e} + (1/B) \left ( X\cdot e\right ) \boldsymbol{Y}\wedge \boldsymbol{e} \end{equation*}

In [104]:
R = pyeval("c+s*Bhat", c=c, s=s, Bhat=Bhat)


Out[104]:
\begin{equation*} c + (1/B) s \boldsymbol{X}\wedge \boldsymbol{Y} - (1/B) \left ( Y\cdot e\right ) s \boldsymbol{X}\wedge \boldsymbol{e} + (1/B) \left ( X\cdot e\right ) s \boldsymbol{Y}\wedge \boldsymbol{e} \end{equation*}

In [105]:
Z = pyeval("R*X*R.rev()", R=R, X=X)


Out[105]:
\begin{equation*} \left ( (1/B)^{2} \left ( X\cdot Y\right ) ^{2} s^{2} - 2 (1/B)^{2} \left ( X\cdot Y\right ) \left ( X\cdot e\right ) \left ( Y\cdot e\right ) s^{2} + 2 (1/B) \left ( X\cdot Y\right ) c s - 2 (1/B) \left ( X\cdot e\right ) \left ( Y\cdot e\right ) c s + c^{2}\right ) \boldsymbol{X} + 2 (1/B) \left ( X\cdot e\right ) ^{2} c s \boldsymbol{Y} + 2 (1/B) \left ( X\cdot Y\right ) \left ( X\cdot e\right ) s \left(- (1/B) \left ( X\cdot Y\right ) s + 2 (1/B) \left ( X\cdot e\right ) \left ( Y\cdot e\right ) s - c\right) \boldsymbol{e} \end{equation*}

In [107]:
pyeval("str(Z)", Z=Z)


Out[107]:
"((1/B)**2*(X.Y)**2*s**2 - 2*(1/B)**2*(X.Y)*(X.e)*(Y.e)*s**2 + 2*(1/B)*(X.Y)*c*s - 2*(1/B)*(X.e)*(Y.e)*c*s + c**2)*X + 2*(1/B)*(X.e)**2*c*s*Y + 2*(1/B)*(X.Y)*(X.e)*s*(-(1/B)*(X.Y)*s + 2*(1/B)*(X.e)*(Y.e)*s - c)*e"

In [110]:
pyeval("(Binv**2*(X|Y)**2*s**2 - 2*Binv**2*(X|Y)*(X|e)*(Y|e)*s**2 + 2*Binv*(X|Y)*c*s - 2*Binv*(X|e)*(Y|e)*c*s + c**2)*X + 2*Binv*(X|e)**2*c*s*Y + (2*Binv*(X|Y)*(X|e)*s*(-Binv*(X|Y)*s + 2*Binv*(X|e)*(Y|e)*s - c))*e == (Binv**2*(X|Y)**2*s**2 - 2*Binv**2*(X|Y)*(X|e)*(Y|e)*s**2 + 2*Binv*(X|Y)*c*s - 2*Binv*(X|e)*(Y|e)*c*s + c**2)*X + 2*Binv*(X|e)**2*c*s*Y + 2*Binv*(X|Y)*(X|e)*s*(-Binv*(X|Y)*s + 2*Binv*(X|e)*(Y|e)*s - c)*e", B=B, Binv=Binv, X=X, Y=Y, s=s, e=e, c=c)


Out[110]:
true

In [111]:
W = pyeval("(Z|Y).scalar()", Z=Z, Y=Y)


Out[111]:
PyObject (1/B)**2*(X.Y)**3*s**2 - 4*(1/B)**2*(X.Y)**2*(X.e)*(Y.e)*s**2 + 4*(1/B)**2*(X.Y)*(X.e)**2*(Y.e)**2*s**2 + 2*(1/B)*(X.Y)**2*c*s - 4*(1/B)*(X.Y)*(X.e)*(Y.e)*c*s + (X.Y)*c**2

In [112]:
pyeval("str(W)", W=W)


Out[112]:
"(1/B)**2*(X.Y)**3*s**2 - 4*(1/B)**2*(X.Y)**2*(X.e)*(Y.e)*s**2 + 4*(1/B)**2*(X.Y)*(X.e)**2*(Y.e)**2*s**2 + 2*(1/B)*(X.Y)**2*c*s - 4*(1/B)*(X.Y)*(X.e)*(Y.e)*c*s + (X.Y)*c**2"

In [113]:
Binv


Out[113]:
PyObject (1/B)

In [116]:
B[:inv]()


Out[116]:
\begin{equation*} \frac{1}{\left ( X\cdot Y\right ) \left(\left ( X\cdot Y\right ) - 2 \left ( X\cdot e\right ) \left ( Y\cdot e\right ) \right)} \boldsymbol{X}\wedge \boldsymbol{Y} - \frac{\left ( Y\cdot e\right ) }{\left ( X\cdot Y\right ) \left(\left ( X\cdot Y\right ) - 2 \left ( X\cdot e\right ) \left ( Y\cdot e\right ) \right)} \boldsymbol{X}\wedge \boldsymbol{e} + \frac{\left ( X\cdot e\right ) }{\left ( X\cdot Y\right ) \left(\left ( X\cdot Y\right ) - 2 \left ( X\cdot e\right ) \left ( Y\cdot e\right ) \right)} \boldsymbol{Y}\wedge \boldsymbol{e} \end{equation*}

In [117]:
B


Out[117]:
\begin{equation*} \boldsymbol{X}\wedge \boldsymbol{Y} - \left ( Y\cdot e\right ) \boldsymbol{X}\wedge \boldsymbol{e} + \left ( X\cdot e\right ) \boldsymbol{Y}\wedge \boldsymbol{e} \end{equation*}

In [118]:
pyeval("B * B.inv()", B=B)


Out[118]:
\begin{equation*} 1 \end{equation*}

In [120]:
expected = "(1/B)**2*(X.Y)**3*s**2 - 4*(1/B)**2*(X.Y)**2*(X.e)*(Y.e)*s**2 + 4*(1/B)**2*(X.Y)*(X.e)**2*(Y.e)**2*s**2 + 2*(1/B)*(X.Y)**2*c*s - 4*(1/B)*(X.Y)*(X.e)*(Y.e)*c*s + (X.Y)*c**2"
actual = pyeval("str(W)", W=W)


Out[120]:
"(1/B)**2*(X.Y)**3*s**2 - 4*(1/B)**2*(X.Y)**2*(X.e)*(Y.e)*s**2 + 4*(1/B)**2*(X.Y)*(X.e)**2*(Y.e)**2*s**2 + 2*(1/B)*(X.Y)**2*c*s - 4*(1/B)*(X.Y)*(X.e)*(Y.e)*c*s + (X.Y)*c**2"

In [121]:
@doc replace


Out[121]:
replace(string, pat, r[, n])

Search for the given pattern pat, and replace each occurrence with r. If n is provided, replace at most n occurrences. As with search, the second argument may be a single character, a vector or a set of characters, a string, or a regular expression. If r is a function, each occurrence is replaced with r(s) where s is the matched substring. If pat is a regular expression and r is a SubstitutionString, then capture group references in r are replaced with the corresponding matched text.


In [123]:
replace("(1/B)", r"\(1/B\)", "Binv")


Out[123]:
"Binv"

In [124]:
function exprize(str)
    tmp = replace(str, r"\(1/B\)", "Binv")
    tmp = replace(tmp, r"\.", "|")
    tmp
end


Out[124]:
exprize (generic function with 1 method)

In [125]:
expected = exprize(expected)
actual = exprize(actual)


Out[125]:
"Binv**2*(X|Y)**3*s**2 - 4*Binv**2*(X|Y)**2*(X|e)*(Y|e)*s**2 + 4*Binv**2*(X|Y)*(X|e)**2*(Y|e)**2*s**2 + 2*Binv*(X|Y)**2*c*s - 4*Binv*(X|Y)*(X|e)*(Y|e)*c*s + (X|Y)*c**2"

In [126]:
pyeval("$expected == $actual", Binv=Binv, X=X, Y=Y, e=e, s=s, c=c)


Out[126]:
true

In [137]:
epected = "(X.Y)*C - (X.e)*(Y.e)*C + (X.e)*(Y.e) + S*sqrt((X.Y)**2 - 2*(X.Y)*(X.e)*(Y.e))"
actual = "(1/B)*(X.Y)*C*sqrt((X.Y)**2 - 2*(X.Y)*(X.e)*(Y.e)) - (1/B)*(X.e)*(Y.e)*C*sqrt((X.Y)**2 - 2*(X.Y)*(X.e)*(Y.e)) + (1/B)*(X.e)*(Y.e)*sqrt((X.Y)**2 - 2*(X.Y)*(X.e)*(Y.e)) + S*sqrt((X.Y)**2 - 2*(X.Y)*(X.e)*(Y.e))"
expected = exprize(expected)
actual = exprize(actual)
@printf "%s\n%s\n" expected actual 
pyeval("$expected", Binv=Binv, X=X, Y=Y, e=e, s=s, c=c, C=C, sqrt=sympy.sqrt)


Binv**2*(X|Y)**3*s**2 - 4*Binv**2*(X|Y)**2*(X|e)*(Y|e)*s**2 + 4*Binv**2*(X|Y)*(X|e)**2*(Y|e)**2*s**2 + 2*Binv*(X|Y)**2*c*s - 4*Binv*(X|Y)*(X|e)*(Y|e)*c*s + (X|Y)*c**2
Binv*(X|Y)*C*sqrt((X|Y)**2 - 2*(X|Y)*(X|e)*(Y|e)) - Binv*(X|e)*(Y|e)*C*sqrt((X|Y)**2 - 2*(X|Y)*(X|e)*(Y|e)) + Binv*(X|e)*(Y|e)*sqrt((X|Y)**2 - 2*(X|Y)*(X|e)*(Y|e)) + S*sqrt((X|Y)**2 - 2*(X|Y)*(X|e)*(Y|e))
Out[137]:
\begin{equation*} \left ( X\cdot Y\right ) \left((1/B)^{2} \left ( X\cdot Y\right ) ^{2} s^{2} - 4 (1/B)^{2} \left ( X\cdot Y\right ) \left ( X\cdot e\right ) \left ( Y\cdot e\right ) s^{2} + 4 (1/B)^{2} \left ( X\cdot e\right ) ^{2} \left ( Y\cdot e\right ) ^{2} s^{2} + 2 (1/B) \left ( X\cdot Y\right ) c s - 4 (1/B) \left ( X\cdot e\right ) \left ( Y\cdot e\right ) c s + c^{2}\right) \end{equation*}

In [ ]: