# Smooth manifolds, vector fields and tensor fields¶

This notebook accompanies the lecture Symbolic tensor calculus on manifolds at JNCF 2018.

Click here to download the notebook file (ipynb format). To run it, you must start SageMath with the Jupyter Notebook server, via the command sage -n jupyter

In [1]:
%display latex


Let us restore the 2-sphere manifold constructed in the preceeding worksheet:

In [2]:
M = Manifold(2, 'M')
U = M.open_subset('U')
XU.<x,y> = U.chart()
V = M.open_subset('V')
XV.<xp,yp> = V.chart("xp:x' yp:y'")
M.declare_union(U,V)
XU_to_XV = XU.transition_map(XV,
(x/(x^2+y^2), y/(x^2+y^2)),
intersection_name='W',
restrictions1= x^2+y^2!=0,
restrictions2= xp^2+yp^2!=0)
XV_to_XU = XU_to_XV.inverse()
M.atlas()

Out[2]:

We also reconstruct the point $p$:

In [3]:
p = U((1,2), chart=XU, name='p')
print(p)

Point p on the 2-dimensional differentiable manifold M


and the embedding $\mathbb{S}^2 \to \mathbb{R}^3$:

In [4]:
R3 = Manifold(3, 'R^3', r'\mathbb{R}^3')
XR3.<X,Y,Z> = R3.chart()
Phi = M.diff_map(R3, {(XU, XR3):
[2*x/(1+x^2+y^2), 2*y/(1+x^2+y^2),
(x^2+y^2-1)/(1+x^2+y^2)],
(XV, XR3):
[2*xp/(1+xp^2+yp^2), 2*yp/(1+xp^2+yp^2),
(1-xp^2-yp^2)/(1+xp^2+yp^2)]},
name='Phi', latex_name=r'\Phi')
Phi.display()

Out[4]:
In [5]:
graph = XU.plot(chart=XR3, mapping=Phi, number_values=25,
label_axes=False) + \
XV.plot(chart=XR3, mapping=Phi, number_values=25,
color='green', label_axes=False) + \
p.plot(chart=XR3, mapping=Phi, label_offset=0.05)
show(graph, viewer='threejs', online=True)


Finally we reconstruct the scalar field $f$:

In [6]:
f = M.scalar_field({XU: 1/(1+x^2+y^2), XV: (xp^2+yp^2)/(1+xp^2+yp^2)},
name='f')
f.display()

Out[6]:

and assign the Python variable CM to the algebra of scalar fields:

In [7]:
CM = M.scalar_field_algebra()
CM

Out[7]:

## Tangent vectors¶

The tangent space at the point $p$ introduced above is generated by

In [8]:
Tp = M.tangent_space(p)
Tp

Out[8]:

It is a vector space over $\mathbb{R}$, which is represented by Sage's Symbolic Ring:

In [9]:
print(Tp.category())

Category of finite dimensional vector spaces over Symbolic Ring


The dimension of $T_p M$ is the same as that of $M$:

In [10]:
dim(Tp)

Out[10]:

Tangent spaces are implemented as a class inherited from TangentSpace via the category framework:

In [11]:
type(Tp)

Out[11]:

The class TangentSpace actually inherits from the generic class FiniteRankFreeModule, which, in SageMath, is devoted to free modules of finite rank without any distinguished basis:

In [12]:
isinstance(Tp, FiniteRankFreeModule)

Out[12]:

Two bases of $T_p M$ are already available: those generated by the derivations at $p$ along the coordinates of charts XU and XV respectively:

In [13]:
Tp.bases()

Out[13]:

None of these bases is distinguished, but one if the default one, which simply means that it is the basis to be considered if the basis argument is skipped in some methods:

In [14]:
Tp.default_basis()

Out[14]:

A tangent vector is created as an element of the tangent space by the standard SageMath procedure new\_element = parent(...), where ... stands for some material sufficient to construct the element:

In [15]:
vp = Tp((-3, 2), name='v')
print(vp)

Tangent vector v at Point p on the 2-dimensional differentiable manifold M


Since the basis is not specified, the pair $(-3,2)$ refers to components with respect to the default basis:

In [16]:
vp.display()

Out[16]:

We have of course

In [17]:
vp.parent()

Out[17]:
In [18]:
vp in Tp

Out[18]:

As other manifold objects, tangent vectors have some plotting capabilities:

In [19]:
graph += vp.plot(chart=XR3, mapping=Phi, scale=0.5, color='gold')
show(graph, viewer='threejs', online=True)