高级方面:作为黎曼流形的欧几里德空间

本教程将介绍SageMath在三维欧几里得空间中的一些向量演算功能。相应的工具已经通过 SageManifolds 项目。

The tutorial is also available as a Jupyter notebook, either passive (nbviewer) or interactive (binder).

欧几里德3-空间

让我们考虑三维欧几里德空间 mathbb{{E}}^3 ,使用笛卡尔坐标 (x,y,z) ::

sage: E.<x,y,z> = EuclideanSpace()
sage: E
Euclidean space E^3

mathbb{{E}}^3 实际上是一个 黎曼流形 (见 pseudo_riemannian ),即具有正定度量张量的光滑实流形:

sage: E.category()
Category of smooth manifolds over Real Field with 53 bits of precision
sage: E.base_field() is RR
True
sage: E.metric()
Riemannian metric g on the Euclidean space E^3

事实上 RR is used here as a proxy for the real field (this should be replaced in the future, see the discussion at #24456 )53位的精度当然对符号计算没有任何作用。

让我们介绍一下球坐标和柱坐标 mathbb{{E}}^3 ::

sage: spherical.<r,th,ph> = E.spherical_coordinates()
sage: cylindrical.<rh,ph,z> = E.cylindrical_coordinates()

用户图集 mathbb{{E}}^3 有三个图表:

sage: E.atlas()
[Chart (E^3, (x, y, z)), Chart (E^3, (r, th, ph)), Chart (E^3, (rh, ph, z))]

在上定义了五个矢量帧 mathbb{{E}}^3 ::

sage: E.frames()
[Coordinate frame (E^3, (e_x,e_y,e_z)),
 Coordinate frame (E^3, (d/dr,d/dth,d/dph)),
 Vector frame (E^3, (e_r,e_th,e_ph)),
 Coordinate frame (E^3, (d/drh,d/dph,d/dz)),
 Vector frame (E^3, (e_rh,e_ph,e_z))]

实际上,三个坐标系中的每一个都有两个坐标系:坐标系(上面用偏导数表示)和正交坐标系(用 e_* 但对于笛卡尔坐标系,这两个坐标系是重合的。

我们得到了正射的柱面坐标系

sage: spherical_frame = E.spherical_frame()
sage: spherical_frame
Vector frame (E^3, (e_r,e_th,e_ph))
sage: cylindrical_frame = E.cylindrical_frame()
sage: cylindrical_frame
Vector frame (E^3, (e_rh,e_ph,e_z))

另一方面,坐标系 left(frac{{partial}}{{partial r}}, frac{{partial}}{{partialtheta}}, frac{{partial}}{{partial phi}}right)left(frac{{partial}}{{partial rho}}, frac{{partial}}{{partialphi}}, frac{{partial}}{{partial z}}right) 由方法返回 frame() 作用于坐标图:

sage: spherical.frame()
Coordinate frame (E^3, (d/dr,d/dth,d/dph))
sage: cylindrical.frame()
Coordinate frame (E^3, (d/drh,d/dph,d/dz))

图表作为地图 mathbb{{E}}^3 rightarrow mathbb{{R}}^3

笛卡尔坐标图是在 E ;让我们用 cartesian ::

sage: cartesian = E.cartesian_coordinates()
sage: cartesian
Chart (E^3, (x, y, z))

让我们考虑一点 pin mathbb{{E}}^3 ,由其笛卡尔坐标定义:

sage: p = E((-1, 1,0), chart=cartesian, name='p')
sage: p
Point p on the Euclidean space E^3
sage: p.parent() is E
True

的坐标 p 在给定的坐标图中,通过让相应的图表作用于 p ::

sage: cartesian(p)
(-1, 1, 0)
sage: spherical(p)
(sqrt(2), 1/2*pi, 3/4*pi)
sage: cylindrical(p)
(sqrt(2), 3/4*pi, 0)

黎曼度量

的默认度量张量 mathbb{{E}}^3 是::

sage: g = E.metric()
sage: g
Riemannian metric g on the Euclidean space E^3
sage: g.display()
g = dx*dx + dy*dy + dz*dz
sage: g[:]
[1 0 0]
[0 1 0]
[0 0 1]

上述显示在默认框架中执行,即笛卡尔框架。当然,我们可能会要求显示其他帧:

sage: g.display(spherical_frame)
g = e^r*e^r + e^th*e^th + e^ph*e^ph
sage: g[spherical_frame, :]
[1 0 0]
[0 1 0]
[0 0 1]

在上面的显示中, e^r = e^re^th = e^thetae^ph = e^phi 定义余帧的1-形式与正交球面框架是对偶的吗 (e_r,e_theta,e_phi) ::

sage: spherical_frame.coframe()
Coframe (E^3, (e^r,e^th,e^ph))

上述度量分量为0或1的事实反映了向量框的正交性 (e_r,e_theta,e_phi) . 相反,在坐标系中 left(frac{{partial}}{{partial r}}, frac{{partial}}{{partialtheta}}, frac{{partial}}{{partial phi}}right) ,它不是正交的,某些组件与0或1不同:

sage: g.display(spherical.frame())
g = dr*dr + (x^2 + y^2 + z^2) dth*dth + (x^2 + y^2) dph*dph

注意,组件是用默认图表(即笛卡尔图)表示的。为了使它们以球面图的形式显示,我们必须提供后者作为该方法的第二个参数 display() ::

sage: g.display(spherical.frame(), spherical)
g = dr*dr + r^2 dth*dth + r^2*sin(th)^2 dph*dph

从SageMath 8.8开始,捷径是:

sage: g.display(spherical)
g = dr*dr + r^2 dth*dth + r^2*sin(th)^2 dph*dph

组件的矩阵视图通过方括号运算符获得:

sage: g[spherical.frame(), :, spherical]
[            1             0             0]
[            0           r^2             0]
[            0             0 r^2*sin(th)^2]

同样,对于柱坐标,我们有:

sage: g.display(cylindrical_frame)
g = e^rh*e^rh + e^ph*e^ph + e^z*e^z
sage: g.display(cylindrical)
g = drh*drh + rh^2 dph*dph + dz*dz
sage: g[cylindrical.frame(), :, cylindrical]
[   1    0    0]
[   0 rh^2    0]
[   0    0    1]

公制 g 是一个 flat Rietensor曲率 riemann() )为零:

sage: g.riemann()
Tensor field Riem(g) of type (1,3) on the Euclidean space E^3
sage: g.riemann().display()
Riem(g) = 0

公制 g 定义上的点积 mathbb{{E}}^3 ::

sage: u = E.vector_field(x*y, y*z, z*x)
sage: u.display()
x*y e_x + y*z e_y + x*z e_z
sage: v = E.vector_field(-y, x, z^2, name='v')
sage: v.display()
v = -y e_x + x e_y + z^2 e_z
sage: u.dot(v) == g(u,v)
True

因此:

sage: norm(u) == sqrt(g(u,u))
True

Levi-Civita张量

的标量三乘积 mathbb{{E}}^3 由Levi-Civita张量(也称为 卷形式 )与…有关 g (并且选择了 (e_x,e_y,e_z) 右手)::

sage: epsilon = E.scalar_triple_product()
sage: epsilon
3-form epsilon on the Euclidean space E^3
sage: epsilon is E.volume_form()
True
sage: epsilon.display()
epsilon = dx/\dy/\dz
sage: epsilon.display(spherical)
epsilon = r^2*sin(th) dr/\dth/\dph
sage: epsilon.display(cylindrical)
epsilon = rh drh/\dph/\dz

检查上面介绍的所有正交帧是否为右手:

sage: ex, ey, ez = E.cartesian_frame()[:]
sage: epsilon(ex, ey, ez).display()
epsilon(e_x,e_y,e_z): E^3 --> R
   (x, y, z) |--> 1
   (r, th, ph) |--> 1
   (rh, ph, z) |--> 1
sage: epsilon(*spherical_frame)
Scalar field epsilon(e_r,e_th,e_ph) on the Euclidean space E^3
sage: epsilon(*spherical_frame).display()
epsilon(e_r,e_th,e_ph): E^3 --> R
   (x, y, z) |--> 1
   (r, th, ph) |--> 1
   (rh, ph, z) |--> 1
sage: epsilon(*cylindrical_frame).display()
epsilon(e_rh,e_ph,e_z): E^3 --> R
   (x, y, z) |--> 1
   (r, th, ph) |--> 1
   (rh, ph, z) |--> 1

向量场作为导数

f 是上的标量字段 mathbb{{E}}^3 ::

sage: f = E.scalar_field(x^2+y^2 - z^2, name='f')
sage: f.display()
f: E^3 --> R
   (x, y, z) |--> x^2 + y^2 - z^2
   (r, th, ph) |--> -2*r^2*cos(th)^2 + r^2
   (rh, ph, z) |--> rh^2 - z^2

向量场作为标量场的导数:

sage: v(f)
Scalar field v(f) on the Euclidean space E^3
sage: v(f).display()
v(f): E^3 --> R
   (x, y, z) |--> -2*z^3
   (r, th, ph) |--> -2*r^3*cos(th)^3
   (rh, ph, z) |--> -2*z^3
sage: v(f) == v.dot(f.gradient())
True
sage: df = f.differential()
sage: df
1-form df on the Euclidean space E^3
sage: df.display()
df = 2*x dx + 2*y dy - 2*z dz
sage: v(f) == df(v)
True

标量场代数

布景 C^infty(mathbb{{E}}^3) 所有平滑标量场的 mathbb{{E}}^3 在上形成交换代数 mathbb{{R}} ::

sage: CE = E.scalar_field_algebra()
sage: CE
Algebra of differentiable scalar fields on the Euclidean space E^3
sage: CE.category()
Category of commutative algebras over Symbolic Ring
sage: f in CE
True

用SageMath术语来说, C^infty(mathbb{{E}}^3) 是标量字段的父级::

sage: f.parent() is CE
True

向量场的自由模

布景 mathfrak{{X}}(mathbb{{E}}^3) 所有向量场的 mathbb{{E}}^3 交换代数上秩为3的自由模 C^infty(mathbb{{E}}^3) ::

sage: XE = v.parent()
sage: XE
Free module X(E^3) of vector fields on the Euclidean space E^3
sage: XE.category()
Category of finite dimensional modules over Algebra of differentiable
 scalar fields on the Euclidean space E^3
sage: XE.base_ring()
Algebra of differentiable scalar fields on the Euclidean space E^3
sage: XE.base_ring() is CE
True
sage: rank(XE)
3

自由模的基 mathfrak{{X}}(mathbb{{E}}^3) 只不过是定义在 mathbb{{E}}^3 ::

sage: XE.bases()
[Coordinate frame (E^3, (e_x,e_y,e_z)),
 Coordinate frame (E^3, (d/dr,d/dth,d/dph)),
 Vector frame (E^3, (e_r,e_th,e_ph)),
 Coordinate frame (E^3, (d/drh,d/dph,d/dz)),
 Vector frame (E^3, (e_rh,e_ph,e_z))]

切线空间

在点$p$处计算的向量场是切线空间中的向量 T_pmathbb{{E}}^3 ::

sage: p
Point p on the Euclidean space E^3
sage: vp = v.at(p)
sage: vp
Vector v at Point p on the Euclidean space E^3
sage: vp.display()
v = -e_x - e_y
sage: Tp = vp.parent()
sage: Tp
Tangent space at Point p on the Euclidean space E^3
sage: Tp is E.tangent_space(p)
True
sage: Tp.category()
Category of finite dimensional vector spaces over Symbolic Ring
sage: dim(Tp)
3
sage: isinstance(Tp, FiniteRankFreeModule)
True

根据 T_pmathbb{{E}}^3 从的向量帧继承 mathbb{{E}}^3 ::

sage: Tp.bases()
[Basis (e_x,e_y,e_z) on the Tangent space at Point p on the Euclidean space E^3,
 Basis (d/dr,d/dth,d/dph) on the Tangent space at Point p on the Euclidean space E^3,
 Basis (e_r,e_th,e_ph) on the Tangent space at Point p on the Euclidean space E^3,
 Basis (d/drh,d/dph,d/dz) on the Tangent space at Point p on the Euclidean space E^3,
 Basis (e_rh,e_ph,e_z) on the Tangent space at Point p on the Euclidean space E^3]

例如,我们有:

sage: spherical_frame.at(p)
Basis (e_r,e_th,e_ph) on the Tangent space at Point p on the
 Euclidean space E^3
sage: spherical_frame.at(p) in Tp.bases()
True

Levi-Civita连接

与欧几里德度量有关的Levi-Civita联系 g 是::

sage: nabla = g.connection()
sage: nabla
Levi-Civita connection nabla_g associated with the Riemannian metric g
 on the Euclidean space E^3

对应于笛卡尔坐标的Christoffel符号相同地为零:它们都不出现在的输出中 christoffel_symbols_display() ,默认情况下只显示非零的Christoffel符号:

sage: g.christoffel_symbols_display(cartesian)

相反,一些关于球坐标的Christoffel符号与零不同:

sage: g.christoffel_symbols_display(spherical)
Gam^r_th,th = -r
Gam^r_ph,ph = -r*sin(th)^2
Gam^th_r,th = 1/r
Gam^th_ph,ph = -cos(th)*sin(th)
Gam^ph_r,ph = 1/r
Gam^ph_th,ph = cos(th)/sin(th)

默认情况下,只显示非零值和非冗余值(例如 Gamma^phi_{{, phi r}} 被跳过,因为它可以从 Gamma^phi_{{, r phi}} 最后两个指数的对称性)。

同样,关于柱坐标的非零克里斯托弗符号是:

sage: g.christoffel_symbols_display(cylindrical)
Gam^rh_ph,ph = -rh
Gam^ph_rh,ph = 1/rh

Christoffel符号只是对应坐标系中的连接系数:

sage: nabla.display(cylindrical.frame(), cylindrical, only_nonredundant=True)
Gam^rh_ph,ph = -rh
Gam^ph_rh,ph = 1/rh

关于正交(非坐标)帧的连接系数是(同样只显示非零值):

sage: nabla.display(spherical_frame, spherical)
Gam^1_22 = -1/r
Gam^1_33 = -1/r
Gam^2_12 = 1/r
Gam^2_33 = -cos(th)/(r*sin(th))
Gam^3_13 = 1/r
Gam^3_23 = cos(th)/(r*sin(th))
sage: nabla.display(cylindrical_frame, cylindrical)
Gam^1_22 = -1/rh
Gam^2_12 = 1/rh

Levi-Civita连接 nabla_g 标准微分运算符中是否涉及连接:

sage: from sage.manifolds.operators import *
sage: grad(f) == nabla(f).up(g)
True
sage: nabla(f) == grad(f).down(g)
True
sage: div(u) == nabla(u).trace()
True
sage: div(v) == nabla(v).trace()
True
sage: laplacian(f) == nabla(nabla(f).up(g)).trace()
True
sage: laplacian(u) == nabla(nabla(u).up(g)).trace(1,2)
True
sage: laplacian(v) == nabla(nabla(v).up(g)).trace(1,2)
True