Skip to content

Instantly share code, notes, and snippets.

@donaldmunro
Last active August 3, 2021 22:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save donaldmunro/00f03ba6c52a0e0d79fcc4a0991883ab to your computer and use it in GitHub Desktop.
Save donaldmunro/00f03ba6c52a0e0d79fcc4a0991883ab to your computer and use it in GitHub Desktop.
Differential Forms on simple Euclidean manifolds using SageMath Manifolds package
clear_vars
reset()
%display latex
R3 = Manifold(3, 'R^3', start_index=1)
X.<x,y,z> = R3.chart()
g = R3.metric('g')
g[1,1], g[2,2], g[3,3] = 1, 1, 1

#R2 = Manifold(2, 'R^2', ambient=R3, start_index=1)
#Y.<x,y> = R2.chart()
#h = R2.metric('g')
#h[1,1], h[2,2] = 1, 1
#v2 = R2.vector_field(1,2, name='v')

var('x y z u v w')
p = R3.point((u,v,w), name='p')
vf = R3.vector_field(x, y^2, z^3, name='vf')
pretty_print(vf.at(p).display())
a = R3.one_form(x, y, z, name='a')
pretty_print(a.display())
pretty_print(a.at(p).display())
b = R3.diff_form(2, name='b')
b[1,2] = 2*x
b[1,3] = 3*y
pretty_print(b.display())
pretty_print(b.at(p).display())
c = a.wedge(b)
pretty_print(c.display())
pretty_print(c.at(p).display())
vv = R3.vector_field(1,2,3,name='vv')
v = R3.multivector_field(2, name='v')
v[1,2], v[1,3], v[2,3] = y^2, z+x, -z^2
v[1,2], v[1,3], v[2,3] = 1, 2, 3
pretty_print(vv.display())
pretty_print(vv.interior_product(c).display())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment