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

本教程将介绍SageMath在3维欧几里德空间中的一些向量演算功能。相应的工具已经通过 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 实际上是一个 Riemannian manifold (见 pseudo_riemannian ),即具有正定度量张量的光滑实流形:

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

实际上 RR 在这里用作真实字段的代理(这在将来应该被替换,请参阅 :issue:`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, (∂/∂r,∂/∂th,∂/∂ph)),
 Vector frame (E^3, (e_r,e_th,e_ph)),
 Coordinate frame (E^3, (∂/∂rh,∂/∂ph,∂/∂z)),
 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))

On the other side, the coordinate frames left(frac{partial}{partial r}, frac{partial}{partialtheta}, frac{partial}{partial phi}right) and left(frac{partial}{partial rho}, frac{partial}{partialphi}, frac{partial}{partial z}right) are returned by the method frame() acting on the coordinate charts:

sage: spherical.frame()
Coordinate frame (E^3, (∂/∂r,∂/∂th,∂/∂ph))
sage: cylindrical.frame()
Coordinate frame (E^3, (∂/∂rh,∂/∂ph,∂/∂z))

地图形式的图表 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]

In the above display, e^r = e^r, e^th = e^theta and e^ph = e^phi are the 1-forms defining the coframe dual to the orthonormal spherical frame (e_r,e_theta,e_phi):

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

The fact that the above metric components are either 0 or 1 reflect the orthonormality of the vector frame (e_r,e_theta,e_phi). On the contrary, in the coordinate frame left(frac{partial}{partial r}, frac{partial}{partialtheta}, frac{partial}{partial phi}right), which is not orthonormal, some components differ from 0 or 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 :其黎曼曲率张量(见 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张量(也称为 volume form )与 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 → ℝ
   (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 → ℝ
   (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 → ℝ
   (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 → ℝ
   (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 → ℝ
   (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

标量域的代数

The set C^infty(mathbb{E}^3) of all smooth scalar fields on mathbb{E}^3 forms a commutative algebra over mathbb{R}:

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

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

sage: f.parent() is CE
True

向量场的自由模

The set mathfrak{X}(mathbb{E}^3) of all vector fields on mathbb{E}^3 is a free module of rank 3 over the commutative algebra 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, (∂/∂r,∂/∂th,∂/∂ph)),
 Vector frame (E^3, (e_r,e_th,e_ph)),
 Coordinate frame (E^3, (∂/∂rh,∂/∂ph,∂/∂z)),
 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 (∂/∂r,∂/∂th,∂/∂ph) 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 (∂/∂rh,∂/∂ph,∂/∂z) 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)

By default, only nonzero and nonredundant values are displayed (for instance Gamma^phi_{, phi r} is skipped, since it can be deduced from Gamma^phi_{, r phi} by symmetry on the last two indices).

同样,相对于柱面坐标的非零Christoffel符号为:

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

利维-奇维塔连接 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