This worksheet illustrates the operators regarding scalar and vector fields on pseudo-Riemannian manifolds introduced in Trac ticket #24622.
Since SageMath 8.3, it is rather obsolete regarding calculus in Euclidean spaces. See these vector calculus examples instead.
version()
'SageMath version 8.2.beta4, Release Date: 2018-01-27'
%display latex
from sage.manifolds.operators import * # to get the operators grad, div, curl, etc.
M = Manifold(3, 'M', structure='Riemannian', start_index=1)
X.<x,y,z> = M.chart()
g = M.metric()
g[1,1], g[2,2], g[3,3] = 1, 1, 1
g.display()
F = M.scalar_field(function('f')(x,y,z), name='F')
F.display()
grad(F).display()
curl(grad(F)).display()
norm(grad(F)).display()
laplacian(F).display()
laplacian(F) == div(grad(F))
v = M.vector_field(name='v')
v[1] = function('v_x')(x,y,z)
v[2] = function('v_y')(x,y,z)
v[3] = function('v_z')(x,y,z)
v.display()
In order not to clutter the outputs, we omit the coordinate arguments in the display of chart functions:
M.options.omit_function_arguments=True
v.display()
Norm of a vector field:
s = norm(v)
print(s)
Scalar field |v| on the 3-dimensional Riemannian manifold M
s.display()
Scalar product of two vector fields:
v.dot(grad(F)).display()
Cross product of two vector fields:
v.cross(grad(F)).display()
Divergence :
s = div(v)
s.display()
Curl:
w = curl(v)
print(w)
Vector field curl(v) on the 3-dimensional Riemannian manifold M
w.display()
To use the notation rot
instead of curl
, simply do
rot = curl
An alternative is
from sage.manifolds.operators import curl as rot
We have then
rot(v).display()
rot(v) == curl(v)
The divergence of a curl is always zero:
div(curl(v)).display()
Laplacian of a vector field:
laplacian(v).display()
curl(curl(v)).display()
grad(div(v)).display()
Check of a famous identity:
curl(curl(v)) == grad(div(v)) - laplacian(v)
Two other identities regarding any scalar field F
and any vector field v
:
div(F*v) == F*div(v) + v.dot(grad(F))
curl(F*v) == grad(F).cross(v) + F*curl(v)
The left-hand side is
curl(F*v).display()