Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
sagemanifolds
GitHub Repository: sagemanifolds/IntroToManifolds
Path: blob/main/11Manifold_Vect_Fields.ipynb
Views: 80
Kernel: SageMath 9.6

11. Vector fields

This notebook is part of the Introduction to manifolds in SageMath by Andrzej Chrzeszczyk (Jan Kochanowski University of Kielce, Poland).

version()
'SageMath version 9.6, Release Date: 2022-05-15'

A vector field XX on a manifold MM assigns to a point pMp ∈ M a tangent vector X(p)TpMX(p) ∈ T_p M. Instead of X(p)X(p) we shall write XpX_p. Since a vector field gives us a tangent vector at each point of its domain and a tangent vector can be applied to real-valued smooth functions to yield real numbers, given a vector field XX and fC(M)f ∈ C^∞ (M), we can form a real-valued function X(f)=XfX(f)=Xf, defined by ParseError: KaTeX parse error: Undefined control sequence: \label at position 41: …p) ≡ X_p( f ). \̲l̲a̲b̲e̲l̲{}\tag{11.1} \e…

We have also an equivalent definition
A vector field XX on a manifold MM is a linear map X:C(M)C(M)X : C^∞ (M ) → C^∞ (M ) such that

X(fg)=fX(g)+gX(f) for all f,gC(M).X(f g) = f X(g) + gX(f )\quad \mbox{ for all } f, g ∈ C^∞ (M ).

A vector field XX is smooth if for all fC(M)f\in C^\infty(M) the function XfXf is also in C(M)C^\infty(M).
Equivalently we can say that a vector field XX on a manifold MM is smooth if for any coordinate chart φ=(x1,,xn):URnφ = (x^1 ,\ldots , x^n ) :U → R^n we have for any point pUp ∈ U ParseError: KaTeX parse error: Undefined control sequence: \label at position 68: …al x^i}\Big|_p \̲l̲a̲b̲e̲l̲{}\tag{11.2} \e… for some CC^\infty functions fi:URf^i : U → R.


Frames


To define vector fields with specified components in SageMath Manifolds we need vector frames.

If UU is an open subset of a manifold MM (for example a coordinate neighborhood) then the vector frame on UU is the sequence ee of vector fields on UU such that for each pU, e(p)p∈U, \ e(p) is a vector basis of the tangent space TpUT_pU.

Usually we shall use the coordinate frames associated with the local coordinates.


Example 11.1

Let us display the frame corresponding to the default chart

%display latex R2=Manifold(2,'R^2',start_index=1) # manifold R^2 c_xy.<x,y>=R2.chart() # global coordinates v = R2.vector_field(name='v') # vector field on R2 e = c_xy.frame() # vector frame print(e) e
Coordinate frame (R^2, (∂/∂x,∂/∂y))

(R2,(x,y))\displaystyle \left(R^2, \left(\frac{\partial}{\partial x },\frac{\partial}{\partial y }\right)\right)

In this case the elements of the frame are the vector fields pxipp\to \frac{\partial}{\partial x^i}\big|_p\quad (xip\frac{\partial}{\partial x^i}\big|_p was defined by formula (8.3)).

If the frame is not defined by the user, the default frame is used.

Let us check how the elements e[1],e[2] of our frame e act on a scalar function.

# continuation # f is a scalar function on R2: f = R2.scalar_field(function('f')(x,y), name='f') e[1](f).expr(), e[2](f).expr() # values of the vector frame on f

(xf(x,y),yf(x,y))\displaystyle \left(\frac{\partial}{\partial x}f\left(x, y\right), \frac{\partial}{\partial y}f\left(x, y\right)\right)

If the frame is defined, we can define the components of the vector field in this frame.


Example 11.2

Here defining a vector field, we use frame e:

R2=Manifold(2,'R^2',start_index=1) # manifold R2 c_xy.<x,y>=R2.chart() # global coordinates v = R2.vector_field(name='v') # vector field v e = c_xy.frame() # vector frame e v[e,:] = [-y, 1+x] # components of v in e v.display() # show v

v=yx+(x+1)y\displaystyle v = -y \frac{\partial}{\partial x } + \left( x + 1 \right) \frac{\partial}{\partial y }

Since we use the default frame, the previous code can be simplified.


Example 11.3

Here the frame is not specified, the result is the same, since we have used the default frame

R2=Manifold(2,'R^2',start_index=1) # manifold R2 c_xy.<x,y>=R2.chart() # global coordinates v = R2.vector_field(name='v') # vector field v[:] = [-y, 1+x] # components of v in default frame v.display() # show v

v=yx+(x+1)y\displaystyle v = -y \frac{\partial}{\partial x } + \left( x + 1 \right) \frac{\partial}{\partial y }

The value of v on a scalar function:

# continuation # scalar function f = R2.scalar_field(function('f')(x,y), name='f') s=v(f) # value of v on f s.expr() # show expression

yxf(x,y)+(x+1)yf(x,y)\displaystyle -y \frac{\partial}{\partial x}f\left(x, y\right) + {\left(x + 1\right)} \frac{\partial}{\partial y}f\left(x, y\right)


Example 11.4

Let us check that vector fields are derivations.

# vector fields are derivations R2=Manifold(2,'R^2',start_index=1) # manifold R2 c_xy.<x,y>=R2.chart() # global coordinates v = R2.vector_field(name='v') # vector field v e = c_xy.frame() # frame on R2 f=R2.scalar_field(function('f')(x,y)) # scalar function f g=R2.scalar_field(function('g')(x,y)) # scalar function g v1=R2.scalar_field(function('v1')(x,y)) # component v1 of v v2=R2.scalar_field(function('v2')(x,y)) # component v2 of v v[e,:] = [v1, v2] # components of v in frame e

First we compute the value of  v(fg)\ v(fg):

v(f*g).expr() # value of v on f*g

g(x,y)v1(x,y)xf(x,y)+g(x,y)v2(x,y)yf(x,y)+f(x,y)v1(x,y)xg(x,y)+f(x,y)v2(x,y)yg(x,y)\displaystyle g\left(x, y\right) v_{1}\left(x, y\right) \frac{\partial}{\partial x}f\left(x, y\right) + g\left(x, y\right) v_{2}\left(x, y\right) \frac{\partial}{\partial y}f\left(x, y\right) + f\left(x, y\right) v_{1}\left(x, y\right) \frac{\partial}{\partial x}g\left(x, y\right) + f\left(x, y\right) v_{2}\left(x, y\right) \frac{\partial}{\partial y}g\left(x, y\right)

and next the value of  fv(g)+gv(f)\ fv(g)+gv(f):

(f*v(g)+g*v(f)).expr() # value of f*v(g)+g*v(f)

g(x,y)v1(x,y)xf(x,y)+g(x,y)v2(x,y)yf(x,y)+f(x,y)v1(x,y)xg(x,y)+f(x,y)v2(x,y)yg(x,y)\displaystyle g\left(x, y\right) v_{1}\left(x, y\right) \frac{\partial}{\partial x}f\left(x, y\right) + g\left(x, y\right) v_{2}\left(x, y\right) \frac{\partial}{\partial y}f\left(x, y\right) + f\left(x, y\right) v_{1}\left(x, y\right) \frac{\partial}{\partial x}g\left(x, y\right) + f\left(x, y\right) v_{2}\left(x, y\right) \frac{\partial}{\partial y}g\left(x, y\right)

Both values are the same:

v(f*g) == f*v(g) + g*v(f) # check if v is derivation

True\displaystyle \mathrm{True}


Example 11.5

Let us plot the vector field v0=yx2+y2x+xx2+y2y.\quad v_0=\frac{-y}{\sqrt{x^2+y^2}}\frac{\partial}{\partial x} +\frac{x}{\sqrt{x^2+y^2}}\frac{\partial}{\partial y}.

To obtain the plot, some restriction are necessary.

%display latex R2=Manifold(2,'R^2',start_index=1) # manifold R2 c_xy.<x,y>=R2.chart(coord_restrictions=lambda x,y:x^2+y^2>0) v0=R2.vector_field(name='v0') # vector field v0 v0[:]=-y/sqrt(x^2+y^2),x/sqrt(x^2+y^2) # components of v0 v0.display()

v0=(yx2+y2)x+(xx2+y2)y\displaystyle v0 = \left( -\frac{y}{\sqrt{x^{2} + y^{2}}} \right) \frac{\partial}{\partial x } + \left( \frac{x}{\sqrt{x^{2} + y^{2}}} \right) \frac{\partial}{\partial y }

v0.plot(arrowsize=2,color='black',aspect_ratio=1) # plot v0
Image in a Jupyter notebook

Use the command v0.plot? to see how to plot vector fields.


Example 11.6

Now let us plot the vector field v1=xxyy.\quad v_1=x\frac{\partial}{\partial x} -y\frac{\partial}{\partial y}.

Here we have excluded some neighborhood of the origin.

M=Manifold(2,'M') # manifold M X.<x,y>=M.chart(coord_restrictions=lambda x,y:(abs(x)>0.1,abs(y)>0.1)) e=X.frame() # frame e on M v1=M.vector_field(name='v1') # vector field v1 v1[e,:]=x,-y # components of v1 v1.plot(number_values=10, scale=0.2, arrowsize=2,color='black',aspect_ratio=1) # plot v1
Image in a Jupyter notebook

Example 11.7

Let us consider the two-dimensional sphere with spherical coordinates θ,ϕ\theta,\phi and the corresponding frame θ,ϕ\frac{\partial}{\partial\theta},\frac{\partial}{\partial\phi}.

%display latex S2=manifolds.Sphere(2) # sphere S^2 Phi=S2.embedding() # embedding S^2 -> E^3 sph.<th,ph>=S2.spherical_coordinates() # spherical coord. on S^2 sphFr=sph.frame() # frame on S^2 E=S2.ambient() # Euclidean space E^3 cart.<x,y,z> = E.cartesian_coordinates() # Cart.coord. in E^3

First let us plot the vector field ϕ\frac{\partial}{\partial\phi}:

p1=sphFr[2].plot(chart=cart, mapping=Phi,number_values=10, scale=0.5,arrowsize=0.5,label_axes=False,thickness=0.5, width=0.5,color='black') # plot vector field d/dphi s=sphere(color='lightgrey',opacity=0.9) # plot the sphere (p1+s).show(frame=False,label_axes=False) # combine plots