📚 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="FS">12<title>Sage and Linear Algebra Worksheet</title>13<subtitle>FCLA Section FS</subtitle>1415<!-- header inclusion needs -xinclude switch on xsltproc -->16<frontmatter>17<xi:include href="../header.xml" />18</frontmatter>1920<section>21<title>Four Subsets</title>2223<p><c>A</c> is an <m>8\times 10</m> matrix.</p>2425<sage><input>26A = matrix(QQ,27[[194, -41, -899, -396, 49, 112, 874, -355, 1139, -1221],28[269, -57, -1247, -549, 68, 155, 1212, -492, 1579, -1693],29[16, -3, -73, -33, 4, 10, 72, -30, 95, -101],30[115, -24, -532, -235, 29, 67, 518, -211, 676, -724],31[ 10, 1, -37, -23, 2, 12, 44, -24, 67, -65],32[-59, 13, 275, 120, -15, -33, -266, 107, -345, 371],33[ 36, -7, -165, -74, 9, 22, 162, -67, 213, -227],34[-20, 4, 92, 41, -5, -12, -90, 37, -118, 126]])35A36</input></sage>3738<p>We get the extended echelon form, along with the natural subdivisions into four submatrices. We unpack the four submatrices, and stack them in pairs to also get the left and right portions.</p>3940<sage><input>41N = A.extended_echelon_form(subdivide=True)42N43</input></sage>444546<sage><input>47C = N.subdivision(0,0)48Z = N.subdivision(1,0)49K = N.subdivision(0,1)50L = N.subdivision(1,1)51</input></sage>5253<p>And build two bigger pieces.</p>5455<sage><input>56B = C.stack(Z)57J = K.stack(L)58</input></sage>5960<sage><input>61B62</input></sage>6364<sage><input>65J66</input></sage>6768<exercise>69<statement>70<p>Verify some of the properties of these matrices, as given in Theorem PEEF.<ol>71<li>Is <c>J</c> nonsingular?</li>72<li>How are <c>A</c>, <c>B</c>, and <c>J</c> related? Observe that the matrix <c>J</c> effectively reproduces the net effect of a sequence of row operations that converts <c>A</c> to <c>B</c>.</li>73</ol></p>74</statement>75</exercise>7677<sage />7879<sage />8081<p>Imagine the equation in the last part of the exercise, but instead replace <m>A</m> by an augmented matrix of a linear system with a vector of constants <c>b</c>. The row operations that convert <c>A</c> to <c>B</c>, will also act on the vector of constants. Will the result be a pivot column (an inconsistent system) or a vector with zeros in all of the same rows as the zero rows of <c>B</c>? Equivalent question: is the vector of constants outside the column space, or within the column space?</p>8283<p>The answer to the first question is that the zeros will occur in the proper entries to avoid a pivot column exactly if <c>b</c> is in the null space of the matrix <c>L</c>. So consistent systems come from the vectors in the null space of <c>L</c>, and by Theorem CSCS, we know this set of vectors is also the column space.</p>8485<exercise>86<statement>87<p>Illustrate the previous discussion with a random choice of the vector <c>b</c> from the null space of <c>L</c>.</p>88</statement>89</exercise>9091<sage><input>92NL = L.right_kernel(basis='pivot')93NL94</input></sage>9596<p>We create an arbitrary element of the null space of <c>L</c> with a linear combination.</p>9798<sage><input>99NLbasis = NL.basis()100</input></sage>101102<sage><input>103b = *NLbasis[0] + *NLbasis[1] + *NLbasis[2]104b105</input></sage>106107<p><c>b</c> will create a consistent system with <c>A</c> as coefficient matrix.</p>108109<sage><input>110P = A.augment(b, subdivide=True)111P.rref()112</input></sage>113114<p>The column space of <c>A</c> is equal to the null space of <c>L</c>. This is part of Theorem FS.</p>115116<sage><input>117CA = A.column_space()118CA119</input></sage>120121<p>Since the vector <c>b</c> leads to a consistent system, we know it is in the column space of <c>A</c>. But we can check with Sage.</p>122123<sage><input>124b in CA125</input></sage>126127<p>Sage relies on <term>echelonized bases</term> to represent infinite sets of vectors and to be able to test vector space equality (which seems pretty amazing at first!).</p>128129<sage><input>130NL.echelonized_basis()131</input></sage>132133<sage><input>134CA == NL135</input></sage>136</section>137138<xi:include href="../legal.xml" />139140</article>141</pretext>142143144