This notebook is part of the Introduction to manifolds in SageMath by Andrzej Chrzeszczyk (Jan Kochanowski University of Kielce, Poland).
version()
'SageMath version 9.6, Release Date: 2022-05-15'
Warning: In this notebook $M$ denotes a module --- not a manifold
Le us assume that $e=(e_1,\ldots,e_n)$ is a basis in a finite dimensional vector space $V$ or more generally finite rank free module $M$ over a ring $R$ (defined in notebook 6), so every vector $v$ can be uniquely represented as a linear combination $v=\sum_i\alpha_i e_i=\alpha_i e_i$, $\ \alpha_i\in R$.
Example 10.1
Define a basis in a 3-dimensional module over the symbolic ring SR
.
N=3 # dim. of the module M
%display latex
M = FiniteRankFreeModule(SR, 3, name='M') # module M
e = M.basis('e') ;e # basis of M
If $(e_1,\ldots,e_n)$ is a basis we denote by $(e^1,\ldots,e^n)$ the dual basis, i.e. the family of linear forms $M\to R$, such that $e^i(e_j)=\delta_j^i= \begin{cases} 1,& \text{if } i=j,\\ 0, & \text{otherwise.} \end{cases} $
Example 10.2
Let us define the dual basis to the basis from the previous example.
# continuation
d=e.dual_basis()
matrix(N,N,lambda i,j:d[i](e[j])) # matrix of all e^i(e_j)
If $(e_1,\ldots,e_n)$ is a basis and $(e^1,\ldots,e^n)$ its dual basis, then for $w=\alpha_je_j$ we have
$$e^i(w)=e^i(\alpha_je_j)=\alpha_je^i(e_j)=\alpha_j\delta^i_j=\alpha_i,$$so the $i$-th element of the dual basis is the $i$-th coordinate function: $$e^i(\alpha_je_j)=\alpha_i.$$
Example 10.3
For example let us check the values of all elements of the dual basis $d=(e^0,e^1,e^2)$ on the vector $w=\alpha_0e_0+\alpha_1e_1+\alpha_2e_2$.
# continuation
al=var('α',n=N) #\alpha+{Tab}
w=sum([al[k]*e[k] for k in range(N)]) # w=al_k*e_k
w.disp() # show w
[d[i](w) for i in range(N)] # compute e^i(w) for i=0,1,2,
By a permutation of a set $Y$ we mean a bijection $\sigma: Y\to Y$. In the sequel we will restrict ourselves to finite sets $Y=\{1,2,\ldots,k\}.$ In that case, the permutation is just the reordering $(1,2,\ldots,k)\to(\sigma(1),\sigma(2),\ldots,\sigma(k)).$ To define a permutation, it is sufficient to define the image $(\sigma(1),\sigma(2),\ldots,\sigma(k))$.
Example 10.4
We can define a permutation of the set $(1,2,3)$ by its image $(p(1),p(2),p(3))$.
p = Permutation([2,1,3]);p # (1,2,3)->(2,1,3)
The action of $p$ on (1,2,3):
a = [1,2,3] # a -sequence to permute
p.action(a) # permutation of a
The permutations form a group if we define the multiplication as the composition: $\sigma\tau=\sigma\circ\tau.$ The group of permutations of the set $\{1,2,\ldots,k\}$ is usually denoted by ${S_k}$.
An inversion of a permutation $\sigma$ is a pair $(i, j)$ such that $i < j$ and $\sigma(i) > \sigma(j)$. A permutation is even or odd depending on whether it is the product of an even or odd number of inversions. The sign of a permutation $\sigma$, denoted by $\mathrm{sign}(\sigma)$ is defined to be +1 or -1 depending on whether the permutation is even or odd. The sign of permutations satisfies
$$\mathrm{sign}(\sigma\tau)=\mathrm{sign}(\sigma)\mathrm{sign}(\tau).$$Example 10.5
Let us compute for example the sign of the permutation $(4,2,1,3,5)$ of $(1,2,3,4,5)$.
p=Permutation([4,2,1,3,5])
sign(p)
# even number of inversions
p.inversions()
p.number_of_inversions()
Example 10.6
Now let us list all permutations from $S_3$ and their signs.
S3=Permutations(3).list() # S_3
[(p,sign(p)) for p in S3] # signs of all permutations from S_3
Let $M^k=M\times\dots\times M,$ where $M$ is a vector space or a module. Recall that by a $k$-linear form on $M$ (or covariant tensor of type $(0,k)$) we mean a function $t: M^k\to R$ which is linear in each of its arguments, i.e for $i=1,\ldots,k$
$$t(v_1,\ldots,\alpha v_i+\beta w_i,\ldots, v_k)= \alpha t(v_1,\ldots,v_i,\ldots,v_k)+\beta t(v_1,\ldots,w_i,\ldots, v_k),\quad \alpha,\beta\in R,\quad v_i,w_i\in M.$$A $k$-linear form $t:M^k\to R$ is alternating if it changes sign every time two of its variables are interchanged, that is, if
$$t (v_1 , . . . , v_i , . . . , v_j , . . . , v_k ) = −t (v_1 , . . . , v_j , . . . , v_i , . . . , v_k ).$$Let us recall that in the notebook 9a the $k$-linear forms on $M$ were called covariant tensors from $T^{(0,k)}M$.
In notations used by SageMath
the module of alternating $k$-forms on a module $M$ is denoted by $\Lambda^k(M^*)$ ( it is a submodule of $T^{(0,k)}M$).
Example 10.7
Define a 3-linear form and alternating 3-form on a module M.
M = FiniteRankFreeModule(SR, 3, name='M') # module M of rank 3 over SR
# SR is a field, so M is vect.sp.
e = M.basis('e') # basis of M
t=M.tensor((0,3),name='t');print(t) # covariant tensor of type (0,3)
Type-(0,3) tensor t on the 3-dimensional vector space M over the Symbolic Ring
For alternating forms we have a special command: alternating_form
.
a=M.alternating_form(3);a # alternating form on M
# the mathematical object of which "a" is an element.
print(a.parent())
show(a.parent())
3rd exterior power of the dual of the 3-dimensional vector space M over the Symbolic Ring
If $t$ is a covariant tensor from $T^{(0,k)}M$, then we can define an alternating $k$-form called Alt($t$) in the following way \begin{equation} \mathrm{Alt}(t)(v_1,\ldots,v_k)=\frac{1}{k!}\sum_{\sigma\in S_k}\mathrm{sign}(\sigma)\;t(v_{\sigma(1)},\ldots,v_{\sigma(k)}), \label{}\tag{10.1} \end{equation} for $v_i\in M$.
The antisymmetrization operation in SageMath Manifolds is accessible by the method
antisymmetrize
.
Example 10.8
Let us define a tensor of type $(0,2)$ on a 3-dimensional module $M$ and its antisymmetrization.
M = FiniteRankFreeModule(SR, 3, name='M') # module M of rank 3
e = M.basis('e') # basis of M
t = M.tensor((0,2)); print('t:',t) # tensor of type (0,2)
t[:] = [[1,-2,3], [4,5,6], [7,8,-9]]; # components of t
ta=t.antisymmetrize();print('ta:',ta) # antisymmetrization of t
t: Type-(0,2) tensor on the 3-dimensional vector space M over the Symbolic Ring ta: Alternating form of degree 2 on the 3-dimensional vector space M over the Symbolic Ring
In the next series of cells we try to show some details of the antisymmetrization operation Alt.
Example 10.9
If $k=2$ there are only two permutations in $S_k$, with signs +1, -1 so the sum from the antisymmetrization definition (10.1), applied to $\ t=t_{ij}e^i\otimes e^j,\ i,j=0,1\ $ computed on the vectors $(v_0,v_1)=(e_0,e_1)$ reduces to $\frac{1}{2!}(t_{01}-t_{10})$.
Define tensor $t$:
%display latex
N=3
Mo = FiniteRankFreeModule(SR, N, name='Mo') # 3-dim module M
e = Mo.basis('e') # basis of M
t=Mo.tensor((0,2)) # (0,2) type tensor
symb_mat=[[var('t'+str(i)+str(j))
for j in range(N)] for i in range(N)] # matrix of components
t[:]=symb_mat # define all components
t.disp() # show t
and list components of $t$ in the sum (10.1):
S2=Permutations(2).list() # list of perm.from S_2
[t(e[p[0]-1],e[p[1]-1]) for p in S2] # elements in the sum (10.1)
# permutations p[i] give numbers from {1,..,k},
# we need indices from {0,..,k-1}, therefore we are subtracting 1
Compute the sum from the definition (10.1) of antisymmetrization for $(v_0,v_1)=(e_0,e_1)$:
1/factorial(2)*sum([sign(p)*t(e[p[0]-1],e[p[1]-1]) for p in S2])
Check if SageMath Manifolds antisymmetrize
gives the same result:
ta=t.antisymmetrize()
ta(e[0],e[1])
Example 10.10
Now let us check how the antisymmetrization works for covariant tensors from $T^{(0,3)}M$. We define symbolic 3-dimensional tables first.
%display latex
N=4 # dimension of module
symb_ten3=[[[var('t'+str(i0)+str(i1)+str(i2))
for i2 in range(N)]
for i1 in range(N)]
for i0 in range(N)] # components of t
symb_ten3 # show components
Since $S_3$ contains 3!=6 elements, the sum from antisymmetrization definition (10.1) contains 6 summands.
# continuation
Mo = FiniteRankFreeModule(SR, N, name='Mo') # module Mo of dimension 4
e = Mo.basis('e') # basis of M
t = Mo.tensor((0,3), name='t') # tensor t of type (0,3)
t[:]=symb_ten3 # components of t
S3=Permutations(3).list() # permutation group S_3
Let us apply the antisymmetrization definition (10.1) for $(v_0,v_1,v_2)=(e_0,e_1,e_2)$.
1/factorial(3)*sum([sign(p)*t(e[p[0]-1],e[p[1]-1],e[p[2]-1]) for p in S3])
Let us check what gives the antisymmetrize
method:
ta=t.antisymmetrize()
ta(e[0],e[1],e[2])
#ta.antisymmetrize?
Note that in the above calculations we restricted ourselves to one component of the antisymmetrized tensor.
To display the full result we need the notion of tensor and wedge products.
Recall the definition (9.1a) of the tensor product
For $\ t\in T^{(0,k)}M,\,s\in T^{(0,m)}M\ $ we define the tensor product $\ \ t\otimes s\in T^{(0,k+m)}M$ by
\begin{equation} (t ⊗ s )(v_1 ,\ldots , v_{k+m} ) ≡ t (v_1 ,\ldots, v_k ) s (v_{k+1} , . . . , v_{k+m} ), \tag{9.1a} \end{equation}for $v_1,\ldots,v_{k+m}\in M$.
Using the antisymmetrization operation Alt we can define the wedge product between alternating forms $t ∈ \Lambda^k(M^*)$ and $s ∈ \Lambda^m(M^*)$, which gives $t ∧ s ∈ \Lambda^{k+m}(M^*)$ defined by \begin{equation} t ∧ s =\frac{(k + m)!}{k!m!}\mathrm{Alt}(t ⊗ s). \label{}\tag{10.2} \end{equation}
Example 10.11
If $a,b\in \Lambda^1(M^*),$ then since $S_2$ contains only two permutations of opposite sign we see that Alt$(a\otimes b)$ is equal to $\frac{1}{2!}(t\otimes s -s\otimes t)$ and $t\wedge s=\frac{(1+1)!}{1!1!}\Big(\frac{1}{2!}((t\otimes s -s\otimes t)\Big)=t\otimes s -s\otimes t$.
One can prove that for $t\in \Lambda^k(M^*),s\in\Lambda^m(M^*),r\in\Lambda^l(M^*)$
$$(t ∧ s) ∧ r = t ∧ (s ∧ r),$$(in notebook 14 we prove this for differential forms).
Since the order of parentheses in that formula is not essential we can replace both sides by $t\wedge s\wedge r$, analogously we can form the wedge products of larger number of forms: $t_1\wedge\ldots\wedge t_i$.
To show concrete examples of alternating forms we will use bases in the spaces of alternating $k$-forms.
If $e^1,\ldots,e^n$ is a basis of $M^*$, then the set
$$ \{e^{i_1}\wedge\dots\wedge e^{i_k}: 1\leq i_1<\ldots<i_k\leq n\} $$is a basis for $\Lambda^k(M^*)$, i.e. elements of this set are linearly independent and every $a\in\Lambda^k(M^*)$ can be uniquely written in the form
\begin{equation} a=\sum_{1\leq i_1<\ldots<i_k\leq n} a_{i_1\ldots i_k} e^{ i_1} \wedge \ldots \wedge e^{i_k}, \tag{10.3} \end{equation}where $$ a_{i_1\ldots i_k}=a(e_{i_1},\ldots,e_{i_k}). $$
Detailed proof of this fact, in the case of differential forms, is given in notebook 14.
Since the indices $i_1,\ldots,i_k$ form a strictly increasing sequences, the number of such sequences for an $n$-dimensional $M$ is $\binom{n}{k}$, so the dimension of $\Lambda^k(M^*)$ for an $n$-dimensional $M$ is $\binom{n}{k}.$
Example 10.12
Take two 1-forms $a$ and $b$:
%display latex
M = FiniteRankFreeModule(SR, 3, name='M') # module M of dimension 3
e = M.basis('e') # basis of M
a=M.alternating_form(1) # 1-form a
b=M.alternating_form(1) # 1-form b
a[:]=var('a',n=3) # a0,a1,a2 # components of a
b[:]=var('b',n=3) # b0,b1,b2 # components of b
a.disp() # show a
# the mathematical object of which "a" is an element.
a.parent()
a[:] # comp. in the basis e
b.disp() # show b
Compute the wedge product $a\wedge b$:
t=a.wedge(b);print(t) # wedge prod. a/\b
t.disp() # show wedge prod.
Alternating form of degree 2 on the 3-dimensional vector space M over the Symbolic Ring
Let us check the result using the definition of wedge product.
%display latex
tt=factorial(1+1)/factorial(1)/factorial(1)*(a*b).antisymmetrize()
tt.disp() # show the result of application of definition of a/\b
Let us note that for 1-forms with components $a_0,a_1,a_2$ and $b_0,b_1,b_2$ the components of $a\wedge b$ are just the minors of $\Big(\begin{matrix} a_0,a_1,a_2\\ b_0,b_1,b_2 \end{matrix}\Big). $
ma=matrix([a[:],b[:]]);ma # matrix with comp. of a and b as rows
ma.minors(2) # 2x2 minors of matrix ma
Example 10.13
Let us compute the wedge product of three 1-forms in a 3-dimensional module.
M = FiniteRankFreeModule(SR, 3, name='M') # module M of dimension 3
e = M.basis('e') # basis of M
d=e.dual_basis() # dual basis
a=M.alternating_form(1) # 1-form a
b=M.alternating_form(1) # 1-form b
c=M.alternating_form(1) # 1-form c
a[:]=var('a',n=3) # components of a
b[:]=var('b',n=3) # components of b
c[:]=var('c',n=3) # components of c
abc=(a.wedge(b)).wedge(c) # a/\b/]c
abc.disp() # show abc
# the mathematical object of which "abc" is an element.
abc.parent()
We can recognize in the result the Laplace expansion of the determinant det $\left(\begin{matrix} a_0,a_1,a_2\\ b_0,b_1,b_2\\ c_0,c_1,c2 \end{matrix}\right), $
so we obtain $\quad a\wedge b\wedge c=$ det $\left(\begin{matrix} a_0,a_1,a_2\\ b_0,b_1,b_2\\ c_0,c_1,c2 \end{matrix}\right) e^0\wedge e^1\wedge e^2. $
SageMath Manifolds also recognizes that equality:
# compare abc and the 3-form with unique component equal to
# det of the matrix of coefficients of a,b,c
abc==det(matrix([a[:],b[:],c[:]]))*(d[0].wedge(d[1])).wedge(d[2])
Example 10.14
For alternating 2-forms the antisymmetry property $a(v_1,v_2)=-a(v_2,v_1)$ implies, that the corresponding component matrices must be antisymmetric, so only upper or lower triangles of the component matrices must be defined.
M = FiniteRankFreeModule(SR, 3, name='M') # module M of dimension 3
e = M.basis('e') # basis of M
c=var('c',n=3) # c_0,c_1,c_2
c=M.alternating_form(2) # 2-form
c[0,1]=c0; c[0,2]=c1; c[1,2]=c2 # components of 2-form
c[:] # show component matr.
a=M.alternating_form(1) # 1-form a
a[:]=var('a',n=3) # components of a
a.disp() # show a
Compute 1-form times 2-form in 3-dimensional module:
# continuation
ac=a.wedge(c);ac
ac.disp() # show ac
Let us apply the definition of wedge product for comparison.
(factorial(3)/factorial(2)*(a*c).antisymmetrize()).disp()
Example 10.15
Clarification of the factor $\mathbf {\frac{1}{k!m!}}$ in the wedge product definition.
Let us perform the wedge product between a 2-form and 3-form in 5-dimensional module.
# 2form times 3form in 5-dimensions
%display latex
var('a12,a24,a35') # symbolic components of 2-form w1
var('b123,b234,b345') # symbolic components of 3-form w2
V = FiniteRankFreeModule(SR,rank=5, name='V', start_index=1)
e = V.basis('e'); # basis of V
w1=V.alternating_form(2) # w1 is 2-form with
w1[1,2],w1[2,4],w1[3,5]=a12,a24,a35; # components a12,a24,a35
w2=V.alternating_form(3) # w2 is 3-form
w2[1,2,3],w2[2,3,4],w2[3,4,5]=b123,b234,b345; # with components
# b123,b234,b345
w1.display() # show w1
w2.display() # show w2
Here is the wedge product according to SageMath Manifolds:
w1.wedge(w2).display() # show w1/\w2
Let us apply the definition of wedge product for comparison:
w=w1*w2
w0=factorial(2+3)/factorial(3)/factorial(2)*w.antisymmetrize()
w0.display()
If we drop the factor $\frac{1}{2!3!}$ and expand the sum from the antisymmetrization definition (cf. (10.1)) we obtain (the factor $(2+3)!$ is canceled by the factor $\frac{1}{(2+3)!}$ from that definition):
S5=Permutations(5).list()
s0=sum([sign(p)*w1(e[p[0]],e[p[1]])*w2(e[p[2]],e[p[3]],e[p[4]])
for p in S5])
s0
The last sum contains $2!\cdot 3!=12$ repeated elements.
Below we display all permutations from $S_5$ which give nonzero elements in the sum from the definition of wedge product. All mentioned permutations $p$ give the same result of
$${\rm{sign}}(p)\,w_1(e_{p(0)},e_{p(1)})\,w_2(e_{p(2)},e_{p(3)},e_{p(4)})$$equal to $\ \ a_{12}b_{345}:$
# (shows only the nonzero elements of the sum of 5!=120 elements)
[[p[0],p[1],p[2],p[3],p[4],'---',
sign(p)*w1(e[p[0]],e[p[1]])*w2(e[p[2]],e[p[3]],e[p[4]])]
for p in S5 if (Set(range(1,3))==Set([p[0],p[1]]) and
Set(range(3,6))==Set([p[2],p[3],p[4]]))]
Thus the factor $\frac{1}{k!m!}$ in the wedge product definition is reasonable. Some authors use different choices of this factor. We follow the SageMath Manifolds choice.
For arbitrary $k$-forms in $\Lambda^k(M^*)$
sometimes we would not want to actually write out all the indices from (10.3), so
instead we will write
\begin{equation}
α =\sum_I a_I dx^I .
\label{}\tag{10.4}
\end{equation}
Here the $I$ stands for the sequence of $k$ increasing indices $i_1 i_2 \ldots i_k$: $1 ≤ i_1 < i_2 < \ldots < i_k ≤ n$. That is, we sum over
$I ∈ J_{k,n} = \{(i_1 i_2 \ldots i_k ) : 1 ≤ i_1 < i_2 < \ldots < i_k ≤ n\}$ .
For example, for $k = 3$ and $n = 4$ we have $I\in\{123,124,134,234\}.$
If $I$ and $J$ are disjoint then we have $dx^I ∧ dx^J = ±dx^K$ where $K = I ∪ J$ , but is reordered to be in increasing order. Elements with repeated indices are dropped. Using this notation we can compute the wedge product as follows
\begin{equation} \Big(\sum_I a_Idx^I\Big)\wedge\Big(\sum_J b_Jdx^J\Big)= \sum_K\Big(\sum_{\substack{I\cup J=K\\I\cap J=\emptyset}}\pm a_Ib_J\Big)dx^K. \label{}\tag{10.5} \end{equation}Example 10.16
Let us demonstrate this method in the case of the wedge product of 2-form times 2-form in a four-dimensional module.
var('f12,f13,f14, f23, f24, f34') # variables for components of w1
var('g12,g13,g14, g23, g24, g34') # variables for components of w2
# module V of dimension 4:
V = FiniteRankFreeModule(SR,rank=4, name='V', start_index=1)
e = V.basis('e'); # basis of V
w1=V.alternating_form(2) # 2-form w1
# components of w1
w1[1,2],w1[1,3],w1[1,4],w1[2,3],w1[2,4],w1[3,4]=f12,f13,f14, f23, f24, f34
w2=V.alternating_form(2) # 2-form w2
# components of w2
w2[1,2],w2[1,3],w2[1,4],w2[2,3],w2[2,4],w2[3,4]=g12,g13,g14, g23, g24, g34
w1.display() # show w1
w2.display() # show w2
Computing the wedge product we use all possible strictly increasing and disjoint sequences $I=(i_1,i_2),\quad J=(j_1,j_2),\quad$ $dx^K=e^1\wedge e^2\wedge e^3\wedge e^4,\quad$ $K=(1,2,3,4)$ is reordered disjoint union $I\cup J$.
In our example we take all possible 2-element increasing permutations of indices for the first form:
$$I\in \{(1,2), (1,3), (1,4), (2,3), (2,4), (3,4)\}$$The corresponding increasing $J$ satisfying $I\cup J=\{1,2,3,4\}$ and $I\cap J=\emptyset$ are:
$$J\in \{(3,4), (2,4), (2,3), (1,4), (1,3), (1,2)\}$$so, the wedge product is $$(f_{12}g_{34}-f_{13}g_{24}+f_{14}g_{23}+f_{23}g_{14}-f_{24}g_{13}+f_{34}g_{12})e^1\wedge e^2\wedge e^3\wedge e^4.$$
The signs in the last result are the signs of the corresponding permutations:
s=[[1,2,3,4],[1,3,2,4],[1,4,2,3],[2,3,1,4],[2,4,1,3],[3,4,1,2]]
[sign(Permutation(x)) for x in s] # list of signs of permut.
SageMath Manifolds gives the sum in parentheses in reverse order:
w=w1.wedge(w2) # wedge product w1/\w2
w.display() # show wedge product
Multilinearity
For $\alpha,\alpha_1,\alpha_2\in \Lambda^k(M^*),\beta,\beta_1,\beta_2\in \Lambda^m(M^*)$ and $a\in R$ \begin{equation} (\alpha_1+\alpha_2)\wedge\beta=\alpha_1\wedge\beta+\alpha_2\wedge\beta,\\ \alpha\wedge(\beta_1+\beta_2)=\alpha\wedge\beta_1+\alpha\wedge\beta_2,\\ (a\alpha)\wedge\beta=a(\alpha\wedge\beta)=\alpha\wedge(a\beta). \label{}\tag{10.6} \end{equation}
Associativity
For $\alpha_i\in \Lambda^{k_i}(M^*)$
\begin{equation} (\alpha_1\wedge \alpha_2)\wedge \alpha_3=\alpha_1\wedge(\alpha_2\wedge \alpha_3). \tag{10.7} \end{equation}Anticommutativity
If $t ∈ \Lambda^k(M^*)$ and $s ∈ \Lambda^m(M^*)$, then \begin{equation} t ∧ s = (−1)^{km} s ∧ t. \label{}\tag{10.8} \end{equation}
In the notebook 14 we will prove analogous properties in the case of differential forms.
Take a look at the notebook Vector fields.