Vector calculus with SageMath
Part 5: Advanced aspects: Euclidean spaces as Riemannian manifolds
This notebook illustrates some vector calculus capabilities of SageMath within the 3-dimensional Euclidean space. The corresponding tools have been developed within the SageManifolds project.
Click here to download the notebook file (ipynb format). To run it, you must start SageMath with the Jupyter interface, via the command sage -n jupyter
NB: a version of SageMath at least equal to 8.3 is required to run this notebook:
First we set up the notebook to display math formulas using LaTeX formatting:
The Euclidean 3-space
We define the 3-dimensional Euclidean space , with Cartesian coordinates :
is actually a Riemannian manifold, i.e. a smooth real manifold endowed with a positive definite metric tensor:
Actually RR
is used here as a proxy for the real field (this should be replaced in the future, see the discussion at #24456) and the 53 bits of precision play of course no role for the symbolic computations.
Let us introduce spherical and cylindrical coordinates on :
The user atlas of has then three charts:
while there are five vector frames defined on :
Indeed, there are two frames associated with each of the three coordinate systems: the coordinate frame (denoted with partial derivatives above) and an orthonormal frame, but for Cartesian coordinates, both frames coincide.
We get the orthonormal spherical and cylindrical frames by
On the other side, the coordinate frames are returned by the method frame()
acting on the coordinate charts:
Charts as maps
The chart of Cartesian coordinates has been constructed at the declaration of E
; let us denote it by cartesian
:
Let us consider a point , defined by its Cartesian coordinates:
The coordinates of in a given coordinate chart are obtained by letting the corresponding chart act on :
Riemannian metric
The default metric tensor of is
The above display in performed in the default frame, which is the Cartesian one. Of course, we may ask for display with respect to other frames:
In the above display, , and are the 1-forms defining the coframe dual to the orthonormal spherical frame :
The fact that the above metric components are either 0 or 1 reflect the orthonormality of the vector frame . On the contrary, in the coordinate frame , which is not orthonormal, the components differ from 0 or 1:
Note that the components are expressed in terms of the default chart, namely the Cartesian one. To have them displayed in terms of the spherical chart, we have to provide the latter as the second argument of the method display()
:
Similarly, for cylindrical coordinates, we have
The metric is a flat: its (Riemann) curvature tensor is zero:
The metric is defining the dot product on :
Consequently
The Levi-Civita tensor
The scalar triple product of is provided by the Levi-Civita tensor (also called volume form) associated with (and chosen such that is right-handed):
Checking that all orthonormal frames introduced above are right-handed:
Vector fields as derivatives
Let be a scalar field on :
Vector fields acts as derivative on scalar fields:
The algebra of scalar fields
The set of all smooth scalar fields on forms a commutative algebra over :
In SageMath terminology is the parent of scalar fields:
The free module of vector fields
The set of all vector fields on is a free module of rank 3 over the commutative algebra :
The bases of the free module are nothing but the vector frames defined on :
Tangent spaces
Vector fields evaluated at a point are vectors in the tangent space at this point:
The bases on are inherited from the vector frames of :
For instance, we have
Levi-Civita connection
The Levi-Civita connection associated to the Euclidean metric is
The corresponding Christoffel symbols with respect to Cartesian coordinates are identically zero: none of them appear in the output of christoffel_symbols_display
, which by default displays only nonzero Christoffel symbols:
On the contrary, some of the Christoffel symbols with respect to spherical coordinates differ from zero:
By default, only nonzero and nonredundant values are displayed (for instance is skipped, since it can be deduced from by symmetry on the last two indices).
Similarly, the nonzero Christoffel symbols with respect to cylindrical coordinates are
The Christoffel symbols are nothing but the connection coefficient in the corresponding coordinate frame:
The connection coefficients with respect to the orthonormal (non-coordinate) frames are (again only nonzero values are displayed):
is the connection involved in differential operators: