This notebook demonstrates some differential geometry capabilities of SageMath on the example of the 1-dimensional sphere, i.e. the circle. The corresponding tools have been developed within the SageManifolds project.
%display latex
S1 = Manifold(1, 'S^1', latex_name=r'\mathbb{S}^1')
print(S1)
1-dimensional differentiable manifold S^1
S1
A = S1.open_subset('A')
B = S1.open_subset('B')
S1.declare_union(A, B)
CA.<ph> = A.chart(r"ph:(0,2*pi):\varphi")
CA
CA.coord_range()
CB.<ps> = B.chart(r"ps:(0,2*pi):\psi")
CB
CA_to_CB = CA.transition_map(CB, (ph + pi*(1 - 2*heaviside(ph - pi)),),
intersection_name='W',
restrictions1= ph!=pi,
restrictions2= ps!=pi)
CA_to_CB.display()
CA_to_CB(ph)[0]
plot(CA_to_CB(ph)[0], (ph, 0, pi),
axes_labels=[r'$\varphi$', r'$\psi$'],
ticks=[pi/2, pi/2], tick_formatter=[pi, pi], fontsize=14,
frame=True, gridlines=True, axes=False, aspect_ratio=1) \
+ plot(CA_to_CB(ph)[0], (ph, pi, 2*pi))
CA_to_CB.set_inverse(ps + pi*(1 - 2*heaviside(ps - pi)))
Check of the inverse coordinate transformation: ph == 2*pi - 2*pi*heaviside(-pi + ph) - 2*pi*heaviside(-2*pi*heaviside(-pi + ph) + ph) + ph **failed** ps == 2*pi - 2*pi*heaviside(-pi + ps) - 2*pi*heaviside(-2*pi*heaviside(-pi + ps) + ps) + ps **failed** NB: a failed report can reflect a mere lack of simplification.
S1.atlas()
plot(2*pi - 2*pi*heaviside(-pi + ph) - 2*pi*heaviside(-2*pi*heaviside(-pi + ph) + ph) + ph,
(ph, 0, 2*pi))
R2.<X,Y> = EuclideanSpace(name='R^2', latex_name=r'\mathbb{R}^2', metric_name='h')
cartesian = R2.cartesian_coordinates()
cartesian
Phi = S1.diff_map(R2, {(CA, cartesian): (cos(ph), sin(ph)),
(CB, cartesian): (-cos(ps), -sin(ps))},
name='Phi', latex_name=r'\Phi')
Phi.display()
O = S1((pi,), chart=CB, name='O')
O
cartesian(Phi(O))
H = S1((pi,), chart=CA, name='H')
cartesian(Phi(H))
graph_spher = CA.plot(chart=cartesian, mapping=Phi, number_values=11,
color='blue')
graph_spher
e = S1.vector_frame('e')
e.restrict(A)[0][0] = 1
e.restrict(A)[0].display()
A.set_change_of_frame(CA.frame(), e.restrict(A),
A.tangent_identity_field())
e.restrict(B)[0][0] = 1
e.restrict(B)[0].display()
B.set_change_of_frame(CB.frame(), e.restrict(B),
B.tangent_identity_field())
graph_spher + e[0].plot(cartesian, mapping=Phi)
S1.is_manifestly_parallelizable()
f = S1.one_form(name='f')
f[0] = 1
print(f)
f.display()
1-form f on the 1-dimensional differentiable manifold S^1
f == e.coframe()[0]
The 1-form $f$ is closed (as any 1-form on a 1-dimensional manifold) but is not exact:
f.restrict(A).display()
f.restrict(B).display()
df = diff(f.restrict(A))
df.display()
diff(f.restrict(B)).display()