#!/usr/bin/env python
# coding: utf-8
# # 19. Lie derivative
#
# 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()
# ### Lie derivative of functions
#
#
#
# If $ϕ$ is a one-parameter group of transformations on $M$ ([notebook 17](https://nbviewer.org/github/sagemanifolds/IntroToManifolds/blob/main/17Manifold_One_Parameter.ipynb)), then the map $ϕ_t : M →
# M$, defined by $ϕ_t (x) = ϕ(x, t)$, is smooth and therefore for
# $f ∈ C^∞ (M),\ \ $
# $ϕ_t^*f = f\circ \phi_t\ $
# also belongs to $C^∞ (M)$.
#
# If $X$ is the infinitesimal generator of $ϕ$ ([notebook 17](https://nbviewer.org/github/sagemanifolds/IntroToManifolds/blob/main/17Manifold_One_Parameter.ipynb)),
# then the **Lie derivative of $f$ with respect to $X$** is defined by
#
# \begin{equation}
# \mathcal{L}_Xf=\lim_{t\to 0}\frac{\phi_t^*f-f}{t}
# =\frac{d}{dt}(\phi_t^*f)\Big|_{t=0}.
# \tag{19.1}
# \end{equation}
#
#
#
#
# **Example 19.1**
#
# Compute $\ \ \mathcal{L}_Xf\ \ $ for $ f(x)=x^2\cos y \ \ $ and
# $\ \ X=-y\frac{\partial}{\partial x}+x\frac{\partial}{\partial y},$ using SageMath Manifolds.
# In[2]:
get_ipython().run_line_magic('display', 'latex')
M = Manifold(2, 'M') # manifold M
c_xy. = M.chart() # chart on M
f = M.scalar_field(x^2*cos(y)) # scalar function f on M
X = M.vector_field(name='X') # vector field X on M
X[:] = (-y, x) # components of X
f.lie_derivative(X).expr() # Lie derivative L_X(f)
#
#
# ### Lie derivative of $f$ with respect to $X$ is the value of $\ Xf$
#
#
#
# Since the curve $ϕ_x$ given by $ϕ_x (t) = ϕ(x, t)$ is
# the integral curve of $X$ that starts at $x$ we have
#
# $$\lim_{t\to 0}\frac{\phi_t^*f-f}{t}(x)=
# \lim_{t\to 0}\frac{f(\phi_t(x))-f(x)}{t}
# =\lim_{t\to 0}\frac{f(\phi(x,t))-f(x)}{t}$$
#
# $$=\lim_{t\to 0}\frac{f(\phi_x(t))-f(\phi_x(0))}{t}\\
# =(ϕ_x)'_0 ( f ) = X_x ( f )=(Xf)(x).
# $$
# We have checked that
# \begin{equation}
# \mathcal{L}_Xf=Xf.
# \tag{19.2}
# \end{equation}
#
# Thus **we can compute $\ \ \mathcal{L}_Xf\ \ $ without any knowledge on the integral curves of $X$**.
#
#
#
#
# **Example 19.2**
#
# Check the result of the previous example using (19.2).
#
#
#
# We have
#
# $$\ \ X(f)=(-y\frac{\partial}{\partial x}+x\frac{\partial}{\partial y})(x^2\cos y )\ \
# =-y(2x)\cos y +x(x^2)(-\sin y)\\=-x^3\sin y-2xy\cos y.$$
#
# In[3]:
# continuation
X(f).expr() # value of the vector field X on f
#
#
# **Example 19.3**
#
# Check that SageMath `lie_derivative` method applied to functions coincides with application of (19.2).
# In[4]:
get_ipython().run_line_magic('display', 'latex')
N = 2 # dimension of manifold M
M = Manifold(N, 'M') # manifold M
c_x = M.chart(' '.join(['x'+str(i)+':x^{'+str(i)+'}' for i in range(N)])) # chart on M
x0, x1 = c_x[:] # coordinates x^0, x^1 of chart c_x as the Python variables x0, x1
X = M.vector_field(name='X') # vector field X
Xf=[M.scalar_field(function('X'+str(i), # list of components
latex_name='X'+'^'+str(i))(x0, x1))
for i in range(N)]
X[:] = Xf # define all components of X
X.disp()
# In[5]:
f = M.scalar_field(function('f')(x0, x1)) # scalar function on M
f.disp()
# In[6]:
f.lie_derivative(X).expr() # Lie derivative of f w.r.t. X
#
#
# ### Commutator of Lie derivatives of functions
#
#
#
# From (19.2) it follows
# $$\mathcal{L}_X (\mathcal{L}_Y f ) − \mathcal{L}_Y (\mathcal{L}_X f ) = XY f − YX f = [X, Y] f = \mathcal{L}_{[X,Y]} f,
# $$
# i.e.
# \begin{equation}
# \mathcal{L}_X (\mathcal{L}_Y f ) − \mathcal{L}_Y (\mathcal{L}_X f )=
# \mathcal{L}_{[X,Y]} f.
# \tag{19.3}
# \end{equation}
#
#
# **Example 19.4**
#
# Check in SageMath Manifolds that (19.3) holds for 2-dimensional manifolds.
# In[7]:
# continuation
Y = M.vector_field(name='Y') # vector field Y
Yf = [M.scalar_field(function('Y'+str(i), # list of components
latex_name='Y'+'^'+str(i))(x0, x1))
for i in range(N)]
Y[:] = Yf # define all components
L_XL_Yf = (f.lie_derivative(Y)).lie_derivative(X) # L_X(L_Y(f))
L_YL_Xf = (f.lie_derivative(X)).lie_derivative(Y) # L_Y(L_X(f))
L_bracket_f = f.lie_derivative(X.bracket(Y)) # L_{lie_brack(X,Y)}(f)
L_XL_Yf - L_YL_Xf == L_bracket_f # check (19.3)
#
#
# ### $\psi$-related vector fields
#
#
#
# Let $ψ : M → N$ be a smooth map between two smooth manifolds. If
# $X ∈ \mathfrak{X}(M)$ and $Y ∈ \mathfrak{X}(N ).$
#
# $X$ and $Y$ are $ψ$-**related** if
# \begin{equation}
# Y_{ψ(p)} = dψ_pX_p ,
# \tag{19.4}
# \end{equation}
# for $p ∈ M.$
#
# If $f ∈ C^∞ (N )$, then from (19.4) and (8.8) it follows
#
# $$
# (Y f ) (ψ( p)) = Y_{ψ( p)} ( f ) = dψ_p X_p ( f ) = X_p ( f ◦ ψ)
# = (X( f ◦ ψ) )( p),$$
# for $p ∈ M,$ i.e.,
# \begin{equation}
# (Y f ) ◦ ψ = X( f ◦ ψ),
# \tag{19.5}
# \end{equation}
# for $f ∈ C^∞ (N).$
# An equivalent formulation is
#
# \begin{equation}
# \psi^*(Y f ) = X( \psi^*f),
# \tag{19.6}
# \end{equation}
# for $f ∈ C^∞ (N).$
#
#
# ### Pullback of a vector field and its properties
#
#
#
#
# Let $M$ and $N$ be smooth manifolds, $ψ : M → N$ be a **diffeomorphism** and $X$ be a vector field on $N$. The **pullback of $X$ under** $\psi$ is the vector field on $M$ defined by
#
# \begin{equation}
# (\psi^∗ X)_x = d(ψ^{-1 })_{ψ(x)} X_{ ψ(x)}.
# \tag{19.7}
# \end{equation}
#
#
#
#
# Note that (19.7) implies that
#
# \begin{equation}
# X_{\psi(x)}=d\psi_x(\psi^*X)_x,
# \tag{19.7'}
# \end{equation}
#
# which means that
# $ψ^∗ X$ and $X$ are $ψ$-related. If we replace in
# (19.6) $Y$ by $X$ and $X$ by $\psi^*X$ we obtain
#
# \begin{equation}
# \psi^*(X f ) = (\psi^*X)( \psi^*f),
# \tag{19.8}
# \end{equation}
# for $f ∈ C^∞ (N ).$
#
# We have also
# $$ψ^∗ ( f X) = (ψ^∗ f )(ψ^∗ X),$$
#
# $$ψ^∗ (aX + bY) = aψ^∗X + bψ^∗ Y,$$
#
# for $X, Y ∈ \mathfrak{X}(N ), f ∈ C^∞ (N ),$ and $a, b ∈ R.$
#
# In fact by (19.7)
#
# $$ [ψ^∗( f X)]_x = d(ψ^{−1} )_{ψ(x)} ( f X)_{ψ(x)}
# = d(ψ^{−1} )_{ψ(x)} (f (ψ(x)) X_{ψ(x)})\\
# = f (ψ(x)) d(ψ^{−1} )_{ψ(x)} X_{ψ(x)} = (ψ^∗ f )(x) (ψ^∗ X)_x =
# [(ψ^∗ f )(ψ^∗ X)]_x,
# $$
# and
#
# $$
# [ψ^∗ (aX + bY)]_x = d(ψ^{−1})_{ψ(x)} (aX + bY)_{ψ(x)}
# = d(ψ^{−1} )_{ψ(x)} (aX_{ψ(x)} + bY_{ψ(x)} )
# = ad(ψ^{ −1} )_{ψ(x)} X_{ψ(x)} + bd(ψ^{−1} )_{ψ(x)} Y_{ψ(x)}
# = [aψ^∗ X + bψ^∗ Y]_x.
# $$
#
#
# If $ψ : M → N$ is a **diffeomorphism** of smooth manifolds $M$, $N$ and $χ$ is a one-parameter group of transformations on $N$ whose infinitesimal generator is $Y$,
# then $ϕ_t = ψ^{−1} ◦ χ_t ◦ ψ$ **is a one-parameter group of transformations on $M$ whose
# infinitesimal generator is** $ψ^∗ Y$.
#
# This relation follows from
#
# $$ϕ_s ◦ϕ_t = (ψ^{−1} ◦ χ_s ◦ ψ) ◦ (ψ^{−1} ◦ χ_t ◦ ψ) \\
# = ψ^{−1} ◦ χ_s ◦ χ_t ◦ ψ =
# ψ^{−1} ◦ χ_{s+t} ◦ ψ = ϕ_{s+t} .$$
#
#
#
#
# If $ψ_1 : M_1 → M_2$ and $ψ_2 : M_2 → M_3$ are diffeomorphisms, then $$(ψ_2 ◦ ψ_1 )^∗ X = (ψ_1^∗ ◦ ψ_2^∗ )X,$$ for $X ∈ \mathfrak{X}(M_3 )$.
# The last equality is true, since
#
# $$
# [(ψ_2 ◦ ψ_1 )^∗ X]_x = d((ψ_2 ◦ ψ_1 )^{−1})
# _{ (ψ_2 ◦ψ_1 )(x)}X_{( ψ_2 \circ ψ_1 )(x)}\\
# = (d(ψ_1^{−1})_{ψ_1 (x)}\circ d(ψ_2^{-1})_{\psi_2(\psi_1(x))})
# X_{\psi_2(ψ_1 (x))}\\
# =d(\psi_1^{-1})_{\psi_1(x)}(\psi_2^*X)_{\psi_1(x)}
# = [ψ_1^∗ (ψ_2^∗ X)]_x .
# $$
#
#
#
# ### Lie derivative of a vector field
#
#
#
# If $ϕ$ is a one-parameter group of transformations on a manifold $M$ and $X$ its infinitesimal generator, then for any vector field $Y$ on $M$, the Lie derivative of $Y$ with respect to $X$ is defined by
# \begin{equation}
# (\mathcal{L}_XY)_x=\lim_{t→0}\frac{(\phi^*_tY)_x-Y_x}{t}
# =\frac{d}{dt}(\phi_t^*Y)_x\Big|_{t=0}.
# \tag{9.11}
# \end{equation}
#
#
#
#
# ### Lie derivatives of vector fields are equal to Lie brackets
#
#
#
# If $X, Y ∈ \mathfrak{X}(M)$, then
# \begin{equation}
# \mathcal{L}_XY=[X,Y].
# \tag{19.12}
# \end{equation}
#
# To prove this formula, we will check first a form of Leibniz rule.
# If $ \phi$ is a one-parameter group of transformations on $M$ whose infinitesimal generator is $X$, then
#
# $$\mathcal{L}_X(Yf)
# =\lim_{t→0}\frac{\phi^*_t(Yf)-Yf}{t}
# =\lim_{t→0}\frac{(\phi^*_tY)(\phi_t^*f)-Yf}{t}$$
# $$=\lim_{t→0}\Big[(\phi^*_tY)\frac{\phi^*_tf-f}{t}
# +\frac{\phi^*_tY-Y}{t}f\Big]=Y(\mathcal{L}_Xf)+(\mathcal{L}_XY)f.
# $$
#
# Notice that $(\phi^*_tY)_x=d(\phi_t^{-1})_{\phi_t(x)}Y_{\phi_t(x)}=
# d(\phi_{-t})_{\phi_t(x)}Y_{\phi_t(x)}$. We have also
# $\phi_t(x)\to x, \ \phi_{-t}(x)\to x$ as $t\to 0$ and in local coordinates the components of the matrix of the differential
# $d(ϕ_{−t} )_{\phi_t(x)} : T_{ϕ_t(x)} M → T_x M$
# are $\displaystyle \frac{∂ϕ^i(−t, ϕ(t, x))}{∂x^j}.$
# Smoothness of $X$ implies smoothness of $\phi$, which implies that
#
# $$\displaystyle \frac{∂ϕ^i(−t, ϕ(t, x))}{∂x^j}\to \frac{\partial\phi^i(0,x)}{\partial x^j}=\frac{\partial x^i}{\partial x^j}=\delta^i_j\quad\text {as}\ t\to 0.$$
# Consequently, if $Y = Y^j \frac{\partial}{∂ x^j}$, then
# $$d(ϕ_{−t} )_{\phi_t(x)}Y_{ϕ_t (x)} =
# \frac{∂ϕ^i (−t, ϕ(t, x))}{ ∂ x^j}Y^j(ϕ(t, x))\frac{∂}{∂x^i}\Big|_{x}\to Y_x\quad \mbox{as } t\to 0.
# $$
#
# Since by (19.2) $\mathcal{L}_Xf=Xf,\ $ we have
#
# $$X(Yf)=\mathcal{L}_X(Yf)=Y(Xf)+(\mathcal{L}_XY)f,$$
# so
# $$\mathcal{L}_X(Yf)= X(Yf)-Y(Xf)=[X,Y]f,$$
# i.e., (19.12) holds true.
#
# Thus **we can compute $\ \ \mathcal{L}_XY\ \ $ without any knowledge on the integral curves of $X$**.
#
#
#
#
# **Example 19.5**
#
# Compute $\ \ \mathcal{L}_XY\ \ $ for $\ \ X=-y\frac{\partial}{\partial x}+x\frac{\partial}{\partial y}\ \ $
# and
# $\ \ Y=(1-x)\frac{\partial}{\partial x}+(x-y)\frac{\partial}{\partial y}.$
# In[8]:
get_ipython().run_line_magic('display', 'latex')
M = Manifold(2, 'M') # manifold M
c_xy. = M.chart() # chart on M
X = M.vector_field(-y, x, name='X') # vector field X
Y = M.vector_field(1-x, x-y, name='Y') # vector field Y
# First we use the `lie_derivative` method:
# In[9]:
Y_X = Y.lie_derivative(X) # Lie derivative L_X(Y)
Y_X.disp()
# and next the Lie bracket for comparison:
# In[10]:
X.bracket(Y).disp() # [X,Y]
#
#
# **Example 19.6**
#
# Use SageMath to check that (19.12) holds for 2-dimensional manifolds.
# In[11]:
get_ipython().run_line_magic('display', 'latex')
N = 2 # dimension of manifold M
M = Manifold(N, 'M') # manifold M
c_x = M.chart(' '.join(['x'+str(i)+':x^{'+str(i)+'}' for i in range(N)])) # chart on M
x0, x1 = c_x[:] # coordinates x^0, x^1 of chart c_x as the Python variables x0, x1
X = M.vector_field(name='X') # vector field X
Xf = [M.scalar_field(function('X'+str(i), # list of components
latex_name='X'+'^'+str(i))(x0,x1))
for i in range(N)]
X[:] = Xf # define all components of X
Y = M.vector_field(name='Y') # vector field Y
Yf = [M.scalar_field(function('Y'+str(i), # list of components
latex_name='Y'+'^'+str(i))(x0,x1))
for i in range(N)]
Y[:] = Yf # define all components of Y
Y.lie_derivative(X) == X.bracket(Y) # check (19.12)
#
#
# ### Basic properties of Lie derivative of vector fields
#
#
# Using properties of the Lie bracket from [notebook 12](https://nbviewer.org/github/sagemanifolds/IntroToManifolds/blob/main/12Manifold_VectorFields_cont.ipynb), one can check that if $X, Y ∈ \mathfrak{X}(M)$ and $f ∈ C^∞ (M),$ then
#
# $$\mathcal{L}_X(fY)=[X, f Y] = f [X, Y] + (X f )Y = f \mathcal{L}_X Y + (\mathcal{L}_X f )Y,$$
# and
# $$\mathcal{L}_X (Y + Z) = [X, Y + Z] = [X, Y] + [X, Z] = \mathcal{L}_X Y + \mathcal{L}_X Z.$$
#
# If $X, Y, Z \in \mathfrak{X}(M)$, then using Jacobi identity ([notebook 12](https://nbviewer.org/github/sagemanifolds/IntroToManifolds/blob/main/12Manifold_VectorFields_cont.ipynb)) we obtain
#
# $$\mathcal{L}_X (\mathcal{L}_Y Z) − \mathcal{L}_Y (\mathcal{L}_X Z) = [X, [Y, Z]] − [Y, [X, Z]] =
# [X, [Y, Z]] + [Y, [Z, X]]\\
# = −[Z, [X, Y]]= [[X, Y], Z] =\mathcal{L}_{[X,Y]} Z.$$
#
#
#
# **Example 19.7**
#
# For $\ X,Y$ from example 19.5 and
# $\ Z=y\frac{\partial}{\partial x}+x\frac{\partial}{\partial y}\ \ $ compute
# $\mathcal{L}_X (\mathcal{L}_Y Z) − \mathcal{L}_Y (\mathcal{L}_X Z)\ \ $ and $ \mathcal{L}_{[X,Y]} Z.$
# In[12]:
get_ipython().run_line_magic('display', 'latex')
M = Manifold(2, 'M') # manifold M
c_xy. = M.chart() # chart on M
X = M.vector_field(-y, x, name='X') # vector field X
Y = M.vector_field(1-x, x-y, name='Y') # vector field Y
Z = M.vector_field(y, x, name='Z') # vector field Z
Z_YX = (Z.lie_derivative(Y)).lie_derivative(X) # L_X(L_Y(Z))
Z_XY = (Z.lie_derivative(X)).lie_derivative(Y) # L_Y(L_X(Z))
(Z_YX - Z_XY).disp() # L_X(L_Y(Z)) - L_Y(L_X(Z))
# In[13]:
Z_brXY = Z.lie_derivative(X.bracket(Y)) # L_[X,Y](Z)
Z_brXY.disp()
#
#
# ### Some properties of pullback of covariant tensor fields
#
#
#
# Let us recall (from [notebook 15](https://nbviewer.org/github/sagemanifolds/IntroToManifolds/blob/main/15Manifold_Pullback.ipynb)) that if $M$ and $N$ are smooth manifolds and $ψ : M → N$ is a smooth map then the pullback $\ \psi^*t\ $of a smooth tensor field $t\in T^{(0,k)}N$ is defined by
#
# \begin{equation}
# (ψ^∗ t)_p (X_{1p} , . . . , X_{kp} ) = t_{ψ( p)} (dψ_p X_{1p} , . . . , dψ_p X_{kp} ),
# \tag{19.13}
# \end{equation}
#
# for $X_{1p},\ldots,X_{kp}\in T_pM$ and $p\in M$.
#
#
# In (15.2) we have proved that for $f ∈ C^∞ (N )$
# \begin{equation}
# ψ^∗ d f=d(\psi^*f),
# \tag{9.14}
# \end{equation}
#
# and in (15.3)-(15.5) we justified the relations (for covariant tensor fields $t,s$ and $f\in C^\infty(M),\ a,b\in R$)
#
#
# \begin{equation}
# \begin{matrix}
# ψ^∗ (at + bs) = aψ^∗ t + bψ^∗ s,\\
# ψ^∗ ( f t) = (ψ^* f )(ψ^* t),
# \end{matrix}
# \tag{19.15}
# \end{equation}
#
# \begin{equation}
# ψ^∗ (t ⊗ s) = (ψ^∗ t) ⊗ (ψ^∗ s).
# \tag{19.16}
# \end{equation}
# In [notebook 15](https://nbviewer.org/github/sagemanifolds/IntroToManifolds/blob/main/15Manifold_Pullback.ipynb) we also have checked that if $M_1,M_2,M_3\ $ are smooth manifolds and $ψ_1 : M_1 → M_2$ and $ψ_2 : M_2 → M_3$ are smooth maps, then
# \begin{equation}
# (ψ_2 ◦ ψ_1 )^∗ t = (ψ_1^∗ ◦ ψ_2^∗ )\,t.
# \tag{19.17}
# \end{equation}
#
#
#
# ### Lie derivative of covariant tensor fields
#
#
#
# If $ϕ$ is a one-parameter group of transformations on $M$ and $X$ its infinitesimal generator, then for any tensor field $t\in T^{(0,k)}M$ the Lie derivative of $t$ with respect to $X$ is defined by
# \begin{equation}
# (\mathcal{L}_Xt)_x=\lim_{h→0}\frac{(\phi^*_ht)_x-t_x}{h}
# =\frac{d}{dt}(\phi_t^*t)_x\Big|_{t=0}.
# \tag{9.18}
# \end{equation}
#
#
#
# For $t\in T^{(0,k)}M,\ s\in T^{(0,m)}M$ we have
#
# \begin{equation}
# \begin{matrix}
# \displaystyle
# \mathcal{L}_X(t\otimes s)
# =\lim_{h→0}\frac{\phi^*_h(t\otimes s)-t\otimes s}{h}
# =\lim_{h→0}\frac{(\phi^*_ht)\otimes (\phi_h^*s)-t\otimes s}{h}\\
# \displaystyle
# =\lim_{h→0}\Big[(\phi^*_ht)\otimes\frac{\phi^*_hs-s}{h}
# +\frac{\phi^*_ht-t}{h}\otimes s\Big]\\
# \displaystyle
# =t\otimes(\mathcal{L}_X s)+(\mathcal{L}_Xt)\otimes s.
# \end{matrix}
# \tag{19.19}
# \end{equation}
# For $t,s\in T^{(0,k)}M$ and $a,b\in R$
# \begin{equation}
# \begin{matrix}
# \displaystyle
# \mathcal{L}_X(at+bs)
# =\lim_{h→0}\frac{\phi^*_h(at+bs)-(at+bs)}{h}\\
# \displaystyle
# =\lim_{h→0}\frac{a\phi^*_ht+b\phi^*_hs-at-bs}{h}
# =a\mathcal{L}_Xt +b\mathcal{L}_Xs.
# \end{matrix}
# \tag{19.20}
# \end{equation}
# For $f ∈ C^∞ (M)$ and $t\in T^{(0,k)}M$
#
# \begin{equation}
# \begin{matrix}
# \displaystyle
# \mathcal{L}_X(ft)
# =\lim_{h→0}\frac{\phi^*_h(ft)-ft}{h}
# =\lim_{h→0}\frac{(\phi^*_hf)(\phi_h^*t)-ft}{h}\\
# \displaystyle
# =\lim_{h→0}\Big[\phi^*_hf\frac{\phi^*_ht-t}{h}
# +\frac{\phi^*_hf-f}{h}t\Big]
# =f(\mathcal{L}_X t)+(\mathcal{L}_Xf)t.
# \end{matrix}
# \tag{19.21}
# \end{equation}
# \begin{equation}
# \begin{matrix}
# \displaystyle
# \mathcal{L}_Xdf
# =\lim_{h→0}\frac{\phi^*_hdf-df}{h}
# =\lim_{h→0}\frac{d(\phi^*_hf)-df}{h}
# =d(\mathcal{L}_Xf).
# \end{matrix}
# \tag{19.22}
# \end{equation}
#
#
# ### Lie derivative of covariant tensor fields in local components
#
#
#
# If $t\in T^{(0,k)}M$ is given locally by $t = t_{i_1... i_k} dx^{i_1} ⊗· · · ⊗ dx^{i_k}$, then
#
# $$
# \mathcal{L}_X t =
# \mathcal{L}_X (t_{i_1... i_k} dx^{i_1} ⊗ · · · ⊗ dx^{i_k} )\\
# = (\mathcal{L}_X t_{i_1... i_k})dx^{i_1} ⊗ · · · ⊗ dx^{i_k} \\
# + t_{i_1... i_k}\big( \mathcal{L}_X dx^{i_1} ⊗ · · · ⊗ dx^{i_k} + · · · +
# dx^{i_1} ⊗ · · · ⊗ \mathcal{L}_Xdx^{i_k}\big)\\
# =(Xt_{i_1... i_k})dx^{i_1} ⊗ · · · ⊗ dx^{i_k}\\
# + t_{i_1... i_k}\big[d (\mathcal{L}_X x^{i_1}) ⊗ · · · ⊗ dx^{i_k} + · · · +
# dx^{i_1} ⊗ · · · ⊗ d(\mathcal{L}_Xx^{i_k})\big].\\
# $$
# If $X = X^m \frac{∂}{∂ x^m}$, then
#
# $$
# \mathcal{L}_Xx^i=Xx^i=\big(X^m \frac{∂}{∂ x^m}\big)x^i=X^i,
# $$
#
# consequently
#
# \begin{equation}
# d(\mathcal{L}_Xx^i)=dX^i=\frac{∂X^i}{∂ x^m}dx^m,
# \tag{19.22'}
# \end{equation}
#
# and
# \begin{eqnarray*}
# &\mathcal{L}_X t = (Xt_{i_1... i_k} ) dx^{i_1} ⊗ · · · ⊗ dx^{i_k}\\
# &+t_{i_1... i_k} \big(\frac{∂X^{i_1}}{∂ x^m}dx^m\otimes\ldots\otimes dx^{i_k}+\ldots+dx^{i_1}\otimes\ldots\otimes\frac{∂X^{i_k}}{∂ x^m}dx^m\Big)\\
# &=\big(X^m\frac{\partial t_{i_1... i_k}}{∂ x^m}+
# t_{i_m... i_k}\frac{∂X^{i_m}}{∂ x^{i_1}}+\ldots
# +t_{i_1... i_m}\frac{∂X^{i_m}}{∂ x^{i_k}}\Big)dx^{i_1} ⊗ · · · ⊗ dx^{i_k}.
# \tag{19.23}
# \end{eqnarray*}
#
#
#
# **Example 19.8**
#
# Compute $\ \mathcal{L}_Xt\ \ $ for $\ X=(1-x)\frac{\partial}{\partial x}+(x-y)\frac{\partial}{\partial y}\ \ $ and $\ \ t=xdx⊗dx+dx⊗d𝑦+𝑦d𝑦⊗dx.$
#
#
#
# First define the tensor field and vector field:
# In[14]:
get_ipython().run_line_magic('display', 'latex')
M = Manifold(2, 'M') # manifold M
c_xy. = M.chart() # chart on M
e_xy = c_xy.frame() # local basis of vector fields
t = M.tensor_field(0, 2, {e_xy: [[x, 1], [y, 0]]}, name='t')
t.disp() # tensor field t of (0,2)-type
# In[15]:
e_xy # show the local basis
# In[16]:
X = M.vector_field({e_xy: [1-x, x-y]}, name='X')
X.disp() # vector field X
# Now we can compute $\ \mathcal{L}_Xt:\ \ $
# In[17]:
lt = t.lie_derivative(X) # Lie derivative L_X(t)
lt.display(e_xy)
#
#
# **Example 19.9**
#
# For a deeper understanding of the formula (19.23) let us take a more general example.
#
# Let $\ \ t=𝑡_{00}d𝑥^0⊗d𝑥^0+𝑡_{01}d𝑥^0⊗d𝑥^1+𝑡_{10}d𝑥^1⊗d𝑥^0+𝑡_{11}d𝑥^1⊗d𝑥^1.\ \ $
# In[18]:
N=2 # dimension of manifold M
M = Manifold(N, 'M') # manifold M
c_x = M.chart(' '.join(['x'+str(i)+':x^{'+str(i)+'}' for i in range(N)])) # chart on M
x0, x1 = c_x[:] # coordinates x^0, x^1 of chart c_x as the Python variables x0, x1
t = M.tensor_field(0,2, name='t') # tensor field t of type (0,2)
def f2(i,j): return 't'+str(i)+str(j) # names of components
# component functions:
f1 = [[M.scalar_field(function(f2(j,k))(x0,x1), name=f2(j,k))
for k in range(N)] for j in range(N)]
t[:] = f1 # define all components of t
get_ipython().run_line_magic('display', 'latex')
Manifold.options.omit_function_arguments=True
t.disp() # show tensor field t
# and $\ \ X=X^0\frac{\partial}{\partial x^0}+X^1\frac{\partial}{\partial x^1}$
# In[19]:
# continuation
X = M.vector_field(name='X') # vector field X
Xf=[M.scalar_field(function('X'+str(i), # list of components
latex_name='X'+'^'+str(i))(x0,x1))
for i in range(N)]
X[:] = Xf # define all comp. of X
X.disp() # show vect.field X
# Compute the Lie derivative$\ \mathcal{L}_Xt:\ \ $
# In[20]:
lt = t.lie_derivative(X)
lt.disp()
# For comparison, using (19.23) without simplifications we obtain
#
# $$
# \begin{matrix}
# \Big(X^m\frac{\partial t_{i_1... i_k}}{∂ x^m} &
# +t_{i_m... i_k}\frac{∂X^{i_m}}{∂ x^{i_1}}+ &
# ...+t_{i_1... i_m}\frac{∂X^{i_m}}{∂ x^{i_k}}\Big) &
# dx^{i_1} ⊗ · · · ⊗ dx^{i_k}\\
# =\Big(X^0\frac{\partial t_{00}}{\partial x^0}+X^1 \frac{\partial t_{00}}{\partial x^1} &
# +t_{00}\frac{\partial X^0}{\partial x^0}+t_{10}\frac{\partial X^1}{\partial x^0} &
# +t_{00}\frac{\partial X^0}{\partial x^0}+t_{01}\frac{\partial X^1}{\partial x^0} \Big)&
# dx^0\otimes dx^0\\
# +\Big(X^0\frac{\partial t_{01}}{\partial x^0}+X^1 \frac{\partial t_{01}}{\partial x^1} &
# +t_{01}\frac{\partial X^0}{\partial x^0}+t_{11}\frac{\partial X^1}{\partial x^0} &
# +t_{00}\frac{\partial X^0}{\partial x^1}+t_{01}\frac{\partial X^1}{\partial x^1} \Big)&
# dx^0\otimes dx^1\\
# +\Big(X^0\frac{\partial t_{10}}{\partial x^0}+X^1 \frac{\partial t_{10}}{\partial x^1} &
# +t_{00}\frac{\partial X^0}{\partial x^1}+t_{10}\frac{\partial X^1}{\partial x^1} &
# +t_{10}\frac{\partial X^0}{\partial x^0}+t_{11}\frac{\partial X^1}{\partial x^0} \Big)&
# dx^1\otimes dx^0\\
# +\Big(X^0\frac{\partial t_{11}}{\partial x^0}+X^1 \frac{\partial t_{11}}{\partial x^1} &
# +t_{01}\frac{\partial X^0}{\partial x^1}+t_{11}\frac{\partial X^1}{\partial x^1} &
# +t_{10}\frac{\partial X^0}{\partial x^1}+t_{11}\frac{\partial X^1}{\partial x^1} \Big)&
# dx^1\otimes dx^1,
# \end{matrix}
# $$
#
# which of course gives the same result.
# In[21]:
# 3 ways how to obtain contraction sign
print(u'\u231F',u'\u300D',u'\uFF63')
#
#
# ### Contraction with a vector field (interior product)
#
#
#
# If $t\in T^{(0,k)}M,\ X\in \mathfrak{X}(M)$, then the **contraction**
# of $t$ with $X$, denoted by $\ X\mathbin{」}t\ $ is a tensor field from
# $T^{(0,k-1)}M$ defined by
#
# \begin{equation}
# (X\mathbin{」}t)_p(X_{2p},\ldots,X_{kp})=t_p(X_p,X_{2p},\ldots,X_{kp}).
# \tag{19.24}
# \end{equation}
#
#
#
#
# **Example 19.10**
#
# Let us compute $\ \ X\mathbin{」}t\ \ $ for $\ \ X=X^1\frac{\partial}{\partial x^1}+
# X^2\frac{\partial}{\partial x^2}\ \ $ and $\ \ 𝑔=d𝑥^1⊗d𝑥^1+d𝑥^2⊗d𝑥^2.$
#
# In[22]:
get_ipython().run_line_magic('display', 'latex')
N = 2 # dimension of manifold M
M = Manifold(2, 'M',start_index=1) # manifold M
c_x = M.chart(' '.join(['x'+str(i)+':x^{'+str(i)+'}' for i in range(1, N+1)])) # chart on M
x1, x2 = c_x[:] # coordinates x^1, x^2 of chart c_x as the Python variables x1, x2
g = M.tensor_field(0, 2, name='g'); # tensor field of type (0,2)
g[1,1] = 1; g[2,2] = 1 # set nonzero components
g.display() # show g
# In[23]:
X = M.vector_field() # vector field X
X[:] = (function('X1', latex_name='X^1')(x1,x2), # define components of X
function('X2', latex_name='X^2')(x1,x2))
Manifold.options.omit_function_arguments=True
X.display() # show X
# In[24]:
X.contract(g).display() # X 」g
#
#
# **Example 19.11**
#
# Compute $\ \ X\mathbin{」} a\ \ $ for $\ \ X=X^1\frac{\partial}{\partial x^1}+
# X^2\frac{\partial}{\partial x^2}\ \ $ and $\ \ a= 𝑎_1d𝑥^1+𝑎_2d𝑥^2.$
# In[25]:
# continuation
a = M.one_form() # one-form a
# define components of a
a[:] = (function('a1')(x1,x2), function('a2')(x1,x2))
a.disp() # show a
# In[26]:
(X.contract(a)).disp() # X 」 a
# In[27]:
X.interior_product(a).disp() # interior product
# gives the same results for k-forms
# In[28]:
a(X).disp() # value of a on X
# In[29]:
X(a).disp() # value of X on a
#
#
# **Example 19.12**
#
# Compute $\ \ X\mathbin{」}t\ \ $ for $\ \ X=X^0\frac{\partial}{\partial x^0}+
# X^1\frac{\partial}{\partial x^1}\ \ $ and $\ \ 𝑡=𝑡_{00}d𝑥^0⊗d𝑥^0+𝑡_{01}d𝑥^0⊗d𝑥^1+𝑡_{10}d𝑥^1⊗d𝑥^0+𝑡_{11}d𝑥^1⊗d𝑥^1.$
# In[30]:
N = 2 # dimension of manifold M
M = Manifold(N, 'M') # manifold M
c_x = M.chart(' '.join(['x'+str(i)+':x^{'+str(i)+'}' for i in range(N)])) # chart on M
x0, x1 = c_x[:] # coordinates x^0, x^1 of chart c_x as the Python variables x0, x1
t = M.tensor_field(0,2, name='t') # tensor field t of type (0,2)
def f2(i,j): return 't'+str(i)+str(j) # names of components
# list of components:
f = [[M.scalar_field(function(f2(j,k))(x0,x1), name=f2(j,k))
for k in range(2)] for j in range(2)]
t[:] = f # all components of t
get_ipython().run_line_magic('display', 'latex')
Manifold.options.omit_function_arguments=True
t.disp() # show t
# In[31]:
X = M.vector_field() # vector field X
X[:] = (function('X0',latex_name='X^0')(x0,x1), # list of comp.
function('X1',latex_name='X^1')(x0,x1))
# In[32]:
X.contract(t).display() # X 」 t
#
#
# ### Pullback of contraction
#
#
# Let $ψ:M → N$ be a diffeomorphisms, $\ t\in T^{(0,k)}N\ $ and $\ X\in \mathfrak{X}(N)$. Recall that since $ψ^∗ X$ and $X$ are $ψ$-related, then $X_{\psi(p)}=d\psi_p(\psi^*X)_p\ $ (cf. (19.7')) and
# $(ψ^∗ X)(ψ^∗ f ) = ψ^∗ (X f )\ $ (cf. (19.8)), therefore
#
# $$[(ψ^∗ X)\mathbin{」}(ψ^∗ t)]_p (X_{2p} , . . . , X_{kp} )
# =(ψ^∗ t)_p ((ψ^∗ X)_p , X_{2p} , . . . , X_{kp})\\
# = t_{ψ( p)} (dψ_p (ψ^∗ X)_p , dψ_p X_{2p} , . . . , dψ_p X_{kp})\\
# = t_{ψ( p)} (X_{ψ( p)} ,dψ_p X_{2p} , . . . , dψ_p X_{kp} )\\
# =(X\mathbin{」} t)_{ψ( p)} (dψ_p X_{2p} , . . . , dψ_p X_{kp} )
# = [ψ^∗ (X\mathbin{」} t)]_p (X_{2p} , . . . , X_{kp} ),
# $$
#
# for $X_{2p},\ldots,X_{kp}\in T_pN.$ We have proved
#
# \begin{equation}
# ψ^∗ (X\mathbin{」} t)=(ψ^∗ X)\mathbin{」}(ψ^∗ t).
# \tag{19.25}
# \end{equation}
#
#
# ### Lie derivative of contraction
#
#
#
# In a consequence, if $\phi_t$ is a one-parameter group of transformations on 𝑀, $X$ its infinitesimal generator and $Y\in\mathfrak{X}(M)$, then for $t\in T^{(0,k)}M$
# $$\mathcal{L}_X (Y\mathbin{」}t)=
# \lim_{h\to 0}\frac{\phi_h^*(Y\mathbin{」}t)-Y\mathbin{」}t}{h}
# =\lim_{h\to 0}\frac{\phi_h^*(Y)\mathbin{」}(\phi^*_ht)-Y\mathbin{」}t}{h}\\
# =\lim_{h\to 0}\frac{\phi_h^*(Y)\mathbin{」}(\phi^*_ht)-
# \phi_h^*(Y)\mathbin{」}t+\phi_h^*(Y)\mathbin{」}t-Y\mathbin{」}t}{h}\\
# =\lim_{h\to 0}\Big[\phi_h^*Y\mathbin{」}\frac{\phi_h^*t-t}{h}+
# \frac{\phi_h^*Y-Y}{h}\mathbin{」}t\Big].
# $$
#
# Thus
# \begin{equation}
# \mathcal{L}_X (Y\mathbin{」}t)=(\mathcal{L}_XY)\mathbin{」}t
# +Y\mathbin{」}\mathcal{L}_Xt.
# \tag{19.26}
# \end{equation}
#
#
# **Example 19.13**
#
# Compute both sides of (19.26) for
# $\ X=-y\frac{\partial}{\partial x}+x\frac{\partial}{\partial y},$
# $\ \ Y=(1-x)\frac{\partial}{\partial x}+(x-y)\frac{\partial}{\partial y}\ \ $ and $g=ydx⊗dx+xd𝑦⊗dy.$
#
# First we define $g,\ X,\ Y$:
#
# In[33]:
get_ipython().run_line_magic('display', 'latex')
M = Manifold(2, 'M') # manifold M
c_xy. = M.chart() # chart on M
g = M.tensor_field(0,2, name='g'); # tensor field of type (0,2)
g[0,0] = y; g[1,1] = x # set nonzero components
X = M.vector_field(-y, x, name='X') # vector field X
Y = M.vector_field(1-x, x-y, name='Y') # vector field Y
# Left hand side of (19.26) in SageMath:
# In[34]:
(Y.contract(g)).lie_derivative(X).disp()
# Right hand side of (19.26):
# In[35]:
r1 = (Y.lie_derivative(X)).contract(g)
r2 = Y.contract(g.lie_derivative(X))
(r1 + r2).disp()
#
#
# ### Computing the Lie derivative of covariant tensor fields with the help of Lie brackets
#
#
#
#
# From (19.24) it follows
# \begin{equation}
# t_p(X_p,X_{2p},\ldots,X_{kp})=(X\mathbin{」}t)_p(X_{2p},\ldots,X_{kp}),\quad \text{for}\ t\in T^{(0,k)}M,
# \end{equation}
#
# and $X_i\in\mathfrak{X}(M)$.
#
# As a consequence we obtain
#
# $$
# t_p(Y_{1p},Y_{2p},\ldots,Y_{kp})=(Y_{1p}\mathbin{」}t)_p(Y_{2p},\ldots,Y_{kp})\\
# =(Y_{2p}\mathbin{」}(Y_{1p}\mathbin{」}t))_p(Y_{3p},\ldots,Y_{kp})=\ldots\\
# =(Y_{kp}\mathbin{」}Y_{(k-1)p}\mathbin{」}\ldots\mathbin{」}Y_{1p}\mathbin{」}t),
# $$
#
# i.e., for $\ t\in T^{(0,k)}M$ and $Y_i\in\mathfrak{X}(M)$
#
# \begin{equation}
# t(Y_1,Y_2,\ldots,Y_k)=Y_k\mathbin{」}Y_{k-1}\mathbin{」}\ldots\mathbin{」}Y_1\mathbin{」}t.
# \tag{19.27}
# \end{equation}
# We know from (19.2) that
# $Xf=\mathcal{L}_Xf$, so
#
# $$X( t (Y_1 , . . . , Y_k ))
# = \mathcal{L}_X (t (Y_1 , . . . , Y_k ))=
# \mathcal{L}_X(Y_k\mathbin{」}Y_{k-1}\mathbin{」}\ldots\mathbin{」}Y_1\mathbin{」}t)\\
# =[(\mathcal{L}_XY_k)\mathbin{」}Y_{k-1}\mathbin{」}\ldots\mathbin{」}Y_1\mathbin{」}t\\
# +Y_k\mathbin{」}(\mathcal{L}_XY_{k-1})\mathbin{」}\ldots\mathbin{」}Y_1\mathbin{」}t\\
# ............................\\
# +Y_k\mathbin{」}Y_{k-1}\mathbin{」}\ldots\mathbin{」}(\mathcal{L}_XY_1)\mathbin{」}t\\
# +Y_k\mathbin{」}Y_{k-1}\mathbin{」}\ldots\mathbin{」}Y_1\mathbin{」}(\mathcal{L}_Xt)]
# $$
#
# According to (19.27) we have
#
# $$ t(Y_1,\ldots,Y_{k-1},\mathcal{L}_XY_k)=
# (\mathcal{L}_XY_k)\mathbin{」}Y_{k-1}\mathbin{」}\ldots\mathbin{」}Y_1\mathbin{」}t,\\
# t(Y_1,\ldots,\mathcal{L}_XY_{k-1},Y_k)=
# Y_k\mathbin{」}(\mathcal{L}_XY_{k-1})\mathbin{」}\ldots\mathbin{」}Y_1\mathbin{」}t,\\
# ......................................\\
# t(\mathcal{L}_XY_1,\ldots,Y_{k-1},Y_k)=
# Y_k\mathbin{」}Y_{k-1}\mathbin{」}\ldots\mathbin{」}(\mathcal{L}_XY_1)\mathbin{」}t,\\
# (\mathcal{L}_Xt)(Y_1,\ldots,Y_{k-1},Y_k)=
# Y_k\mathbin{」}Y_{k-1}\mathbin{」}\ldots\mathbin{」}Y_1\mathbin{」}(\mathcal{L}_Xt).
# $$
#
# Therefore
#
# $$X( t (Y_1 , . . . , Y_k ))
# =t (Y_1 , Y_2 , . . . , \mathcal{L}_X Y_k ) + t (Y_1 , Y_2 , . . . , \mathcal{L}_X Y_{k−1} , Y_k ) + · · ·\\
# + t (\mathcal{L}_X Y_1 , Y_2 , . . . , Y_k ) + (\mathcal{L}_X t)(Y_1 , . . . , Y_k )\\
# = (\mathcal{L}_X t)(Y_1 , . . . , Y_k )+
# \sum_{i=1}^k t (Y_1 , . . . , \mathcal{L}_X Y_i , . . . , Y_k).
# $$
# We have proved
#
# \begin{equation}
# (\mathcal{L}_X t)(Y_1 ,.., Y_k ) = X (t (Y_1 ,.., Y_k ))
# -\sum_{i=1}^kt (Y_1 ,.., [X, Y_i ],.., Y_k ).
# \tag{19.28}
# \end{equation}
#
#
# **Example 19.14**
#
# Compute both sides of (19.28) for
# $\ X=-y\frac{\partial}{\partial x}+x\frac{\partial}{\partial y},$
# $\ \ Y_1=(1-x)\frac{\partial}{\partial x}+(x-y)\frac{\partial}{\partial y},\ \ Y_2=(y+1)\frac{\partial}{\partial x}+(x-2)\frac{\partial}{\partial y},\ $ and $t=ydx⊗dx+xd𝑦⊗dy.$
#
#
#
# First we define $\ t,\ X,\ Y_1,Y_2$:
# In[36]:
get_ipython().run_line_magic('display', 'latex')
M = Manifold(2, 'M') # manifold M
c_xy. = M.chart() # chart on M
t = M.tensor_field(0,2, name='t') # tensor field of type (0,2)
t[0,0] = y; t[1,1] = x # set nonzero components
X = M.vector_field(-y, x, name='X') # vector field X
Y1 = M.vector_field(1-x, x-y, name='Y1') # vector field Y1
Y2 = M.vector_field(y+1, x-2, name='Y2') # vector field Y2
# In[37]:
L = t.lie_derivative(X)(Y1,Y2) # left hand side of (19.28)
L.expr() # value of L
# In[38]:
R = X(t(Y1,Y2)) - t(X.bracket(Y1),Y2) - t(Y1,X.bracket(Y2))
R # right hand side of (19.28)
# In[39]:
R.expr() # value of R
#
#
# ### Commutator of Lie derivatives of covariant tensor fields
#
#
#
# Repeating the use of (19.28) we obtain
#
# $$(\mathcal{L}_X (\mathcal{L}_Y t)) (Z_1 , . . . , Z_k )\\
# =X ((\mathcal{L}_Y t)(Z_1 , . . . , Z_k ))-\sum_{i=1}^k (\mathcal{L}_Y t)(Z_1 , . . . , [X, Z_i ], . . . , Z_k )\\
# = X \Big\{Y (t (Z_1 , . . . , Z_k )) -\sum_{i=1}^k t (Z_1 , . . . , [Y, Z_j ], . . . , Z_k )\
# \Big\}\\
# -\sum_{i=1}^k
# \Big\{Y (t (Z_1 , . . . , [X, Z_i ], . . . , Z_k )
# − t (Z_1 , . . . , [Y, [X, Z_i ]], . . . , Z_k )\\
# -\sum_{j=1,ji}^kt (Z_1 , . . . , [X, Z_i ], . . . , [Y, Z_j ], . . . , Z_k )
# \Big\}\\
# = XY( t (Z_1 , . . . , Z_k ))-\sum_{j=1}^k
# X (t (Z_1 , . . . , [Y, Z_j ], . . . , Z_k ))\\
# -\sum_{i=1}^k
# \Big\{Y (t (Z_1 , . . . , [X, Z_i ], . . . , Z_k ) )
# − t (Z_1 , . . . , [Y, [X, Z_i ]], . . . , Z_k )\\
# -\sum_{j=1,ji}^k
# t (Z_1 , . . . , [X, Z_i ], . . . , [Y, Z_j ], . . . , Z_k )
# \Big\},
# $$
#
# and analogously
#
# $$
# (\mathcal{L}_Y (\mathcal{L}_X t)) (Z_1 , . . . , Z_k )\\
# =YX( t (Z_1 , . . . , Z_k ))
# -\sum_{i=1}^kY (t (Z_1 , . . . , [Y, Z_i ], . . . , Z_k ))\\
# -\sum_{i=1}^k
# \Big\{X (t (Z_1 , . . . , [Y, Z_i ], . . . , Z_k ) )
# − t (Z_1 , . . . , [X, [Y, Z_i ]], . . . , Z_k )\\
# -\sum_{j=1,ji}^k
# t (Z_1 , . . . , [Y, Z_i ], . . . , [X, Z_j ], . . . , Z_k )
# \Big\}.
# $$
#
# The Jacobi identity
# $\ \ -[Y,[Z_i,X]]-[X,[Y,Z_i]]-[Z_i,[X,Y]]=0,\ $
# implies
#
# $$[Y,[X,Z_i]]-[X,[Y,Z_i]]=-[[X,Y],Z_i],$$
#
# so
#
# $$
# (\mathcal{L}_X (\mathcal{L}_Y t) )(Z_1 , . . . , Z_k ) − \mathcal{L}_Y (\mathcal{L}_X t) )(Z_1 , . . . , Z_k )\\
# = [X, Y] (t (Z_1 , . . . , Z_k ))
# -\sum_{i=1}^k t (Z_1 , . . . , [[X, Y], Z_i ], . . . , Z_k ).
# $$
# Thus
# \begin{equation}
# \mathcal{L}_X (\mathcal{L}_Y t) − \mathcal{L}_Y (\mathcal{L}_X t) = \mathcal{L}_{[X,Y]} t.
# \tag{19.29}
# \end{equation}
#
# Using the fact that $\mathcal{L}_X X = [X, X] = 0$, we obtain:
#
# $$\mathcal{L}_X (X \mathbin{」}t) = (\mathcal{L}_X X)\mathbin{」} t + X\mathbin{」} (\mathcal{L}_X t) = X\mathbin{」} (\mathcal{L}_X t).$$
#
#
# **Example 19.15**
#
# Check (19.29) for a 2-dimensional manifold and tensor $t$ of type (0,2).
# In[40]:
get_ipython().run_line_magic('display', 'latex')
N = 2 # dimension of manifold M
M = Manifold(N, 'M') # manifold M
c_x = M.chart(' '.join(['x'+str(i)+':x^{'+str(i)+'}' for i in range(N)])) # chart on M
x0, x1 = c_x[:] # coordinates x^0, x^1 of chart c_x as the Python variables x0, x1
X = M.vector_field(name='X') # vector field X
Xf = [M.scalar_field(function('X'+str(i), # list of components
latex_name='X'+'^'+str(i))(x0,x1))
for i in range(N)]
X[:] = Xf
Y = M.vector_field(name='Y') # vector field Y
Yf = [M.scalar_field(function('Y'+str(i), # list of components
latex_name='Y'+'^'+str(i))(x0,x1))
for i in range(N)]
Y[:] = Yf
t = M.tensor_field(0,2, name='t') # tensor field t of type (0,2)
def f2(i,j): return 't'+str(i)+str(j) # names of components
# list of components:
f = [[M.scalar_field(function(f2(j,k))(x0,x1), name=f2(j,k))
for k in range(2)] for j in range(2)]
t[:] = f
t.disp() # show t
# In[41]:
[X.disp(), Y.disp()] # show X,Y
# In[42]:
L_XL_Yt = (t.lie_derivative(Y)).lie_derivative(X) # L_XL_Y(t)
L_YL_Xt = (t.lie_derivative(X)).lie_derivative(Y) # L_YL_X(t)
L = L_XL_Yt-L_YL_Xt # Left hand side of (19.29)
R = t.lie_derivative(X.bracket(Y)) # Right hand side of (19.29)
L == R # check (19.29)
# slow
#
#
# ### Lie derivative for general tensor fields
#
#
#
# For a general tensor field $t\in T^{(k,m)}M$ the lie derivative is defined by
#
# \begin{equation}
# \begin{matrix}
# (£_X t)(α_1 , . . . , α_k , Y_1 , . . . , Y_m ) = X (t (α_1 , . . . , α_k , Y_1 , . . . , Y_m ))\\
# -\sum_{i=1}^k t (α_1 , . . . , £_X α_i , . . . , α_k , Y_1 , . . . , Y_m )\\
# -\sum_{i=1}^m t (α_1 , . . . , α_k , Y_1 , . . . , £_X Y_i , . . . , Y_m ),
# \end{matrix}
# \tag{19.30}
# \end{equation}
#
# for $\ α_1 , . . . , α_k ∈ \Omega^1(M)\ $ and $\ Y_1 , . . . , Y_m ∈ \mathfrak{X}(M)$.
#
#
# ### Lie derivative for general tensor fields in components
#
#
#
# If in coordinates $\ (x^1,\ldots,x^n)\ $ the tensor field $t\in T^{(k,m)}M$ has components
# $t^{i_1\ldots i_k}_{j_1\ldots j_m}$, then the Lie derivative $\ \mathcal{L}_Xt\ \ $ has components
#
# \begin{equation}
# \begin{matrix}
# \displaystyle
# (\mathcal{L}_Xt)^{i_1\ldots i_k}_{j_1\ldots j_m}
# =X^p\frac{\partial t^{i_1\ldots i_k}_{j_1\ldots j_m}}{\partial x^p}
# -t^{p\,i_2\ldots i_k}_{j_1\ldots j_m}\frac{\partial X^{i_1}}{\partial x^p}
# \ldots -t^{i_1\ldots i_{k-1}p}_{j_1\ldots j_m}\frac{\partial X^{i_k}}{\partial x^p}\\
# \displaystyle
# +t^{i_1\ldots i_k}_{p\,j_2\ldots j_m}\frac{\partial X^p}{\partial x^{j_1}}
# +\ldots +t^{i_1\ldots i_k}_{j_1\ldots j_{m-1}\,p}\frac{\partial X^p}{\partial x^{j_m}}.
# \end{matrix}
# \tag{19.31}
# \end{equation}
#
#
#
#
# The formula follows from (19.30). In fact, computing $\mathcal{L}_X$ for scalars $\ f\ $ we have by (19.2) $\ \mathcal{L}_Xf=Xf,\ $ so $\ \mathcal{L}_X(t^{i_1\ldots i_k}_{j_1\ldots j_m})=X^p\frac{\partial t^{i_1\ldots i_k}_{j_1\ldots j_m}}{\partial x^p}$, computing $\mathcal{L}_X$ for $\ dx^i\ $ we have by (19.22), (19.22') $\ \ \mathcal{L}_Xdx^i=\frac{\partial X^i}{\partial x^p}dx^p,\ $ and computing $\mathcal{L}_X$ for for $\frac{\partial}{\partial x^k}$ we can use Lie brackets:
# $$\mathcal{L}_X \frac{\partial}{\partial x^k}
# =[X,\frac{\partial}{\partial x^k}]=[X^p\frac{\partial}{\partial x^p},
# \delta^i_k\frac{\partial}{\partial x^i}]=(X\delta^i_k-\frac{\partial}{\partial x^k}X^p)\frac{\partial}{\partial x^p}
# =-\frac{\partial X^p}{\partial x^k}
# \frac{\partial}{\partial x^p},
# $$
#
# (cf. also (19.23)).
#
#
#
# **Example 19.16**
#
# Compute the Lie derivative $\ \mathcal{L}_Xt\ \ $
# for $\ \ X=X^0\frac{\partial}{\partial x^0}+
# X^1\frac{\partial}{\partial x^1}\ \ $
# and
# $𝑡=𝑡^0_0\frac{∂}{∂𝑥^0}⊗d𝑥^0+𝑡^0_1\frac{∂}{∂𝑥^0}⊗d𝑥^1+𝑡^1_0\frac{∂}{∂𝑥^1}⊗d𝑥^0+𝑡^1_1\frac{∂}{∂𝑥^1}⊗d𝑥^1.$
# In[43]:
get_ipython().run_line_magic('display', 'latex')
N = 2 # dimension of manifold M
M = Manifold(N, 'M') # manifold M
c_x = M.chart(' '.join(['x'+str(i)+':x^{'+str(i)+'}' for i in range(N)])) # chart on M
# In[44]:
def fn(i,j): return 't'+str(i)+str(j) # names of components
def fl(i,j): return 't'+'^'+str(i)+'_'+str(j) # latex names of comp.
# list of components of t:
ff = [[M.scalar_field(function(fn(i,j), latex_name=fl(i,j))(*c_x))
for j in range(N)] for i in range(N)]
t = M.tensor_field(1,1, name='t') # tensor field t
t[:] = ff # define all components of t
Manifold.options.omit_function_arguments=True
t.disp() # show t
# In[45]:
X = M.vector_field() # vector field X
X[:] = (function('X0', latex_name='X^0')(*c_x),
function('X1', latex_name='X^1')(*c_x)) # comp. of X
LtX = t.lie_derivative(X) # Lie derivative L_X(t)
LtX.disp() # show Lie derivative
# For comparison, using (19.31) without simplifications we obtain the following components of
# $\ \mathcal{L}_Xt\ \ $ (in the first row we repeat the general formula)
#
# $$
# \begin{matrix}
# X^p\frac{\partial t^{i_1\ldots i_k}_{j_1\ldots j_m}}{\partial x^p}
# &
# -t^{p\,i_2\ldots i_k}_{j_1\ldots j_m}\frac{\partial X^{i_1}}{\partial x^p}
# \ldots -t^{i_1\ldots i_{k-1}p}_{j_1\ldots j_m}\frac{\partial X^{i_k}}{\partial x^p}
# &
# +t^{i_1\ldots i_k}_{p\,j_2\ldots j_m}\frac{\partial X^p}{\partial x^{j_1}}
# +\ldots +t^{i_1\ldots i_k}_{j_1\ldots j_{m-1}\,p}\frac{\partial X^p}{\partial x^{j_m}}\\
# X^0\frac{\partial t^0_0}{\partial x^0}+X^1\frac{\partial t^0_0}{\partial x^1}
# &
# -t^0_0\frac{\partial X^0}{\partial x^0}-t^1_0\frac{\partial X^0}{\partial x^1}
# &
# +t^0_0\frac{\partial X^0}{\partial x^0}+t^0_1\frac{\partial X^1}{\partial x^0}\\
# X^0\frac{\partial t^0_1}{\partial x^0}+X^1\frac{\partial t^0_1}{\partial x^1}
# &
# -t^0_1\frac{\partial X^0}{\partial x^0}-t^1_1\frac{\partial X^0}{\partial x^1}
# &
# +t^0_0\frac{\partial X^0}{\partial x^1}+t^0_1\frac{\partial X^1}{\partial x^1}\\
# X^0\frac{\partial t^1_0}{\partial x^0}+X^1\frac{\partial t^1_0}{\partial x^1}
# &
# -t^0_0\frac{\partial X^1}{\partial x^0}-t^1_0\frac{\partial X^1}{\partial x^1}
# &
# +t^1_0\frac{\partial X^0}{\partial x^0}+t^1_1\frac{\partial X^1}{\partial x^0}\\
# X^0\frac{\partial t^1_1}{\partial x^0}+X^1\frac{\partial t^1_1}{\partial x^1}
# &
# -t^0_1\frac{\partial X^1}{\partial x^0}-t^1_1\frac{\partial X^1}{\partial x^1}
# &
# +t^1_0\frac{\partial X^0}{\partial x^1}+t^1_1\frac{\partial X^1}{\partial x^1}
# \end{matrix}
# $$
#
# which of course gives the same result.
#
# Bellow we list the components of the Lie derivative using `display_comp` method:
# In[46]:
LtX.display_comp(coordinate_labels=False)
# In[47]:
#LtX.comp()[:] # matrix of components
# ## What's next?
#
# Take a look at the notebook [Integration of differential forms on singular $k$-cubes](https://nbviewer.org/github/sagemanifolds/IntroToManifolds/blob/main/20Manifold_Stokes.ipynb).