1 | initial version |
From: sage/src/sage/calculus/test.py
def christoffel(i,j,k,vars,g):
s = 0
ginv = g^(-1)
for l in range(g.nrows()):
s = s + (1/2)*ginv[k,l]*(g[j,l].diff(vars[i])+g[i,l].diff(vars[j])-\
g[i,j].diff(vars[l]))
return s
var('th ph')
g = matrix(SR, [[1,0],[0,sin(th)^2]])
for i in [0,1]:
for j in [0,1]:
for k in[0,1]:
print((i,j,k),christoffel(i,j,k, [th,ph], g))
(0, 0, 0) 0
(0, 0, 1) 0
(0, 1, 0) 0
(0, 1, 1) cos(th)/sin(th)
(1, 0, 0) 0
(1, 0, 1) cos(th)/sin(th)
(1, 1, 0) -cos(th)*sin(th)
(1, 1, 1) 0
2 | No.2 Revision |
From: sage/src/sage/calculus/test.py
def christoffel(i,j,k,vars,g):
s = 0
ginv = g^(-1)
for l in range(g.nrows()):
s = s + (1/2)*ginv[k,l]*(g[j,l].diff(vars[i])+g[i,l].diff(vars[j])-\
g[i,j].diff(vars[l]))
return s
var('th ph')
g = matrix(SR, [[1,0],[0,sin(th)^2]])
for i in [0,1]:
for j in [0,1]:
for k in[0,1]:
print((i,j,k),christoffel(i,j,k, [th,ph], g))
(0, 0, 0) 0
(0, 0, 1) 0
(0, 1, 0) 0
(0, 1, 1) cos(th)/sin(th)
(1, 0, 0) 0
(1, 0, 1) cos(th)/sin(th)
(1, 1, 0) -cos(th)*sin(th)
(1, 1, 1) 0
SageManifolds version:
S2=manifolds.Sphere(2)
Phi=S2.embedding()
sph.<th,ph>=S2.spherical_coordinates()
E=S2.ambient()
c_cart.<x,y,z> = E.cartesian_coordinates()
g=E.metric()
g1 = S2.metric('g1')
g1.set( Phi.pullback(g))
nab = g1.connection()
nab.display(coordinate_labels=False,only_nonzero=False)
3 | No.3 Revision |
From: sage/src/sage/calculus/test.py
def christoffel(i,j,k,vars,g):
s = 0
ginv = g^(-1)
for l in range(g.nrows()):
s = s + (1/2)*ginv[k,l]*(g[j,l].diff(vars[i])+g[i,l].diff(vars[j])-\
g[i,j].diff(vars[l]))
return s
var('th ph')
g = matrix(SR, [[1,0],[0,sin(th)^2]])
for i in [0,1]:
for j in [0,1]:
for k in[0,1]:
print((i,j,k),christoffel(i,j,k, [th,ph], g))
(0, 0, 0) 0
(0, 0, 1) 0
(0, 1, 0) 0
(0, 1, 1) cos(th)/sin(th)
(1, 0, 0) 0
(1, 0, 1) cos(th)/sin(th)
(1, 1, 0) -cos(th)*sin(th)
(1, 1, 1) 0
SageManifolds version:
S2=manifolds.Sphere(2)
Phi=S2.embedding()
sph.<th,ph>=S2.spherical_coordinates()
E=S2.ambient()
c_cart.<x,y,z> = E.cartesian_coordinates()
g=E.metric()
g1 = S2.metric('g1')
g1.set( Phi.pullback(g))
nab = g1.connection()
nab.display(coordinate_labels=False,only_nonzero=False)