📚 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="SS">12<title>Sage and Linear Algebra Worksheet</title>13<subtitle>FCLA Section SS</subtitle>1415<!-- header inclusion needs -xinclude switch on xsltproc -->16<frontmatter>17<xi:include href="../header.xml" />18</frontmatter>192021<section>22<title>Vector Spaces</title>2324<p>It is easy in Sage to make a reasonable facsimile of <m>\mathbf{C}^n</m>. We just restrict our attention to rational entries rather than complex entries. This vector space contains vectors with 4 slots, each filled with a rational number.</p>2526<sage>27<input>28V = QQ^429V30</input>31</sage>3233<exercise>34<statement>35<p>We can test membership using the word/command <c>in</c>. Try vectors with different numers of slots, and perhaps include the complex number <c>2 + 3*I</c> as an entry.</p>36</statement>37</exercise>3839<sage />4041</section>4243<section>44<title>Vector Form of Solutions to Homogeneous Systems</title>4546<p>These are the coefficient matrix and vector of constants from yesterday's big system that led to a colored matrix in reduced row-echelon form.</p>4748<p>The <c>.right_kernel()</c> method will give the vectors of the vector form of the solutions to a homogeneous system when used with the <c>basis='pivot'</c> option.</p>4950<sage>51<input>52A = matrix(QQ, [[ 1, 2, 12, 1, 13, 5, 2],53[ -2, -3, -21, 0, -13, 2, -5],54[ 1, 3, 15, 4, 28, 25, 0],55[ -2, -3, -21, -1, -15, -6, -3],56[ 1, 1, 9, 1, 4, 9, 1]])57b = vector(QQ, [8, -15, 7, -10, 3])58</input>59</sage>6061<sage>62<input>A.right_kernel(basis='pivot')</input>63</sage>6465<p>Rows of the <q>basis matrix</q> are vectors in yesterday's linear combination (with scalars <m>x_3</m>, <m>x_5</m>, <m>x_6</m>). This is a spanning set for the null space of the matrix <m>A</m>. See Theorem VFSLS and Theorem SSNS.</p>6667<p>Theorem PSPHS can explain how to use a single solution to the non-homogeneous system and the spanning set of the null space of the coefficient matrix to arrive at all solutions to the system. Here is a single solution to the system.</p>6869<sage>70<input>A.solve_right(b)</input>71</sage>7273<p>Notice that this vector is the solution when we set each free variable to zero, which is the <q>other</q> vector from yesterday that is not part of the linear combination.</p>74</section>7576<section>77<title>Spanning Sets</title>7879<p>Example ABS from FCLA.</p>8081<sage>82<input>83x1 = vector(QQ,[1,1,3,1])84x2 = vector(QQ,[2,1,2,-1])85x3 = vector(QQ,[7,3,5,-5])86x4 = vector(QQ,[1,1,-1,2])87x5 = vector(QQ,[-1,0,9,0])88W = span([x1, x2, x3, x4, x5])89W90</input>91</sage>9293<exercise>94<statement>95<p>Make a <q>random</q> linear combination of the five vectors and test for membership (which will be trivially true, repeatedly). Remember to use the <c>*</c> operator for vector scalar multiplication.</p>96</statement>97</exercise>9899<sage />100101<p>But not any old vector is in <m>W</m>.</p>102103<sage>104<input>105v = vector(QQ, [1, 1, -3, 2])106v in W107</input>108</sage>109110<p>It should make sense that arbitrary linear combinations are in the span. How did we manufacture a vector <em>not</em> in the span? Stay tuned.</p>111</section>112113<xi:include href="../legal.xml" />114115</article>116</pretext>117118119