📚 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="NM">12<title>Sage and Linear Algebra Worksheet</title>13<subtitle>FCLA Section NM</subtitle>1415<!-- header inclusion needs -xinclude switch on xsltproc -->16<frontmatter>17<xi:include href="../header.xml" />18</frontmatter>192021<p>First, a guaranteed nonsingular <m>5\times 5</m> matrix, created at random.</p>2223<sage>24<input>25A = random_matrix(QQ, 5, algorithm="unimodular", upper_bound=20)26A27</input>28</sage>2930<exercise>31<statement>32<p>Augment with the zero vector, using the matrix method <c>.augment()</c> and the vector constructor <c>zero_vector(QQ, 5)</c>. Then row-reduce to use Definition NM. Or instead, do not augment and apply Theorem NMRRI.</p>33</statement>34</exercise>3536<sage />3738<exercise>39<statement>40<p>Build some random vectors with <c>random_vector(QQ, 5)</c>, augment the matrix and row-reduce. There will always be a unique solution to the linear system represented by the augmented matrix. This is Theorem NMUS.</p>41</statement>42</exercise>4344<sage />4546<p>Instead<mdash />cheap, easy and powerful:</p>4748<sage>49<input>A.is_singular()</input>50</sage>5152<p>Now, a carefully crafted singular matrix.</p>5354<sage>55<input>56B = matrix(QQ, [[ 7, -1, -12, 21, -8],57[-3, 3, 0, -9, 6],58[ 3, 3, -12, 9, 0],59[ 2, 3, -10, 6, 1],60[-2, 2, 0, -6, 4]])61B62</input>63</sage>6465<exercise>66<statement>67<p>Augment with the zero vector and row-reduce (Definition NM), or don't augment and row-reduce (Theorem NMRRI).]</p>68</statement>69</exercise>7071<sage />7273<exercise>74<statement>75<p>A random vector of constants will only rarely build a consistent system when paired with <c>B</c>. Try it. But this is not a theorem, see the vector <c>c</c> below.</p>76</statement>77</exercise>7879<sage />8081<p>Instead<mdash />cheap, easy and powerful:</p>8283<sage>84<input>B.is_singular()</input>85</sage>8687<p>Two carefully crafted vectors for linear systems with <c>B</c> as coefficient matrix.</p>8889<sage>90<input>91c = vector(QQ, [17,-15,-3,-5,-10])92d = vector(QQ, [-3,1,-2,1,2])93</input>94</sage>9596<exercise>97<statement>98<p>Which of these two column vectors will create a consistent system for this singular coefficient matrix? (Stay tuned.)</p>99</statement>100</exercise>101102<sage />103104<p>A null space is called a <term>right kernel</term> in Sage. It's description contains a lot of things we do not understand yet.</p>105106<sage>107<input>108NS = B.right_kernel()109NS110</input>111</sage>112113<exercise>114<statement>115<p>But we can test membership in the null space, which is the most basic property of a set. Try <c>u in NS</c> and then repeat with <c>v</c>.</p>116</statement>117</exercise>118119<sage>120<input>u = vector(QQ, [0,0,3,4,6])</input>121</sage>122123<sage />124125<sage>126<input>v = vector(QQ, [1,0,0,5,-2])</input>127</sage>128129<sage />130131<xi:include href="../legal.xml" />132133</article>134135</pretext>136137138