{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 6. The notion of module\n", "\n", "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)." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'SageMath version 9.6, Release Date: 2022-05-15'" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "version()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If F is a field, a set V is called a **vector space** over F if there is an operation of addition $\\ (x,y) → x+y\\ \\ $\n", "from V×V to V, and a scalar multiplication operation $\\ \\ (α,x) → αx\\ \\ $ from F×V to V, such that the following properties are satisfied.
\n", "(i) (u+v) + w = u + (v+w) for all u, v, w ∈ V,
\n", "(ii) u+v=v+u for all u, v ∈ V,
\n", "(iii) There exists an element 0 ∈ V such that 0+v=v+0 for all v ∈ V,
\n", "(iv) For each v ∈ V there exists u ∈ V such that v+u=0,
\n", "(v) 1v=v for all v ∈ V,
\n", "(vi) $(\\alpha\\beta)v=\\alpha(\\beta v)$ for all $\\alpha,\\beta\\in F$ and v∈V,
\n", "(vii) $(\\alpha+\\beta)v=\\alpha v+\\beta v$ for all $\\alpha,\\beta\\in F$ and v∈V,
\n", "(viii) $\\alpha(u+v)=\\alpha u+\\alpha v$ for all $\\alpha\\in F$\n", "and $u$∈V. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The formal definition of the **module** M over the ring R is exactly as above (with V replaced by M and F replaced by R) but we\n", "relax the requirement that F be a field, and instead allow an\n", "arbitrary ring R (with unity). We shall restrict ourselves to the commutative rings R.\n", "\n", "A **free module of finite rank** over a commutative ring R is a module $M$ over R that admits a **finite basis**, that is a finite family $\\{e_1,\\ldots,e_k\\}$, which spans $M$, i.e., for every $v\\in M$, $\\ v=\\sum_{i=1}^k a_ie_i$ for some $ a_i\\in$ R, and $e_i$ are **linearly independent** i.e., $\\sum_{i=1}^k a_ie_i=0$ implies that all $a_i$ are zero. \n", "\n", "Since R is commutative, it has the invariant basis number property, so that the **rank (dimension) of the free module M** is defined uniquely, as the cardinality of any basis of $M$.\n", "\n", "### General remark on free modules in SageMath\n", "\n", "**Basic motivation for introducing free modules into consideration in SageMath Manifolds is the fact that the sets of vector fields and tensor fields on a parallelizable open subset U of the manifold, are free modules over the ring of scalar fields on U.**" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Some frequently used commands from `SageMath FiniteRankFreeModule`:\n", "\n", "```\n", "an_element endomorphism sym_bilinear_form \n", "automorphism hom tensor\n", "bases irange tensor_from_comp\n", "basis linear_form tensor_module\n", "change_of_basis rank alternating_form \n", "default_basis set_change_of_basis dual_exterior_power\n", "dual set_default_basis exterior_power\n", "```\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In our examples we will use mainly the SageMath symbolic ring SR.\n", "\n", "
\n", "\n", "**Example 6.1**\n", "\n", "`FiniteRankFreeModule` in `SageMath`:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Symbolic ring SR is considered as a field: " ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "SR.is_field() # Symbolic ring is a field" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "so the finite rank free modules over SR are in fact vector spaces:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "4-dimensional vector space V over the Symbolic Ring" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "V = FiniteRankFreeModule(SR,4,name='V') # rank 4 free module V over SR\n", "#V? --detailed explanations concerning FiniteRankFreeModule\n", "V # information on V" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Defining V as a finite rank free module over a field we obtain a vector space without predefined basis." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[]" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "V.bases() # check that V has no predefined basis" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Later we shall see that **without any specific coordinate choice, no basis can be distinguished in a tangent space. This is one more motivation for using modules in SageMath Manifolds**.\n", "\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let us check that defining vector space with VectorSpace command, we introduce a predefined basis." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Vector space of dimension 4 over Symbolic Ring" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "W = VectorSpace(SR,4); W" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[\n", "(1, 0, 0, 0),\n", "(0, 1, 0, 0),\n", "(0, 0, 1, 0),\n", "(0, 0, 0, 1)\n", "]" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "W.basis()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In SageMath the VectorSpace of rank 4 over R is in fact R^4 \n", "-the Cartesian power of R." ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "W == SR^4" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "but an analogous FiniteRankFreeModule is not:" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "False" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "V == SR^4" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "\n", "**Example 6.2**\n", "\n", "To define a vector in `SageMath Manifolds` we need some basis. " ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\\(\\displaystyle u = e_{0} + 2 e_{1} + 3 e_{2} + 4 e_{3}\\)" ], "text/latex": [ "$\\displaystyle u = e_{0} + 2 e_{1} + 3 e_{2} + 4 e_{3}$" ], "text/plain": [ "u = e_0 + 2 e_1 + 3 e_2 + 4 e_3" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%display latex\n", "M = FiniteRankFreeModule(SR, 4, name='M') # module M\n", "e = M.basis('e') # basis of M\n", "# e? -detailed explanations concerning bases\n", "# range(1,5)=[1,2,3,4] --coefficients of the linear combination\n", "u = M(range(1,5),name='u');u.disp() # show vector" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " Vectors can be defined also as linear combinations of the basis." ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\\(\\displaystyle e_{0} + 2 e_{1} + 3 e_{2} + 4 e_{3}\\)" ], "text/latex": [ "$\\displaystyle e_{0} + 2 e_{1} + 3 e_{2} + 4 e_{3}$" ], "text/plain": [ "e_0 + 2 e_1 + 3 e_2 + 4 e_3" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "al = srange(1,5) # a more flexible version of range\n", " # linear combination of basis:\n", "w = sum([al[k]*e[k] for k in range(4)])\n", "w.disp() # show w" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\\(\\displaystyle α_{0} e_{0} + α_{1} e_{1} + α_{2} e_{2} + α_{3} e_{3}\\)" ], "text/latex": [ "$\\displaystyle α_{0} e_{0} + α_{1} e_{1} + α_{2} e_{2} + α_{3} e_{3}$" ], "text/plain": [ "α0 e_0 + α1 e_1 + α2 e_2 + α3 e_3" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# a more general linear combination of a basis \n", "# \\alpha+[Tab] gives the Greek letter alpha\n", "al = var('α',n=4) # α_i, i=1,2,3,4\n", " # linear combination of basis:\n", "w = sum([al[k]*e[k] for k in range(4)])\n", "w.disp() # show w" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "\n", "### Linear transformations in finite rank free module" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "\n", "By the linearity of the map $\\Phi:M\\to N$ between two modules over $R$ we mean the condition\n", "\n", "$$ \\Phi (av + bw ) = a\\Phi (v) + b\\Phi (w ),\\quad\\text{for}\\quad v,w\\in M,\\quad a,b\\in R.$$\n", "\n", "
\n", "\n", "### Automorphism\n", "\n", "
\n", "\n", "\n", "**Automorphism** of the module M is a bijective linear transformation M $\\to$ M.\n", "\n", "An automorphism allows for example for defining a new basis.
\n", "If more than one bases are defined, the first one is the default one.\n", "\n", "
\n", "\n", "**Example 6.3**\n", "\n", "Let us define a module with two bases and an automorphism defining the change of basis." ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\\(\\displaystyle \\left(u = e_{0} + 2 e_{1} + 3 e_{2} + 4 e_{3}, \\verb|________|, u = \\frac{1}{4} f_{0} + \\frac{2}{3} f_{1} + \\frac{3}{2} f_{2} + 4 f_{3}\\right)\\)" ], "text/latex": [ "$\\displaystyle \\left(u = e_{0} + 2 e_{1} + 3 e_{2} + 4 e_{3}, \\verb|________|, u = \\frac{1}{4} f_{0} + \\frac{2}{3} f_{1} + \\frac{3}{2} f_{2} + 4 f_{3}\\right)$" ], "text/plain": [ "(u = e_0 + 2 e_1 + 3 e_2 + 4 e_3,\n", " '________',\n", " u = 1/4 f_0 + 2/3 f_1 + 3/2 f_2 + 4 f_3)" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%display latex\n", "M = FiniteRankFreeModule(SR, 4, name='M') # 4-dim module over SR\n", "a = M.automorphism() # automorphism of M\n", "# a? --detailed explanations concerning module automorphism\n", "e = M.basis('e') # define default basis\n", "f = M.basis('f') # define second basis\n", "# diagonal matrix with diagonal (4,3,2,1) \n", "a[e,:]=diagonal_matrix(4, srange(4,0,-1)); # matrix of automorphism\n", "M.set_change_of_basis(e, f, a) # define change of basis\n", "u = M(range(1,5),name='u') # define vector\n", "# displaying the vector in non-default basis needs \n", "# the basis name as an argument\n", "u.disp(),'________',u.disp(f) # vector u in bases e and f" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\\(\\displaystyle \\left(e_{0},e_{1},e_{2},e_{3}\\right)\\)" ], "text/latex": [ "$\\displaystyle \\left(e_{0},e_{1},e_{2},e_{3}\\right)$" ], "text/plain": [ "Basis (e_0,e_1,e_2,e_3) on the 4-dimensional vector space M over the Symbolic Ring" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "M.default_basis() # default basis" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Matrix of the automorphism:" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\\(\\displaystyle \\left(\\begin{array}{rrrr}\n", "4 & 0 & 0 & 0 \\\\\n", "0 & 3 & 0 & 0 \\\\\n", "0 & 0 & 2 & 0 \\\\\n", "0 & 0 & 0 & 1\n", "\\end{array}\\right)\\)" ], "text/latex": [ "$\\displaystyle \\left(\\begin{array}{rrrr}\n", "4 & 0 & 0 & 0 \\\\\n", "0 & 3 & 0 & 0 \\\\\n", "0 & 0 & 2 & 0 \\\\\n", "0 & 0 & 0 & 1\n", "\\end{array}\\right)$" ], "text/plain": [ "[4 0 0 0]\n", "[0 3 0 0]\n", "[0 0 2 0]\n", "[0 0 0 1]" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a.matrix() # matrix of automorphism a" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "\n", "**Example 6.4**\n", "\n", "The new basis can be also defined component by component." ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\\(\\displaystyle \\left(u = e_{0} + 2 e_{1} + 3 e_{2} + 4 e_{3}, \\verb|______|, u = \\frac{1}{4} f_{0} + \\frac{2}{3} f_{1} + \\frac{3}{2} f_{2} + 4 f_{3}\\right)\\)" ], "text/latex": [ "$\\displaystyle \\left(u = e_{0} + 2 e_{1} + 3 e_{2} + 4 e_{3}, \\verb|______|, u = \\frac{1}{4} f_{0} + \\frac{2}{3} f_{1} + \\frac{3}{2} f_{2} + 4 f_{3}\\right)$" ], "text/plain": [ "(u = e_0 + 2 e_1 + 3 e_2 + 4 e_3,\n", " '______',\n", " u = 1/4 f_0 + 2/3 f_1 + 3/2 f_2 + 4 f_3)" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%display latex\n", "M=FiniteRankFreeModule(SR,4,name='M') # 4-dim module over SR\n", "e = M.basis('e') # basis e\n", "f = M.basis('f', from_family= # new basis f contains lin.comb.\n", " (4*e[0],3*e[1],2*e[2],e[3])) # of elements of e\n", "u = M(range(1,5),name='u'); # vector u\n", "u.disp(),'______',u.disp(f) # u in bases e and f" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Matrix of the change of basis e $\\to$ f:" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\\(\\displaystyle \\left(\\begin{array}{rrrr}\n", "4 & 0 & 0 & 0 \\\\\n", "0 & 3 & 0 & 0 \\\\\n", "0 & 0 & 2 & 0 \\\\\n", "0 & 0 & 0 & 1\n", "\\end{array}\\right)\\)" ], "text/latex": [ "$\\displaystyle \\left(\\begin{array}{rrrr}\n", "4 & 0 & 0 & 0 \\\\\n", "0 & 3 & 0 & 0 \\\\\n", "0 & 0 & 2 & 0 \\\\\n", "0 & 0 & 0 & 1\n", "\\end{array}\\right)$" ], "text/plain": [ "[4 0 0 0]\n", "[0 3 0 0]\n", "[0 0 2 0]\n", "[0 0 0 1]" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "M.change_of_basis(e,f).matrix(e) # matrix of change of basis e->f" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Matrix of the change of basis f $\\to$ e:" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\\(\\displaystyle \\left(\\begin{array}{rrrr}\n", "\\frac{1}{4} & 0 & 0 & 0 \\\\\n", "0 & \\frac{1}{3} & 0 & 0 \\\\\n", "0 & 0 & \\frac{1}{2} & 0 \\\\\n", "0 & 0 & 0 & 1\n", "\\end{array}\\right)\\)" ], "text/latex": [ "$\\displaystyle \\left(\\begin{array}{rrrr}\n", "\\frac{1}{4} & 0 & 0 & 0 \\\\\n", "0 & \\frac{1}{3} & 0 & 0 \\\\\n", "0 & 0 & \\frac{1}{2} & 0 \\\\\n", "0 & 0 & 0 & 1\n", "\\end{array}\\right)$" ], "text/plain": [ "[1/4 0 0 0]\n", "[ 0 1/3 0 0]\n", "[ 0 0 1/2 0]\n", "[ 0 0 0 1]" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "M.change_of_basis(f,e).matrix(e) # matrix of change of basis f->e" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "\n", "### Endomorphism\n", "\n", "
\n", "\n", "**Endomorphism** of the module M is a general linear transformation M $\\to$ M.\n", "\n", "
\n", "\n", "**Example 6.5**\n", "\n", "Define an endomorphism using arbitrarily chosen matrix." ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\\(\\displaystyle \\Phi\\left(u\\right) = 20 e_{0} + 60 e_{1} + 100 e_{2} + 140 e_{3}\\)" ], "text/latex": [ "$\\displaystyle \\Phi\\left(u\\right) = 20 e_{0} + 60 e_{1} + 100 e_{2} + 140 e_{3}$" ], "text/plain": [ "phi(u) = 20 e_0 + 60 e_1 + 100 e_2 + 140 e_3" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "M = FiniteRankFreeModule(SR,4,name='M') # 4-dim module over SR\n", "e = M.basis('e') # basis e\n", "ma = matrix(4,4,range(16)) # matrix of endomorphism \n", "phi = M.endomorphism(ma, basis=e, # define an endomorphism\n", " name='phi',latex_name=r'\\Phi') # Phi\n", "u = M(range(1,5),name='u'); # vector u\n", "phi(u).disp() # Phi(u)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "\n", "### Using general symbolic matrices\n", "\n", "
\n", "\n", "**Example 6.6**" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To obtain general $N\\times N$ matrices with elements $a_{ij}$ we can use for example the following definition:" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [], "source": [ "aa = [[var('a'+str(i)+str(j)) # 4x4 symbolic matrix is\n", " for j in range(4)] # defined by list of lists\n", " for i in range(4)]" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\\(\\displaystyle \\left[\\left[a_{00}, a_{01}, a_{02}, a_{03}\\right], \\left[a_{10}, a_{11}, a_{12}, a_{13}\\right], \\left[a_{20}, a_{21}, a_{22}, a_{23}\\right], \\left[a_{30}, a_{31}, a_{32}, a_{33}\\right]\\right]\\)" ], "text/latex": [ "$\\displaystyle \\left[\\left[a_{00}, a_{01}, a_{02}, a_{03}\\right], \\left[a_{10}, a_{11}, a_{12}, a_{13}\\right], \\left[a_{20}, a_{21}, a_{22}, a_{23}\\right], \\left[a_{30}, a_{31}, a_{32}, a_{33}\\right]\\right]$" ], "text/plain": [ "[[a00, a01, a02, a03],\n", " [a10, a11, a12, a13],\n", " [a20, a21, a22, a23],\n", " [a30, a31, a32, a33]]" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "aa # list of lists (list of rows)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "General endomorphism of a 4-dimensional module:" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\\(\\displaystyle \\Phi\\left(e_{0}\\right) = a_{00} e_{0} + a_{10} e_{1} + a_{20} e_{2} + a_{30} e_{3}\\)" ], "text/latex": [ "$\\displaystyle \\Phi\\left(e_{0}\\right) = a_{00} e_{0} + a_{10} e_{1} + a_{20} e_{2} + a_{30} e_{3}$" ], "text/plain": [ "phi(e_0) = a00 e_0 + a10 e_1 + a20 e_2 + a30 e_3" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\\(\\displaystyle \\Phi\\left(e_{1}\\right) = a_{01} e_{0} + a_{11} e_{1} + a_{21} e_{2} + a_{31} e_{3}\\)" ], "text/latex": [ "$\\displaystyle \\Phi\\left(e_{1}\\right) = a_{01} e_{0} + a_{11} e_{1} + a_{21} e_{2} + a_{31} e_{3}$" ], "text/plain": [ "phi(e_1) = a01 e_0 + a11 e_1 + a21 e_2 + a31 e_3" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\\(\\displaystyle \\Phi\\left(e_{2}\\right) = a_{02} e_{0} + a_{12} e_{1} + a_{22} e_{2} + a_{32} e_{3}\\)" ], "text/latex": [ "$\\displaystyle \\Phi\\left(e_{2}\\right) = a_{02} e_{0} + a_{12} e_{1} + a_{22} e_{2} + a_{32} e_{3}$" ], "text/plain": [ "phi(e_2) = a02 e_0 + a12 e_1 + a22 e_2 + a32 e_3" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\\(\\displaystyle \\Phi\\left(e_{3}\\right) = a_{03} e_{0} + a_{13} e_{1} + a_{23} e_{2} + a_{33} e_{3}\\)" ], "text/latex": [ "$\\displaystyle \\Phi\\left(e_{3}\\right) = a_{03} e_{0} + a_{13} e_{1} + a_{23} e_{2} + a_{33} e_{3}$" ], "text/plain": [ "phi(e_3) = a03 e_0 + a13 e_1 + a23 e_2 + a33 e_3" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "M = FiniteRankFreeModule(SR,4,name='M') # 4-dim module M over SR \n", "e = M.basis('e') # basis of M\n", "phi = M.endomorphism(aa, basis=e, # define an endomorphism\n", " name='phi',latex_name=r'\\Phi') # using matrix\n", "for k in range(4): # show the values Phi(e_i)\n", " show(phi(e[k]).disp()) \n", "# coefficients of phi(e_k) are taken from \n", "# the k-th column of phi matrix " ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\\(\\displaystyle \\left(\\begin{array}{rrrr}\n", "a_{00} & a_{01} & a_{02} & a_{03} \\\\\n", "a_{10} & a_{11} & a_{12} & a_{13} \\\\\n", "a_{20} & a_{21} & a_{22} & a_{23} \\\\\n", "a_{30} & a_{31} & a_{32} & a_{33}\n", "\\end{array}\\right)\\)" ], "text/latex": [ "$\\displaystyle \\left(\\begin{array}{rrrr}\n", "a_{00} & a_{01} & a_{02} & a_{03} \\\\\n", "a_{10} & a_{11} & a_{12} & a_{13} \\\\\n", "a_{20} & a_{21} & a_{22} & a_{23} \\\\\n", "a_{30} & a_{31} & a_{32} & a_{33}\n", "\\end{array}\\right)$" ], "text/plain": [ "[a00 a01 a02 a03]\n", "[a10 a11 a12 a13]\n", "[a20 a21 a22 a23]\n", "[a30 a31 a32 a33]" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%display latex # matrix of endomorphism\n", "phi.matrix()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "\n", "### Homomorphisms of modules\n", "\n", "
\n", " \n", "The general linear maps between modules M, N are **homomorphisms**.\n", "\n", "A bijective homomorphism is called **isomorphism**.\n", "\n", "
\n", "\n", "**Example 6.7**\n", "\n", "Define two modules and a homomorphism between them." ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\\(\\displaystyle \\mbox{Generic morphism:\n", " From: 4-dimensional vector space M over the Symbolic Ring\n", " To: 2-dimensional vector space N over the Symbolic Ring}\\)" ], "text/latex": [ "$\\displaystyle \\mbox{Generic morphism:\n", " From: 4-dimensional vector space M over the Symbolic Ring\n", " To: 2-dimensional vector space N over the Symbolic Ring}$" ], "text/plain": [ "Generic morphism:\n", " From: 4-dimensional vector space M over the Symbolic Ring\n", " To: 2-dimensional vector space N over the Symbolic Ring" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "M = FiniteRankFreeModule(SR,4,name='M') # 4-dim module M over SR\n", "N = FiniteRankFreeModule(SR,2,name='N') # 2-dim module over SR\n", "e = M.basis('e') # basis of M\n", "f = N.basis('f') # basis of N\n", "ma = matrix(2,4,lambda i,j:i+j) # matrix a_ij=i+j\n", "phi = M.hom(N,ma); phi # define homomorphism\n", " # with matrix ma" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\\(\\displaystyle \\mathrm{Hom}\\left(M,N\\right)\\)" ], "text/latex": [ "$\\displaystyle \\mathrm{Hom}\\left(M,N\\right)$" ], "text/plain": [ "Set of Morphisms from 4-dimensional vector space M over the Symbolic Ring to 2-dimensional vector space N over the Symbolic Ring in Category of finite dimensional vector spaces over Symbolic Ring" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# mathematical object of which \"phi\" is an element\n", "phi.parent()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let us check the additivity property using general vectors V, W." ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\\(\\displaystyle \\mathrm{True}\\)" ], "text/latex": [ "$\\displaystyle \\mathrm{True}$" ], "text/plain": [ "True" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "v = var('v',n=4) #(v0,v1,v2,v3) # components of vector V\n", "w = var('w',n=4) #(w0,w1,w2,w3) # components of vector W\n", "V = M(list(v)) # vector V\n", "W = M(list(w)) # vector W\n", "phi(V+W) == phi(V) + phi(W) # check the additivity" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "\n", "The value of the homomorphism phi on the vector V in the basis of N:" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\\(\\displaystyle \\left( v_{1} + 2 \\, v_{2} + 3 \\, v_{3} \\right) f_{0} + \\left( v_{0} + 2 \\, v_{1} + 3 \\, v_{2} + 4 \\, v_{3} \\right) f_{1}\\)" ], "text/latex": [ "$\\displaystyle \\left( v_{1} + 2 \\, v_{2} + 3 \\, v_{3} \\right) f_{0} + \\left( v_{0} + 2 \\, v_{1} + 3 \\, v_{2} + 4 \\, v_{3} \\right) f_{1}$" ], "text/plain": [ "(v1 + 2*v2 + 3*v3) f_0 + (v0 + 2*v1 + 3*v2 + 4*v3) f_1" ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "phi(V).disp() # phi(V)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The matrix of the homomorphism phi:" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\\(\\displaystyle \\left(\\begin{array}{rrrr}\n", "0 & 1 & 2 & 3 \\\\\n", "1 & 2 & 3 & 4\n", "\\end{array}\\right)\\)" ], "text/latex": [ "$\\displaystyle \\left(\\begin{array}{rrrr}\n", "0 & 1 & 2 & 3 \\\\\n", "1 & 2 & 3 & 4\n", "\\end{array}\\right)$" ], "text/plain": [ "[0 1 2 3]\n", "[1 2 3 4]" ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "phi.matrix() # matrix of homomorphism" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "\n", "### Linear forms on modules. Dual module\n", "\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "By a **linear form** or a linear functional on a module $\\ M\\ $ over $R$ we mean the map\n", "$f:M\\to R$ such that\n", "\n", "$$ f (av + bw ) = af(v) + bf(w ),\\quad\\text{for}\\quad v,w\\in M,\\quad a,b\\in R.$$\n", "\n", "
\n", "\n", "The **dual module $M^*$**\n", "is the module of linear forms on a module $M$.\n", "\n", "
\n", "\n", "**Example 6.8**\n", "\n", "\n", "The module of all linear functionals or linear forms on M in `SageMath Manifold` is `M.dual()`:" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\\(\\displaystyle M^*\\)" ], "text/latex": [ "$\\displaystyle M^*$" ], "text/plain": [ "Dual of the 4-dimensional vector space M over the Symbolic Ring" ] }, "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "M = FiniteRankFreeModule(SR,4,name='M') # 4-dim module over SR\n", "Mstar = M.dual(); Mstar\n", "# Since SR is a field, M is a vector space" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "\n", "### Dual basis\n", "\n", "
\n", "\n", "`SageMath dual.basis` allows to define a **dual basis to a given basis** $\\ \\{e_i\\}_{i=1}^n$, i.e., the set of linear functionals $\\ \\{e^i\\}_{i=1}^n\\ $ such that $\\quad e^i(e_j)=\\delta^i_j.$\n", "\n", "
\n", "\n", "**Example 6.9**\n", "\n", "Define dual basis in `SageMath Manifolds`." ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\\(\\displaystyle \\left(e^{0},e^{1},e^{2},e^{3}\\right)\\)" ], "text/latex": [ "$\\displaystyle \\left(e^{0},e^{1},e^{2},e^{3}\\right)$" ], "text/plain": [ "Dual basis (e^0,e^1,e^2,e^3) on the 4-dimensional vector space M over the Symbolic Ring" ] }, "execution_count": 29, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# continuation\n", "e = M.basis('e'); # basis of M\n", "ep = e.dual_basis(); ep # dual basis" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let us check that $\\quad e^i(e_j)=\\delta^i_j$:" ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\\(\\displaystyle \\left(\\begin{array}{rrrr}\n", "1 & 0 & 0 & 0 \\\\\n", "0 & 1 & 0 & 0 \\\\\n", "0 & 0 & 1 & 0 \\\\\n", "0 & 0 & 0 & 1\n", "\\end{array}\\right)\\)" ], "text/latex": [ "$\\displaystyle \\left(\\begin{array}{rrrr}\n", "1 & 0 & 0 & 0 \\\\\n", "0 & 1 & 0 & 0 \\\\\n", "0 & 0 & 1 & 0 \\\\\n", "0 & 0 & 0 & 1\n", "\\end{array}\\right)$" ], "text/plain": [ "[1 0 0 0]\n", "[0 1 0 0]\n", "[0 0 1 0]\n", "[0 0 0 1]" ] }, "execution_count": 30, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%display latex\n", "matrix(4,4,lambda i,j:ep[i](e[j])) # matrix e^i(e_j)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "\n", "Linear forms on a module M are linear combinations of elements of the dual basis.\n", "\n", "
\n", "\n", "**Example 6.10**\n", "\n", "Define a linear form in `SageMath Manifolds`." ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\\(\\displaystyle a = e^{0} + 2 e^{1} + 3 e^{2} + 4 e^{3}\\)" ], "text/latex": [ "$\\displaystyle a = e^{0} + 2 e^{1} + 3 e^{2} + 4 e^{3}$" ], "text/plain": [ "a = e^0 + 2 e^1 + 3 e^2 + 4 e^3" ] }, "execution_count": 31, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# continuation\n", "a = M.linear_form('a') # linear form a on M \n", "a[:] = 1,2,3,4 # define components of a\n", "a.disp() # show a" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Linear forms are elements of the dual module $M^*$." ] }, { "cell_type": "code", "execution_count": 32, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Dual of the 4-dimensional vector space M over the Symbolic Ring\n" ] } ], "source": [ "# mathematical object of which \"a\" is an element\n", "print(a.parent())" ] }, { "cell_type": "code", "execution_count": 33, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\\(\\displaystyle \\mathrm{True}\\)" ], "text/latex": [ "$\\displaystyle \\mathrm{True}$" ], "text/plain": [ "True" ] }, "execution_count": 33, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Mstar = M.dual()\n", "a.parent() == Mstar # check if parent of a is M dual" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## What's next?\n", "\n", "Take a look at the notebook [Smooth functions and pullbacks](https://nbviewer.org/github/sagemanifolds/IntroToManifolds/blob/main/07Manifold_FunPullb_Curves.ipynb)." ] } ], "metadata": { "kernelspec": { "display_name": "SageMath 9.6", "language": "sage", "name": "sagemath" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.10" } }, "nbformat": 4, "nbformat_minor": 4 }