#!/usr/bin/env python
# coding: utf-8
# # 23. Curvature
#
# 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()
# Consider first the case of **Euclidean connection** (notebook 21).
#
# Recall that for an open subset $U\subset R^n$, with Cartesian coordinate system $(U,x^1,\ldots,x^n)$ and vector fields $X,Y\in\mathfrak{X}(U)$, $Y=Y^k \frac{\partial}{\partial x^k}$, we defined the Euclidean connection by $D_XY=X(Y^k)\frac{\partial}{\partial x^k}$.
#
# From this definition it follows that
# $$
# D_XD_YZ
# =X(Y(Z^k))\frac{\partial}{\partial x^k},\quad \text{ for }
# X,Y,Z\in\mathfrak{X}(U).
# $$
# In fact, from the definition of $D_YZ$ it follows that if we put
# $\tilde{Y}^k=Y(Z^k)$, then
# $$D_XD_YZ=D_X(Y(Z^k)\frac{\partial}{\partial x^k})
# =D_X(\tilde{Y}^k\frac{\partial}{\partial x^k})
# =X(\tilde{Y}^k)\frac{\partial}{\partial x^k}=
# X(Y(Z^k))\frac{\partial}{\partial x^k}.
# $$
#
# Using this representation for iterated Euclidean connection we can see that
# $$D_XD_YZ-D_YD_XZ
# =X(Y(Z^k))\frac{\partial}{\partial x^k}
# -Y(X(Z^k))\frac{\partial}{\partial x^k}
# =[X,Y](Z^k)\frac{\partial}{\partial x^k}
# =D_{[X,Y]}Z.
# $$
# i.e.
# \begin{equation}
# D_XD_YZ-D_YD_XZ
# -D_{[X,Y]}Z=0.
# \tag{*}
# \end{equation}
# Recall also that for general connection $\ \nabla\ $ and general vector fields $\displaystyle X=X^i\frac{∂}{∂x^i}, Y=Y^j\frac{∂}{∂x^j}$ we have $\displaystyle ∇_X Y = (X^i\frac{∂}{∂x^i} Y^k + Γ^k_{ij} X^i Y^j )\frac{∂}{∂x^k}$,
# where $Γ^k_{ij}$ are defined by
# $\displaystyle ∇_{\frac{∂}{∂x^i}} \frac{∂}{∂x^j} = Γ^k_{ij}\frac{∂} {∂x^k}$ and consequently the equality $(*)$ is not true. Nevertheless the left hand side of $(*)$ can be used as a kind of
# measure of "flatness" of the manifold
# or a measure how much the geometry of the manifold differs from the geometry of the Euclidean space.
#
#
#
# ### Curvature map
#
#
#
# The **curvature** $R$, of the connection ∇ is a map that associates to each pair
# of vector fields an operator from $\mathfrak{X}(M)$ into itself, given by
#
# \begin{equation}
# R(X, Y)Z = ∇_X ∇_Y Z − ∇_Y ∇_X Z− ∇_{[X,Y]}Z,\quad
# \text{for}\ X, Y, Z ∈ \mathfrak{X}(M).
# \tag{23.1}
# \end{equation}
#
# From the properties of the covariant derivative and Lie bracket it follows
#
# $$
# R(X, Y) = −R(Y, X)\\
# $$
# To prove the tensorial property (see notebook 13) of $R$ , we need to show that
# $R(X, Y )Z$ is multilinear over $C^∞ (M )$ in each of the three vector fields. First we show linearity for the $X$ variable, from which linearity immediately follows for the $Y$
# variable.
#
# Let $f_1 , f_2 ∈ C^∞ (M ).$ Then
#
# $$R(f_1 X_1 + f_2 X_2 , Y )Z \\
# =\nabla_{f_1X_1+f_2X_2}\nabla_YZ-\nabla_Y\nabla_{f_1X_1+f2X_2}Z-
# \nabla_{[f_1X1+f_2X_2,Y]}Z
# \\
# = (f_1 ∇_{X_1} + f_2 ∇_{X_2} )∇_Y Z
# -∇_Y (f_1 ∇_{X_1} + f_2 ∇_{X_2} )Z − ∇_{[f_1 X_1 ,Y ]+[f_2 X_2 ,Y ]} Z.
# $$
#
# Since (cf. notebook 12) $\ [f X , Y ] = f [X , Y ] − Y (f )X $, we have
#
# $$
# R(f_1 X_1 + f_2 X_2 , Y )Z
# = f_1 ∇_{X_1} ∇_Y Z + f_2 ∇_{X_2} ∇_Y Z\\ − f_1 ∇_Y ∇_{X_1} Z − Y (f_1 )∇_{X_1}Z
# − f_2 ∇_Y ∇_{X_2} Z − Y (f_2 )∇_{X_2} Z\\ − ∇_{f_1 [X_1 ,Y ]−Y (f_1 )X_1} Z − ∇_{f_2[X_2 ,Y ]−Y (f_2 )X_2} Z\\
# =f_1 ∇_{X_1} ∇_Y Z − f_1 ∇_Y ∇_{X_1} Z − f_1 ∇_{[X_1 ,Y ]} Z\\
# + f_2 ∇_{X_2} ∇_Y Z − f_2 ∇_Y ∇_{X_2} Z − f_2 ∇_{[X_2 ,Y ]}Z\\
# − Y (f_1 )∇_{X_1} Z − Y (f_2 )∇_{X_2} Z + Y (f_1 )∇_{X_1} Z + Y (f_2 )∇_{X_2} Z\\
# = f_1 R(X_1 , Y )Z + f_2 R(X_2 , Y )Z.
# $$
#
#
#
# Next we check the linearity for the $Z$ variable
#
# $$R(X, Y)( f_1 Z_1+f_2Z_2)\\
# =
# ∇_X ∇_Y (f_1 Z_1+f_2Z_2) − ∇_Y ∇_X (f_1 Z_1+f_2Z_2)
# − ∇_{[X,Y ]} (f_1 Z_1+f_2Z_2)\\
# =∇_X (Y (f_1 )Z_1+ f_1 ∇_Y Z_1)
# − ∇_Y (X(f_1 )Z_1 + f_1 ∇_X Z_1)
# -[X,Y](f_1)Z_1-f_1 ∇_{[X,Y]}Z_1\\
# +∇_X (Y (f_2 )Z_2+ f_2 ∇_Y Z_2)
# − ∇_Y (X(f_2 )Z_2 + f_2 ∇_X Z_2)
# -[X,Y](f_2)Z_2-f_2 ∇_{[X,Y]}Z_2\\
# =X(Y (f_1 ))Z_1 + Y (f_1)∇_X Z_1 + X(f_1 )∇_Y Z_1 + f_1∇_X ∇_Y Z_1\\
# − Y (X(f_1))Z_1 − X(f_1) ∇_Y Z_1 − Y (f_1) ∇_X Z_1 − f_1∇_Y ∇_X Z_1\\
# − (X(Y (f_1))X − Y (X(f_1))Z_1 − f_1 ∇_{[X,Y ]} Z_1\\
# +X(Y (f_2 ))Z_2 + Y (f_2)∇_X Z_2 + X(f_2 )∇_Y Z_2 + f_2∇_X ∇_Y Z_2\\
# − Y (X(f_2))Z_2 − X(f_2) ∇_Y Z_2 − Y (f_2) ∇_X Z_2 − f_2∇_Y ∇_X Z_2\\
# − (X(Y (f_2))X − Y (X(f_2))Z_2 − f_2 ∇_{[X,Y ]} Z_2\\
# = f_1 (∇_X ∇_Y Z_1 − ∇_Y ∇_X Z_1 − ∇_{[X,Y ]} Z_1)\\
# +f_2 (∇_X ∇_Y Z_2 − ∇_Y ∇_X Z_2 − ∇_{[X,Y ]} Z_2)\\
# =f_1R(X,Y)Z_1+f_2R(X,Y)Z_2.
# $$
#
#
# ### Curvature tensor of type $T^{(1,3)}M$
#
#
#
#
# Since $R$ takes its values in $\mathfrak{X}(M)$, it does not satisfy the definition of tensor field (which takes its values in $C^\infty(M) )$, however, $R$ is equivalent to the tensor field of type $T^{(1,3)}M$ defined by
# $\tilde{R}(α, X, Y, Z) ≡ α(R(X, Y)Z).$
#
# **Remark.** In `SageMath Manifolds` the method `riemann` returns this $(1,3)$-type tensor.
#
# A connection $∇$ is **flat** if its curvature tensor is zero.
#
#
#
# ### Curvature in local coordinates
#
#
#
# If $X=X^i\frac{\partial}{\partial x^i},
# Y=Y^j\frac{\partial}{\partial x^j},
# Z=Z^k\frac{\partial}{\partial x^k},$ then
#
# $$R(X, Y)Z = X^i Y^j Z^k R^m_{kij}\frac{\partial}{\partial x^m},$$ where
#
# \begin{equation}
# 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}
# \tag{23.2}
# \end{equation}
#
#
# In fact, from (23.1), the definition of Christoffel symbols and the relation $[\frac{\partial}{\partial x^i},\frac{\partial}{\partial x^j}]=0$ we have
#
# $$\displaystyle
# R(\frac{\partial}{\partial x^i},
# \frac{\partial}{\partial x^j})
# \frac{\partial}{\partial x^k}=\displaystyle
# =\nabla_{\frac{\partial}{\partial x^i}}
# \nabla_{\frac{\partial}{\partial x^j}}\frac{\partial}{\partial x^k}
# -\nabla_{\frac{\partial}{\partial x^j}}
# \nabla_{\frac{\partial}{\partial x^i}}\frac{\partial}{\partial x^k}\\
# =\displaystyle
# \nabla_{\frac{\partial}{\partial x^i}}
# \Big(\Gamma^m_{kj}\frac{\partial}{\partial x^m}\Big)
# -\nabla_{\frac{\partial}{\partial x^j}}
# \Big(\Gamma^m_{ki}\frac{\partial}{\partial x^m}\Big)\\
# =\Gamma^m_{kj}\nabla_{\frac{\partial}{\partial x^i}}
# \frac{\partial}{\partial x^m}
# +\frac{\partial \Gamma^m_{kj}}{\partial x^i}\frac{\partial}{\partial x^m}
# -\Gamma^m_{ki}\nabla_{\frac{\partial}{\partial x^j}}
# \frac{\partial}{\partial x^m}
# -\frac{\partial \Gamma^m_{ki}}{\partial x^j}\frac{\partial}{\partial x^m}\\
# =\Gamma^m_{kj}\Gamma^l_{mi}\frac{\partial}{\partial x^l}
# +\frac{\partial \Gamma^m_{kj}}{\partial x^i}
# \frac{\partial}{\partial x^m}
# -\Gamma^m_{ki}\Gamma^l_{mj}\frac{\partial}{\partial x^l}
# -\frac{\partial \Gamma^m_{ki}}{\partial x^j}
# \frac{\partial}{\partial x^m}\\
# =\Big(\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}\Big)
# \frac{\partial}{\partial x^m}.
# $$
#
#
#
#
# **Example 23.1**
#
# In notebook 21 we have noticed that
# all Christoffel symbols for the Euclidean connection vanish.
# Consequently the curvature for this connection vanishes.
# In[2]:
R2=Manifold(2,'R^2') # manifold R^2
c_xy.=R2.chart() # Cartesian coordinates
nab=R2.affine_connection('nab') # Eucl.connection on R^2
nab[1,1,1]=0 # all coeff. zero
R=nab.riemann();R # curvature of Eucl.conect.
# In[3]:
R.disp() # show R
#
#
# **Example 23.2**
#
# Using the standard metric of the Euclidean space, the previous example can be simplified.
# In[4]:
E.=EuclideanSpace()
E.metric().riemann().disp()
#
#
# **Example 23.3**
#
# Consider the two-dimensional half-plane $y>0$ with connection coefficients defined by
# $\ \ \Gamma^1_{12}=\Gamma^1_{21}=\Gamma^2_{22}=-\frac{1}{y}\ \ $
# and $\ \ \Gamma^2_{11}=\frac{1}{y}.$
# In[5]:
get_ipython().run_line_magic('display', 'latex')
M = Manifold(2, 'M', start_index=1) # manifold M, y>0
c_xy. = M.chart() # chart on M
# affine connection on M:
nab = M.affine_connection('nabla', r'\nabla')
# In[6]:
# Christoffel symbols:
nab[1,1,2], nab[1,2,1],nab[2,2,2],nab[2,1,1] = -1/y, -1/y,-1/y,1/y
get_ipython().run_line_magic('display', 'latex')
nab.display(coordinate_labels=False) # show Christoffel symbols
# (only non-zero ones)
# Using (23.2) with $\ (x^1,x^2)=(x,y)\ $ to compute $R^1_{212}$ we obtain
#
# $$R^1_{212}=\frac{\partial \Gamma^1_{22}}{\partial x^1}
# -\frac{\partial \Gamma^1_{21}}{\partial x^2}
# +\Gamma^1_{11}\Gamma^1_{22}+\Gamma^1_{21}\Gamma^2_{22}
# -\Gamma^1_{12}\Gamma^1_{21}-\Gamma^1_{22}\Gamma^2_{21}\\
# =0-\frac{1}{y^2}+0\cdot 0+(-\frac{1}{y})(-\frac{1}{y})
# -(-\frac{1}{y})(-\frac{1}{y})-0\cdot 0=-\frac{1}{y^2}.
# $$
#
# The remaining components can be found analogously (one can use antisymmetry of $R^m_{kij}$ with respect to $i,j$).
# In[7]:
Riem = nab.riemann(); print(Riem) # curvature (1,3) tensor
Riem.display_comp(coordinate_labels=False) # show nonzero components
#
#
# **Example 23.4**
#
# Consider the plane $R^2$ with Christoffel symbols
# $$Γ^1_{11}= Γ^1_{22}=\frac{4u}{1+u^2+4v^2},\\
# Γ^2_{11}= Γ^2_{22}=\frac{4v}{1+u^2+4v^2},
# $$
# and the remaining symbols equal to 0.
# In[8]:
get_ipython().run_line_magic('display', 'latex')
N=Manifold(2,name='R2',start_index=1) # manifold M, dim=2
c_uv.=N.chart() # coordinates u,v
nab=N.affine_connection('nab') # connection on M
nab[:]=[[[4*u/(4*u^2 + 4*v^2 + 1), 0], # Christoffel symbols
[0, 4*u/(4*u^2 + 4*v^2 + 1)]],
[[4*v/(4*u^2 + 4*v^2 + 1), 0],
[0, 4*v/(4*u^2 + 4*v^2 + 1)]]]
nab.display(coordinate_labels=False,only_nonzero=False)
# Compute components of the curvature $(1,3)$ tensor. At a first attempt we obtain some components non-simplified.
# In[9]:
Riem = nab.riemann(); # curvature (1,3) tensor
Riem.display_comp(coordinate_labels=False)
# so we decided to simplify each component separately and to introduce a new tensor with simplified components.
# In[10]:
# simplification of components one by one
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]];
Riem1 = N.tensor_field(1, 3, name='Riem1') # new tensor (1,3)type
Riem1[c_uv.frame(), :] = Riem2 # with simplified comp.
Riem1.display_comp(coordinate_labels=False)
#
#
# ### Extension of curvature map to covariant tensor fields
#
#
# If we extend the definition $R(X, Y)t ≡ ∇_X ∇_Y t − ∇_Y ∇_X t − ∇_{[X,Y]} t$, to all tensor
# fields $t\in T^{(0,k)}M,$ then one can check that for covariant tensor fields $\ t,s$, vector fields $\ X,Y$ and smooth function $f$
#
# \begin{equation}
# \begin{matrix}
# R(X, Y)(t + s) = R(X, Y)t + R(X, Y)s,\\
# R(X, Y)( f t) = f R(X, Y)t,\\
# R(X, Y)(t ⊗ s) = R(X, Y)t ⊗ s + t ⊗ R(X, Y)s .
# \end{matrix}
# \tag{23.3}
# \end{equation}
#
# The first relation follows from
#
# $$ \nabla_X\nabla_Y(t+s)-\nabla_Y\nabla_X(t+s)-\nabla_{[X,Y]}(t+s)\\
# =\nabla_X\nabla_Yt+\nabla_X\nabla_Ys-
# \nabla_Y\nabla_Xt+\nabla_Y\nabla_Xs-\nabla_{[X,Y]}t-\nabla_{[X,Y]}s,
# $$
#
# the second from
#
# $$
# \nabla_X\nabla_Y(ft)-\nabla_Y\nabla_X(ft)-\nabla_{[X,Y]}(ft)\\
# =\nabla_X(f\nabla_yt+(Yf)t)-\nabla_Y(f\nabla_Xt+(Xf)t)
# -f\nabla_{[X,Y]}t-([X,Y]f)t\\
# =f\nabla_X\nabla_Yt+(Xf)\nabla_Y t +(Yf)\nabla_Xt+(X(Yf))t\\
# -f\nabla_Y\nabla_Xt-(Yf)\nabla_Xt-(Xf)\nabla_Y t-(X(Yf))t\\
# -f\nabla_{[X,Y]}t-([X,Y]f)t,
# $$
#
# and the third from
#
# $$
# \nabla_X\nabla_Y(t\otimes s)-\nabla_Y\nabla_X(t\otimes s)-\nabla_{[X,Y]}(t\otimes s)\\
# =\nabla_X(t\otimes\nabla_Ys+(\nabla_Yt)\otimes s)
# -\nabla_Y(t\otimes\nabla_X s+(\nabla_X t)\otimes s)\\
# -t\otimes(\nabla_{[X,Y]}s)-(\nabla_{[X,Y]}t)\otimes s\\
# =t\otimes\nabla_X\nabla_Y s+(\nabla_Xt)\otimes(\nabla_Y s)
# +(\nabla_X\nabla_Y t)\otimes s+(\nabla_Y t)\otimes(\nabla_X s)\\
# -t\otimes\nabla_Y\nabla_Xs-(\nabla_Y t)\otimes(\nabla_X s)
# -(\nabla_Y\nabla_X t)\otimes s-(\nabla_X t)\otimes(\nabla_Y s)\\
# -t\otimes\nabla_{[X,Y]}s-(\nabla_{[X,Y]}t)\otimes s.
# $$
#
#
#
# ### Bianchi identities
#
#
#
# If $T$ is the torsion and $R$ the curvature, then
# for $X, Y, Z ∈ \mathfrak{X}(M)$, the following **first Bianchi identity** holds true.
#
# \begin{equation}
# \begin{matrix}
# R(X, Y)Z + R(Z, X)Y + R(Y, Z)X\\
# = ∇_X (T (Y, Z)) + ∇_Y (T (Z, X)) + ∇_Z (T (X, Y))\\
# + T (X, [Y, Z]) + T (Y, [Z, X]) + T (Z, [X, Y])
# \end{matrix}
# \tag{23.4}
# \end{equation}
#
# In fact, from the definition of torsion we have
# $$
# \nabla_XY=\nabla_YX+[X,Y]+T(X,Y),\\
# \nabla_ZX=\nabla_XZ+[Z,X]+T(Z,X),\\
# \nabla_YZ=\nabla_ZY+[Y,Z]+T(Y,Z),
# $$
# and therefore
# $$
# R(X, Y)Z + R(Z, X)Y + R(Y, Z)X\\
# =∇_X ∇_Y Z − ∇_Y ∇_X Z − ∇_{[X,Y]} Z\\
# +∇_Y ∇_Z X − ∇_Z ∇_Y X − ∇_{[Y,Z]} X\\
# +∇_Z ∇_X Y − ∇_X ∇_Z Y − ∇_{[Z,X]} Y\\
# =∇_X(\nabla_ZY+[Y,Z]+T(Y,Z))− ∇_Y ∇_X Z − ∇_{[X,Y]} Z\\
# +∇_Y(\nabla_XZ+[Z,X]+T(Z,X))− ∇_Z ∇_Y X − ∇_{[Y,Z]} X\\
# +∇_Z(\nabla_YX+[X,Y]+T(X,Y))− ∇_X ∇_Z Y − ∇_{[Z,X]} Y
# $$
# \begin{equation}
# \begin{matrix}
# =∇_X([Y,Z]+T(Y,Z)) − ∇_{[X,Y]} Z\\
# +∇_Y([Z,X]+T(Z,X)) − ∇_{[Y,Z]} X\\
# +∇_Z([X,Y]+T(X,Y)) − ∇_{[Z,X]} Y.
# \end{matrix}
# \tag{23.5}
# \end{equation}
# If we use the definition of torsion in the following form
#
# $$
# T(X,[Y,Z])=\nabla_X[Y,Z]-\nabla_{[Y,Z]}X-[X,[Y,Z]],\\
# T(Y,[Z,X])=\nabla_Y[Z,X]-\nabla_{[Z,X]}Y-[Y,[Z,X]],\\
# T(Z,[X,Y])=\nabla_Z[X,Y]-\nabla_{[X,Y]}Z-[Z,[X,Y]],\\
# $$
#
# then the subexpressions of (23.5) which do not contain $T$ take the form
#
# $$
# ∇_X([Y,Z]− ∇_{[Y,Z]} X = T(X,[Y,Z])+[X,[Y,Z]],\\
# ∇_Y([Z,X]− ∇_{[Z,X]} Y = T(Y,[Z,X])+[Y,[Z,X]],\\
# ∇_Z([X,Y]− ∇_{[X,Y]} Z = T(Z,[X,Y])+[Z,[X,Y]].\\
# $$
#
# Using the Jacobi identity (notebook 12) we obtain (23.4).
#
#
# The **second Bianchi identity** reads as follows.
#
# For $X, Y, Z, W ∈ \mathfrak{X}(M)$
#
# \begin{equation}
# \begin{matrix}
# ∇_X( R(Y, Z)W) + ∇_Y( R(Z, X)W )+ ∇_Z( R(X, Y)W)\\
# = R(Y, Z)∇_X W + R(Z, X)∇_Y W + R(X, Y)∇_Z W\\
# + R([Y, Z], X)W + R([Z, X], Y)W + R([X, Y], Z)W.
# \end{matrix}
# \tag{23.6}
# \end{equation}
#
# To check the identity let us note that from (23.1) it follows
#
# \begin{equation}
# \begin{matrix}
# R([X, Y], Z)W+\nabla_{[[X,Y],Z]}W=
# \nabla_{[X,Y]}\nabla_ZW-\nabla_Z\nabla_{[X,Y]}W,\\
# R([Y, Z], X)W+\nabla_{[[Y,Z],X]}W=
# \nabla_{[Y,Z]}\nabla_XW-\nabla_X\nabla_{[Y,Z]}W,\\
# R([Z, X], Y)W+\nabla_{[[Z,X],Y]}W=
# \nabla_{[Z,X]}\nabla_YW-\nabla_Y\nabla_{[Z,X]}W,
# \end{matrix}
# \tag{23.7}
# \end{equation}
#
# therefore (we changed the order in the second column of expressions)
#
# $$
# ∇_X( R(Y, Z)W) + ∇_Y( R(Z, X)W )+ ∇_Z( R(X, Y)W)\\
# =∇_X(\nabla_Y\nabla_ZW-\nabla_Z\nabla_YW-\nabla_{[Y,Z]}W)\\
# +∇_Y(\nabla_Z\nabla_XW-\nabla_X\nabla_ZW-\nabla_{[Z,X]}W)\\
# +∇_Z(\nabla_X\nabla_YW-\nabla_Y\nabla_XW-\nabla_{[X,Y]}W)\\
# =\nabla_X\nabla_Y\nabla_ZW-\nabla_Y\nabla_X\nabla_ZW-\nabla_X\nabla_{[Y,Z]}W\\
# +\nabla_Y\nabla_Z\nabla_XW-\nabla_Z\nabla_Y\nabla_XW-\nabla_Y\nabla_{[Z,X]}W\\
# +\nabla_Z\nabla_X\nabla_YW-\nabla_X\nabla_Z\nabla_YW-\nabla_Z\nabla_{[X,Y]}W.\\
# $$
# In all three rows of the obtained sum we can recognize incomplete curvature tensors computed for $\nabla_ZW, \nabla_XW, \nabla_YW$ respectively. If we subtract and add the lacking terms with covariant derivatives along the corresponding Lie brackets, we obtain the following form of the last sum
#
# $$
# R(X,Y)\nabla_ZW+\nabla_{[X,Y]}\nabla_ZW-\nabla_X\nabla_{[Y,Z]}W\\
# +R(Y,Z)\nabla_XW+\nabla_{[Y,Z]}\nabla_XW-\nabla_Y\nabla_{[Z,X]}W\\
# +R(Z,X)\nabla_YW+\nabla_{[Z,X]}\nabla_YW-\nabla_Z\nabla_{[X,Y]}W\\
# $$
#
# In all three lines, the last two expressions are equal to the right hand sides of (23.7), therefore the obtained sum is equal
#
# $$
# R(X,Y)\nabla_ZW+R([X, Y], Z)W+\nabla_{[[X,Y],Z]}W\\
# +R(Y,Z)\nabla_XW+R([Y, Z], X)W+\nabla_{[[Y,Z],X]}W\\
# +R(Z,X)\nabla_YW+R([Z, X], Y)W+\nabla_{[[Z,X],Y]}W.
# $$
#
# The sum of the last column is zero according to Jacobi identity (notebook 12), so (23.6) is proved.
# Bianchi identities will be used in the proof of (24.2) in the [next notebook](https://nbviewer.org/github/sagemanifolds/IntroToManifolds/blob/main/24Manifold_RiemannCurvature.ipynb).
# ## What's next?
#
# Take a look at the notebook [Riemannian curvature tensor of type (0,4)](https://nbviewer.org/github/sagemanifolds/IntroToManifolds/blob/main/24Manifold_RiemannCurvature.ipynb).