#!/usr/bin/env python
# coding: utf-8
# # 24. Riemannian curvature tensor of type (0,4)
#
# This notebook is part of the [Introduction to manifolds in SageMath](https://sagemanifolds.obspm.fr/intro_to_manifolds.html) by Andrzej Chrzeszczyk (Jan Kochanowski University of Kielce, Poland).
# In[1]:
version()
# Assume now that $M$ is a Riemannian manifold with metric $g$ and $\nabla$ is the corresponding Levi-Civita connection. We define **Riemannian curvature tensor** of type $(0,4)$ by
#
# \begin{equation}
# R(X, Y, Z , W ) = g(R(X, Y )Z , W ),\quad \text{for } X,Y,Z,W\in \mathfrak{X}(M).
# \tag{24.1}
# \end{equation}
#
# Since $g$ is non-singular (cf. [notebook 22](https://nbviewer.org/github/sagemanifolds/IntroToManifolds/blob/main/22Manifold_Riemann.ipynb)) the curvature (0,4)-type tensor contains the same information as the corresponding (1,3)-type tensor from the [previous notebook](https://nbviewer.org/github/sagemanifolds/IntroToManifolds/blob/main/23Manifold_Curvature.ipynb).
#
# In a local coordinate system $(x^1,\ldots,x^n)$ we have
#
# \begin{equation}
# R_{ijkl}=g_{im}R^m_{jkl}.
# \tag{24.1'}
# \end{equation}
#
#
# ### Symmetries of Riemannian curvature tensor
#
#
#
# If $X, Y, Z , W$ are vector fields in $M$ and $∇$ is the Levi–Civita connection, then
#
# \begin{equation}
# \begin{matrix}
# R(X, Y, Z , W ) + R(Y, Z , X, W ) + R(Z , X, Y, W ) = 0,\\
# R(X, Y, Z , W ) = −R(Y, X, Z , W ),\\
# R(X, Y, Z , W ) = −R(X, Y, W, Z ),\\
# R(X, Y, Z , W ) = R(Z , W, X, Y ).
# \end{matrix}
# \tag{24.2}
# \end{equation}
#
#
#
# Since the Levi-Civita connections are torsion-free, the first Bianchi identity (23.4) reduces to
# $R(X, Y)Z + R(Z, X)Y + R(Y, Z)X=0$ and implies the first relation.
#
# The antisymmetry $R(X, Y) = −R(Y, X)$ implies the second equality.
#
# The third equality is equivalent to $R(X, Y, Z , Z ) = 0.$ Indeed, if it holds then clearly $R(X, Y, Z , Z ) = 0.$ Conversely, if $R(X, Y, Z , Z ) = 0$, we have
#
# $$R(X, Y, Z + W, Z + W ) = 0\\
# ⇔R(X, Y, Z , Z ) + R(X, Y, Z, W ) +R(X, Y, W, Z ) + R(X, Y, W, W )=0\\
# ⇔ R(X, Y, Z , W ) + R(X, Y, W, Z ) = 0.$$
# To prove $R(X, Y, Z , Z ) = 0$, let us note that
# since the Levi-Civita connection is compatible with the metric, we have
#
# $$ g(∇_X ∇_Y Z , Z ))=X ( g(∇_Y Z , Z ))-g( ∇_Y Z , ∇_X Z),\\
# g(∇_Y ∇_X Z , Z ))=Y ( g(∇_X Z , Z ))-g( ∇_X Z , ∇_Y Z).
# $$
#
# It is also clear, that for connections compatible with the metric, taking $V=[X,Y]$ we obtain
#
# $$V(g(Z,Z))=2g(\nabla_V Z,Z) \Longrightarrow
# [X,Y](g(Z , Z))=2 g(∇_{[X,Y ]} Z , Z). $$
#
# Therefore
# $$
# R(X, Y, Z , Z ) =
# g(∇_X ∇_Y Z , Z) − g(∇_Y ∇_X Z , Z) − g(∇_{[X,Y ]} Z , Z)\\
# = X(g( ∇_Y Z , Z)) − g(∇_Y Z , ∇_X Z)\\
# − Y(g( ∇_X Z , Z))+ g(∇_X Z , ∇_Y Z)\\
# − \frac{1}{2}[X, Y ](g( Z , Z))
# $$
# But we have also
# $$
# g(\nabla_YZ,Z)=Y(g(Z,Z))-g(Z,\nabla_YZ),\\
# g(\nabla_XZ,Z)=X(g(Z,Z))-g(Z,\nabla_XZ),
# $$
#
# and consequently
# $$
# g(\nabla_YZ,Z)=\frac{1}{2}Y(g(Z,Z)),\\
# g(\nabla_XZ,Z)=\frac{1}{2}X(g(Z,Z)),
# $$
#
# therefore
#
# $$
# R(X, Y, Z , Z )\\
# =\frac{1}{2}X(Y( g(Z , Z ))-\frac{1}{2}Y(X( g(Z , Z ))-\frac{1}{2}[X,Y]( g(Z , Z ))\\
# =\frac{1}{2}[X,Y]( g(Z , Z ))-\frac{1}{2}[X,Y]( g(Z , Z ))=0.
# $$
# In the proof of the fourth relation we use the first one to obtain
#
# $$
# R(X, Y, Z , W )+R(Y, Z , X, W )+R(Z , X, Y, W )=0,\\
# R(Y, Z, W, X) +R(Z , W, Y, X )+R(W, Y, Z , X )=0,\\
# R(Z , W, X, Y )+R(W, X, Z , Y )+R(X, Z , W, Y )=0,\\
# R(W, X, Y, Z )+R(X, Y, W, Z )+R(Y, W, X, Z )=0.
# $$
#
# Adding side by side and using the third equality we obtain
#
# $$
# R(Z , X, Y, W ) + R(W, Y, Z , X ) + R(X, Z , W, Y ) + R(Y, W, X, Z ) = 0.
# $$
#
# Using the second and third relation, we have
#
# $$2R(Z , X, Y, W ) − 2R(Y, W, Z , X ) = 0.$$
#
#
#
# The component-wise version of (24.2) reads as follows:
#
# \begin{equation}
# \begin{matrix}
# R_{i jkl} + R_{ikl j} + R_{il jk} = 0,\\
# R_{ijkl} = −R_{jikl},\\
# R_{ijkl} = −R_{ijlk},\\
# R_{ijkl} = R_{klij}.
# \end{matrix}
# \tag{24.2'}
# \end{equation}
#
#
# ### The case of of 2-dimensional manifolds in $R^3$
#
#
#
# If $n=2$, then the indices take values 1 or 2 (or 0,1 if Python is used). The antisymmetry in $i,j$ and $k,l$ means that for nonzero components of of the tensor $R_{ijkl}$, we have $i\not=j$ and $k\not=l$. Furthermore changing the order of $i,j$ or $k,l$ we only change the sign of the corresponding components $R_{ijkl}$. Thus, for manifolds of dimension $n =
# 2,$ there is only one independent component of the Riemannian curvature tensor, namely, $R_{1212}$. The remaining ones vanish or can be obtained by permutations of indices $(i,j)=(1,2), \ (k,l)=(1,2)$ and an appropriate change of signs.
# Suppose we are given a surface in Euclidean 3-space
#
# $$ x=x(u,v),\ \ y=y(u,v),\ \ z=z(u,v),\ \ (u,v)\in V\subset R^2,$$
#
# and a non-singular
# point $P=(x_0 , y_0 , z_0 )=(x(u_0,v_0),y(u_0,v_0),z(u_0,v_0))$ on it. i.e.,
#
# $$
# \text{rank}\left.
# \left(
# \begin{matrix}
# x_u & y_u & z_u\\
# x_v & y_v & z_v
# \end{matrix}
# \right)
# \right|_{(u_0,v_0)}=2.
# $$
#
# We shall assume that the $z$-axis is perpendicular to the tangent plane to the surface at the point $P,$ in which
# case the $x$-axis and $y$-axis will be parallel to it. The surface may then be given
# locally about (i.e. in a neighborhood of) the point $P$ by an equation
# of the form $z = f(x, y)$, where $z_0 = f(x_0 , y_0 )$ and
#
# $$\frac{\partial f}{\partial x}\Big|_{\substack{x=x_0\\y=y_0}}
# =\frac{\partial f}{\partial y}\Big|_{\substack{x=x_0\\y=y_0}}=0, \quad \text{i.e.}\quad
# \text{grad}\, f\,\Big|_{\substack{x=x_0\\y=y_0}}=0.
# $$
#
# Given a surface $z = f(x, y)$, and a point $P=(x_0 , y_0 , z_0 )$ on it
# at which grad $f = 0$, we can define the **Gaussian curvature $K$** of the surface at $(x_0,y_0,z_0)$ to be the determinant of the matrix
#
# $$K=\det (f_{x^ix^j})\Big|_{\substack{x=x_0\\y=y_0}}=
# \det \left(
# \begin{matrix}
# f_{xx} & f_{xy}\\
# f_{yx} & f_{yy}
# \end{matrix}
# \right)\Big|_{\substack{x=x_0\\y=y_0}}.
# $$
#
# The metric on such surface is defined by
#
# $$ g_{11}=1+f^2_x,\quad g_{12}=f_xf_y,\quad g_{22}=1+f_y^2.$$
#
# By the assumption $\text{grad}\, f\,\Big|_{\substack{x=x_0\\y=y_0}}=0$ at point $P$, the derivatives of $g_{ij}$ with respect to $x$ and $y$ vanish, so all Levi-Civita connection coefficients $\Gamma^m_{ij}=0$ at $P$.
#
# Recall the formulas defining the Riemannian curvature tensor at $P$ ( here, as usual $(g_{ij})$ is the matrix of metric components and $(g^{ij})$ its inverse).
#
# $$\displaystyle\Gamma_{rs}^q=\frac{1}{2}g^{tq}\Big(\frac{\partial g_{rt}}{\partial x^s}
# +\frac{\partial g_{ts}}{\partial x^r}-
# \frac{\partial g_{sr}}{\partial x^t}\Big),\\
# R^m_{kij}=\frac{\partial \Gamma^m_{kj}}{\partial x^i}
# -\frac{\partial \Gamma^m_{ki}}{\partial x^j}
# +\Gamma^m_{li}\Gamma^l_{kj}
# -\Gamma^m_{lj}\Gamma^l_{ki},\\
# R_{ijkl}=g_{im}R^m_{jkl}
# =g_{im}
# \Big(\frac{\partial \Gamma^m_{jl}}{\partial x^k}
# -\frac{\partial \Gamma^m_{jk}}{\partial x^l}\Big),\\
# $$
# (in the last formula we used the fact that $\Gamma^m_{ki}=0$ at $P=(x_0,y_0,z_0)$).
# To obtain the derivatives of Christoffel symbols we need their values in a neighborhood of $P$
#
# $$\Gamma^m_{jl}=\frac{1}{2}g^{pm}\Big(\frac{\partial g_{jp}}{\partial x^l}
# +\frac{\partial g_{pl}}{\partial x^j}-
# \frac{\partial g_{lj}}{\partial x^p}\Big),
# $$
# so using the fact that derivatives of $g_{ij}$ vanish at $P$ we obtain
#
# $$\frac{\partial \Gamma^m_{jl}}{\partial x^k}
# =\frac{1}{2}g^{pm}\big(\frac{\partial^2 g_{jp}}{\partial x^k\partial x^l}
# +\frac{\partial^2 g_{pl}}{\partial x^k\partial x^j}-
# \frac{\partial^2 g_{lj}}{\partial x^k\partial x^p}\Big).
# $$
# Similarly
#
# $$\Gamma^m_{jk}=\frac{1}{2}g^{pm}\Big(\frac{\partial g_{jp}}{\partial x^k}
# +\frac{\partial g_{pk}}{\partial x^j}-
# \frac{\partial g_{kj}}{\partial x^p}\Big),
# $$
# so
# $$
# \frac{\partial \Gamma^m_{jk}}{\partial x^l}
# =\frac{1}{2}g^{pm}\big(\frac{\partial^2 g_{jp}}{\partial x^l\partial x^k}
# +\frac{\partial^2 g_{pk}}{\partial x^l\partial x^j}-
# \frac{\partial^2 g_{kj}}{\partial x^l\partial x^p}\Big).
# $$
# Since $g_{im}g^{pm}=\delta_i^p$, then $R_{ijkl}$ is a difference of two expressions:
#
# $$\frac{1}{2}\delta_i^p\big(\frac{\partial^2 g_{jp}}{\partial x^k\partial x^l}
# +\frac{\partial^2 g_{pl}}{\partial x^k\partial x^j}-
# \frac{\partial^2 g_{lj}}{\partial x^k\partial x^p}\big)
# =
# \frac{1}{2}\big(\frac{\partial^2 g_{ji}}{\partial x^k\partial x^l}
# +\frac{\partial^2 g_{il}}{\partial x^k\partial x^j}-
# \frac{\partial^2 g_{lj}}{\partial x^k\partial x^i}\big)
# $$
#
# and
#
# $$\frac{1}{2}\delta_i^p\big(\frac{\partial^2 g_{jp}}{\partial x^l\partial x^k}
# +\frac{\partial^2 g_{pk}}{\partial x^l\partial x^j}-
# \frac{\partial^2 g_{kj}}{\partial x^l\partial x^p}\big)
# =
# \frac{1}{2}\big(\frac{\partial^2 g_{ji}}{\partial x^l\partial x^k}
# +\frac{\partial^2 g_{ik}}{\partial x^l\partial x^j}-
# \frac{\partial^2 g_{kj}}{\partial x^l\partial x^i}\big).
# $$
#
# Thus
#
# $$R_{ijkl}=\frac{1}{2}\Big(
# \frac{\partial^2 g_{il}}{\partial x^k\partial x^j}+
# \frac{\partial^2 g_{kj}}{\partial x^l\partial x^i}-
# \frac{\partial^2 g_{lj}}{\partial x^k\partial x^i}-
# \frac{\partial^2 g_{ik}}{\partial x^l\partial x^j}\Big).
# $$
#
# For $(i,j,k,l)=(1,2,1,2)$ we obtain
# $$R_{1212}=\frac{1}{2}\Big(
# \frac{\partial^2 g_{12}}{\partial x^1\partial x^2}+
# \frac{\partial^2 g_{12}}{\partial x^2\partial x^1}-
# \frac{\partial^2 g_{22}}{\partial x^1\partial x^1}-
# \frac{\partial^2 g_{11}}{\partial x^2\partial x^2}\Big)\\
# =\frac{1}{2}\Big(\frac{\partial^2 g_{12}}{\partial x\partial y}+
# \frac{\partial^2 g_{12}}{\partial y\partial x}-
# \frac{\partial^2 g_{22}}{\partial x^2}-
# \frac{\partial^2 g_{11}}{\partial y^2}\Big)
# .
# $$
#
# Since at $P$
# $$(g_{11})_{yy}=2(f_{xy})^2,\quad (g_{22})_{xx}=2(f_{xy})^2,\quad (g_{12})_{xy}=f_{xx}f_{yy}+(f_{xy})^2,
# $$
# we have at $P$
# $$R_{1212}=\frac{1}{2}\big(2(f_{xx}f_{yy}+(f_{xy})^2)
# -2(f_{xy})^2
# -2(f_{xy})^2\big)=f_{xx}f_{yy}-(f_{xy})^2=\det
# \left(
# \begin{matrix}
# f_{xx} & f_{xy}\\
# f_{yx} & f_{yy}
# \end{matrix}
# \right)=K.
# $$
#
#
#
# ### Ricci tensor and scalar curvature
#
#
#
# **Ricci tensor** can be defined by
#
# \begin{equation}
# Ric(u,v)=R(e^i,u,e_i,v),
# \tag{24.3}
# \end{equation}
#
# for any vector fields $u,v$, where $e_i$ is any vector frame and $e^i$ the corresponding coframe.
#
# In a Riemannian manifold with the metric $g$ the components of Ricci tensor are defined by
#
# $$Ric_{ij}=R^k_{ikj}=g^{kl}R_{likj}=g^{lk}R_{kjli},$$
#
# and the **scalar curvature** by
#
# \begin{equation}
# R=g^{ij}Ric_{ij}.
# \tag{24.4}
# \end{equation}
#
# In the case of two-dimensional manifold we have $R=2K$. In fact
#
# $$R=g^{ij}Ric_{ij}=g^{ij}g^{lk}R_{kjli}.$$
#
# From the symmetry properties of $R_{ijkl}$ it follows that in the obtained sum of $2^4$ elements only 4 are non-zero:
#
# $$R=g^{22}g^{11}R_{1212}+g^{12}g^{21}R_{1221}+
# g^{21}g^{12}R_{2112}+g^{11}g^{22}R_{2121}\\
# =g^{22}g^{11}R_{1212}-g^{12}g^{21}R_{1212}-g^{21}g^{12}R_{1212}+g^{11}g^{22}R_{1212}\\
# =2(g^{11}g^{22}-(g^{12})^2)R_{1212}=2\det (g^{ij})R_{1212}=\frac{2}{\det (g_{ij})}R_{1212}.
# $$
#
# **Remark** in the last calculations the condition $\text{grad}\, f\,\Big|_{\substack{x=x_0\\y=y_0}}=0,$ was not used.
#
#
# If as previously, the coordinates at $P$ are such that $\text{grad}\, f\,\Big|_{\substack{x=x_0\\y=y_0}}=0,$ we have $ \det (g_{ij})\Big|_{\substack{x=x_0\\y=y_0}}=1$ and $R=2K$. Since $R$ and $K$ are scalars, and consequently, are coordinate-independent, we conclude that
#
# \begin{equation}
# R = 2K
# \tag{24.5}
# \end{equation}
#
# at every (non-singular) point of the surface.
#
#
# **Remark.** For non-singular surfaces represented locally in the form $z=f(x,y)$ (without the condition $\text{grad}\, f\,\Big|_{\substack{x=x_0\\y=y_0}}=0$) the Gauss curvature is defined by
# $$K=\frac{f_{xx}f_{yy}-(f_{xy})^2}{(1+(f_x)^2+(f_y)^2)^2}.$$
#
# **Remark.**
# The calculations above give us the formula
# $$R_{1212}=\frac{R}{2}\det(g_{ij}).$$
#
# It can be generalized to all components of the tensor $R_{ijkl}$ as follows:
#
# $$R_{ijkl}=\frac{R}{2}(g_{ik}g_{jl}-g_{il}g_{jk}).$$
#
# In fact, an explicit calculations using the symmetry properties of $R_{ijkl}$ show that
#
# \begin{eqnarray}
# (i,j,k,l)=(1,2,1,2)\quad \Rightarrow & \quad
# \frac{R}{2}(g_{11}g_{22}-g_{12}g_{21})=\frac{R}{2}\det(g_{ij})=R_{1212},\\
# (i,j,k,l)=(2,1,1,2)\quad \Rightarrow & \quad
# \frac{R}{2}(g_{21}g_{12}-g_{22}g_{11})=-\frac{R}{2}\det(g_{ij})=R_{2112},\\
# (i,j,k,l)=(1,2,2,1)\quad \Rightarrow & \quad
# \frac{R}{2}(g_{12}g_{21}-g_{11}g_{22})=-\frac{R}{2}\det(g_{ij})=R_{1221},\\
# (i,j,k,l)=(2,1,2,1)\quad \Rightarrow & \quad
# \frac{R}{2}(g_{22}g_{11}-g_{21}g_{12})=\frac{R}{2}\det(g_{ij})=R_{2121},\\
# \end{eqnarray}
#
# and for the remaining sequences of indices, both sides are zero.
#
#
#
#
# **Example 24.1**
#
# In $R^2$ with $g=dx\otimes dx+dy\otimes dy$, we have $R^i_{mkl}=0$ and $K=\frac{R}{2}=0.$
# In[2]:
E.=EuclideanSpace() # Euclidean space E^2
print(E.metric().riemann()) # curvature tensor of (1,3)-type
E.metric().riemann().disp() # show the curvature tensor
# The method `ricci` gives the Ricci tensor:
# In[3]:
print(E.metric().ricci()) # Ricci curvature tensor
E.metric().ricci().disp() # show the result
# The Ricci scalar curvature can be obtained using `ricci_scalar` method:
# In[4]:
E.metric().ricci_scalar().expr() # Ricci scalar curvature
#
#
# **Example 24.2**
#
# The same can be done without `EuclideanSpace` command.
# In[5]:
get_ipython().run_line_magic('display', 'latex')
M=Manifold(2,name='R^2',start_index=1) # manifold R2
c_xy.=M.chart() # chart on R^2
g = M.metric('g'); # metric on R^2
g[:]=[[1,0],[0,1]] # nonzero components
Riem=g.riemann() # curvature (1,3)-type tensor
print(Riem) # show information on curv. tensor
Riem.disp() # show the curvature tensor
# In[6]:
print(g.ricci()) # Ricci curvature tensor information
g.ricci().disp() # show Ricci tensor
# The Ricci scalar curvature:
# In[7]:
g.ricci_scalar().expr() # Ricci scalar curvature
#
#
# **Example 24.3**
#
# For the metric on the sphere $S^2\subset R^3$, we have
# $𝑔=d𝜃⊗d𝜃+sin(𝜃)^2d𝜙⊗d𝜙$, $K=R/2=1.$
# In[8]:
get_ipython().run_line_magic('display', 'latex')
M = Manifold(3, 'R^3') # R^3 ambient space for S^2
c_xyz. = M.chart() # chart on R^3
N = Manifold(2, 'N',start_index=1) # sphere S^2
c_sph.=N.chart() # chart on S^2
psi = N.diff_map(M, (sin(theta)*cos(phi),
sin(theta)*sin(phi),
cos(theta)),
name='psi',latex_name=r'\psi') # embedding S^2 -> R^3
g0=M.metric('g0') # metric g0 on R^3
g0[0,0],g0[1,1],g0[2,2]=1,1,1 # components of g0
g=N.metric('g') # metric on S^2
g.set( psi.pullback(g0) ) # g is the pullback of g0
g.disp() # show g
# In[9]:
Riem=g.riemann() # curvature (1,3)-tensor
Riem.display_comp(coordinate_labels=False) # show components
# In[10]:
print(g.ricci()) # Ricci curvature tensor
g.ricci().disp() # show Ricci tensor
# Let us show how to apply (24.3).
#
# First we have to define the frame and coframe fields:
# In[11]:
fr=c_sph.frame()[:] # frame
cfr=c_sph.coframe()[:] # coframe
# next we define the matrix of coefficient of the Ricci tensor field according to (24.3).
# In[12]:
Ric_coeff=[[sum([Riem(cfr[i],fr[k],fr[i],fr[l]).expr()
for i in range(2)])
for k in range(2)] for l in range(2)] # cf. (24.3)
Ric_coeff[:] # Ricci ten. components
# Finally we define the Ricci tensor:
# In[13]:
Ric=N.tensor_field(0,2,'Ric') # Ricci curvature tensor
Ric[:]=Ric_coeff # define all components
Ric.disp() # show Ricci tensor
# Ricci scalar curvature:
# In[14]:
g.ricci_scalar().expr() # Ricci scalar curvature
# Formula (24.4) can be used as follows:
# In[15]:
g.inverse().contract(Ric).trace().expr()
# According to (24.5), the Gaussian curvature is 1.
#
#
# **Example 24.4**
#
# Consider the Poincare half-plane $y>0$ with the metric defined by
# $g_{11}=\frac{1}{y^2},\ \ g_{22}=\frac{1}{y^2}, \ $ and remaining components equal to zero.
# In[16]:
M = Manifold(2, 'M', start_index=1) # Poincare half-plane
X. = M.chart(coord_restrictions=lambda x,y: y>0)
g = M.metric('g') # metric on M
g[1,1], g[2,2] = 1/y^2, 1/y^2 # nonzero components of g
# Compute (1,3) type curvature tensor:
# In[17]:
Riem=g.riemann() # (1,3) type curvature tensor
Riem.display_comp(coordinate_labels=False) # show nonzero comp.
# and next the Riemannian curvature tensor of type (0,4), using (24.1):
# In[18]:
R=M.tensor_field(0,4,'R') # R is (0,4)-type tensor field
R[:]=g.contract(Riem)[:] # apply (24.1)
R.display_comp(coordinate_labels=False) # show (0,4) type ten. R
# Now compute the Ricci curvature tensor:
# In[19]:
g.ricci().disp() # Ricci curv. tensor
# and Ricci curvature scalar:
# In[20]:
g.ricci_scalar().expr() # Ricci scalar curv.
#
#
#
# **Example 24.5**
#
# Poincare disk is the set $\ \ \{(x,y)\in R^2:x^2+y^2<1\}\ \ $ with the metric defined by
# $g_{11}=\frac{4}{(1-x^2-y^2)^2},\ \ g_{22}=\frac{4}{(1-x^2-y^2)^2}\ \ $ and remaining components equal to zero.
# In[21]:
M = Manifold(2, 'M', start_index=1) # Poincare disc
# Cartesian coordinates on the Poincaré disk:
X. = M.chart('x:(-1,1) y:(-1,1)',
coord_restrictions=lambda x,y: x^2+y^2<1)
g = M.metric('g') # metric on M
# components of g
g[1,1], g[2,2] = 4/(1-x^2-y^2)^2,4/(1-x^2-y^2)^2
# Compute (1,3)-type curvature tensor. Since `g.riemann()` gives an unsimplified result, we simplify the components one by one.
# In[22]:
Riem = g.riemann(); # curvature (1,3) type tensor
# factor components
Riem2=[[[[Riem[a,b,c,d].factor() for a in [1,2]]
for b in [1,2]] for c in [1,2]] for d in[1,2]];
R=M.tensor_field(1,3,'R') # tensor field of type (1,3)
R[X.frame(),:]=Riem2 # simplified components
R.display_comp(coordinate_labels=False) # show R
# Ricci curvature tensor:
# In[23]:
Ric=g.ricci() # Ricci curvature tensor
Ric.apply_map(factor) # factor components
Ric.disp() # show Ricci curv.tensor
# Ricci curvature scalar:
# In[24]:
g.ricci_scalar().expr() # Ricci scalar curvature
#
#
# **Example 24.6**
#
# Consider $R^2$ with the matrix of metric components:
# In[25]:
matrix([[1+4*x^2,4*x*y],[4*x*y,1+4*y^2]])
# In[26]:
N=Manifold(2,name='R^2',start_index=1) # Manifold R^2
X.=N.chart() # chart on R^2
g = N.metric('g'); # metric g on R^2
g[:]=[[1+4*x^2,4*x*y],[4*x*y,1+4*y^2]] # components of g
Riem = g.riemann(); # (1,3) type curv. tens.
R=N.tensor_field(0,4,'R') # (0,4) type curv. tens.
# Compute Riemannian (0,4)-type tensor.
# In[27]:
R[:]=g.contract(Riem)[:] # use (24.1)
R.display_comp(coordinate_labels=False) # show (0,4) t. R
# Ricci curvature tensor:
# In[28]:
Ric=g.ricci() # Ricci curvature tensor
Ric.apply_map(factor) # factor components
Ric.disp() # show the result
# and Ricci scalar curvature:
# In[29]:
factor(g.ricci_scalar().expr()/2) # Ricci curvature scalar
#
#
# **Example 24.7**
#
# Consider the embedding of the hyperboloid into $R^3$ defined by
# $\ \ \psi(u,v)= (u, v,u^2-v^2)$. The metric on the hyperboloid can be defined as the pullback $\psi^*g_0\ \ $ under $\psi$ where $g_0$ is the standard metric on $R^3$.
# In[30]:
get_ipython().run_line_magic('display', 'latex')
M = Manifold(3, 'R3') # manifold R^3
c_xyz. = M.chart() # Cart. coord. on R^3
N=Manifold(2,name='R2',start_index=1) # hyperboloid N
c_uv.=N.chart() # coordinates on N
g0 = M.metric('g0'); # standard metr, of R^3
g0[:]=[[1,0,0],[0,1,0],[0,0,1]]; # components of g0
psi = N.diff_map(M, (u, v,u^2-v^2) ,name='psi') # embedding
g=N.metric('g') # metric on N
g.set(psi.pullback(g0)) # g is pullback of g0
g.disp() # show g
# Compute the Riemannian curvature tensor of type (0,4).
# In[31]:
Riem = g.riemann(); # curv. (1,3) tensor
R=N.tensor_field(0,4,'R') # tensor field (0,4)-type
R[:]=g.contract(Riem)[:] # use (24.1)
R.display_comp(coordinate_labels=False) # show (0,4) type ten. R
# Ricci tensor:
# In[32]:
Ric=g.ricci() # Ricci curvature tensor
Ric.apply_map(factor) # factor components
Ric.disp() # show the Ricci tensor
# Ricci scalar curvature:
# In[33]:
factor(g.ricci_scalar().expr()) # Ricci scalar curvature
# ## What's next?
#
# Take a look at the notebook [Torsion and curvature forms](https://nbviewer.org/github/sagemanifolds/IntroToManifolds/blob/main/25Manifold_Torsion_Curvature_Forms.ipynb).