📚 The CoCalc Library - books, templates and other resources
License: OTHER
<?xml version="1.0" encoding="UTF-8" ?>12<!-- Sage and Linear Algebra Worksheets -->3<!-- Robert A. Beezer -->4<!-- Copyright 2017-2019 License: CC BY-SA -->5<!-- See COPYING for more information -->67<pretext xmlns:xi="http://www.w3.org/2001/XInclude">89<xi:include href="../worksheetinfo.xml" />1011<article xml:id="IVLT">12<title>Sage and Linear Algebra Worksheet</title>13<subtitle>FCLA Section IVLT</subtitle>1415<!-- header inclusion needs -xinclude switch on xsltproc -->16<frontmatter>17<xi:include href="../header.xml" />18</frontmatter>1920<section>21<title>Invertible Linear Transformations</title>2223<p>A carefully-crafted invertible linear transformation from <m>\mathbb{Q}^5</m> to <m>\mathbb{Q}^5</m>.</p>2425<sage><input>26A = matrix(QQ, [[1, 1, -1, -2, 0], [-3, -2, 1, 4, 7],27[2, 2, -1, -3, -4], [-4, -3, 3, 8, 3], [5, 6, -7, -8, 8]])28T = linear_transformation(QQ^5, QQ^5, A, side='right')29T30</input></sage>3132<sage><input>33T.is_injective(), T.is_surjective()34</input></sage>3536<sage><input>37T.is_invertible()38</input></sage>3940<sage><input>41S = T.inverse()42S43</input></sage>4445<p>The <c>*</c> operator, like we would use for multiplication, will create a composition. This will be perfectly natural once we discuss Section MR. Here, composing an invertible linear transformation with its inverse will yield an identity linear transformation.</p>4647<sage><input>48comp = S*T49comp50</input></sage>5152<sage><input>53comp.is_identity()54</input></sage>55</section>5657<section>58<title>Defining an Invertible Linear Transformation on Bases</title>5960<p>Now, an invertible linear transformation defined on a basis, and the resulting inverse linear transformation. We get two <q>random</q> bases of <m>\mathbb{Q}^7</m> from nonsingular (determinant one) matrices.</p>6162<sage><input>63C = random_matrix(QQ, 7, 7, algorithm='unimodular', upper_bound=99)64Cbasis = C.columns()65D = random_matrix(QQ, 7, 7, algorithm='unimodular', upper_bound=99)66Dbasis = D.columns()67</input></sage>6869<p>Vector spaces with defined user bases.</p>7071<sage><input>72Cspace = (QQ^7).subspace_with_basis(Cbasis)73Dspace = (QQ^7).subspace_with_basis(Dbasis)74Cspace, Dspace75</input></sage>7677<p>The invertible linear transformation defined with images as the vectors in the codomain basis <c>D</c>.</p>7879<sage><input>80T = linear_transformation(Cspace, QQ^7, Dbasis)81T82</input></sage>8384<sage><input>85T.is_invertible()86</input></sage>8788<p>Now we simply <q>turn around</q> the definition, to make the inverse.</p>8990<sage><input>91S = linear_transformation(Dspace, QQ^7, Cbasis)92S93</input></sage>9495<sage><input>96S.is_invertible()97</input></sage>9899<p>Composition with vector spaces using different bases does not seem to be working properly. So we just check some random inputs to the composition.</p>100101<sage><input>102comp = S*T103comp.is_identity()104</input></sage>105106<sage><input>107v = random_vector(QQ, 7)108v, T(S(v)) == v, S(T(v)) == v109</input></sage>110</section>111112<section>113<title>Rank and Nullity</title>114115<p>A general (<ie /> not invertible) linear transformation from <m>\mathbb{Q}^6</m> to <m>\mathbb{Q}^5</m>.</p>116117<sage><input>118F = matrix(QQ, [[1, 0, 2, -1, -4, 2], [-1, -1, -4, 3, 6, -5], [0, 1, 3, -2, -4, 5],119[0, 4, 6, -8, -4, 8], [0, 1, 2, -2, -2, 3]])120R = linear_transformation(QQ^6, QQ^5, F, side='right')121R122</input></sage>123124<p>Rank is dimension of range (image). Note there are not left/right variants.</p>125126<sage><input>127R.image()128</input></sage>129130<sage><input>131R.rank()132</input></sage>133134<p>Nullity is dimension of kernel. Note there are not left/right variants.</p>135136<sage><input>137R.kernel()138</input></sage>139140<sage><input>141R.nullity()142</input></sage>143144<p>Note that rank and nullity sum to the dimension of the domain (which is <m>6</m> here).</p>145</section>146147<xi:include href="../legal.xml" />148149</article>150</pretext>151152153