Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132939 views
License: OTHER
1
<?xml version="1.0" encoding="UTF-8" ?>
2
3
<!-- Sage and Linear Algebra Worksheets -->
4
<!-- Robert A. Beezer -->
5
<!-- Copyright 2017-2019 License: CC BY-SA -->
6
<!-- See COPYING for more information -->
7
8
<pretext xmlns:xi="http://www.w3.org/2001/XInclude">
9
10
<xi:include href="../worksheetinfo.xml" />
11
12
<article xml:id="FS">
13
<title>Sage and Linear Algebra Worksheet</title>
14
<subtitle>FCLA Section FS</subtitle>
15
16
<!-- header inclusion needs -xinclude switch on xsltproc -->
17
<frontmatter>
18
<xi:include href="../header.xml" />
19
</frontmatter>
20
21
<section>
22
<title>Four Subsets</title>
23
24
<p><c>A</c> is an <m>8\times 10</m> matrix.</p>
25
26
<sage><input>
27
A = matrix(QQ,
28
[[194, -41, -899, -396, 49, 112, 874, -355, 1139, -1221],
29
[269, -57, -1247, -549, 68, 155, 1212, -492, 1579, -1693],
30
[16, -3, -73, -33, 4, 10, 72, -30, 95, -101],
31
[115, -24, -532, -235, 29, 67, 518, -211, 676, -724],
32
[ 10, 1, -37, -23, 2, 12, 44, -24, 67, -65],
33
[-59, 13, 275, 120, -15, -33, -266, 107, -345, 371],
34
[ 36, -7, -165, -74, 9, 22, 162, -67, 213, -227],
35
[-20, 4, 92, 41, -5, -12, -90, 37, -118, 126]])
36
A
37
</input></sage>
38
39
<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>
40
41
<sage><input>
42
N = A.extended_echelon_form(subdivide=True)
43
N
44
</input></sage>
45
46
47
<sage><input>
48
C = N.subdivision(0,0)
49
Z = N.subdivision(1,0)
50
K = N.subdivision(0,1)
51
L = N.subdivision(1,1)
52
</input></sage>
53
54
<p>And build two bigger pieces.</p>
55
56
<sage><input>
57
B = C.stack(Z)
58
J = K.stack(L)
59
</input></sage>
60
61
<sage><input>
62
B
63
</input></sage>
64
65
<sage><input>
66
J
67
</input></sage>
68
69
<exercise>
70
<statement>
71
<p>Verify some of the properties of these matrices, as given in Theorem PEEF.<ol>
72
<li>Is <c>J</c> nonsingular?</li>
73
<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>
74
</ol></p>
75
</statement>
76
</exercise>
77
78
<sage />
79
80
<sage />
81
82
<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>
83
84
<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>
85
86
<exercise>
87
<statement>
88
<p>Illustrate the previous discussion with a random choice of the vector <c>b</c> from the null space of <c>L</c>.</p>
89
</statement>
90
</exercise>
91
92
<sage><input>
93
NL = L.right_kernel(basis='pivot')
94
NL
95
</input></sage>
96
97
<p>We create an arbitrary element of the null space of <c>L</c> with a linear combination.</p>
98
99
<sage><input>
100
NLbasis = NL.basis()
101
</input></sage>
102
103
<sage><input>
104
b = *NLbasis[0] + *NLbasis[1] + *NLbasis[2]
105
b
106
</input></sage>
107
108
<p><c>b</c> will create a consistent system with <c>A</c> as coefficient matrix.</p>
109
110
<sage><input>
111
P = A.augment(b, subdivide=True)
112
P.rref()
113
</input></sage>
114
115
<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>
116
117
<sage><input>
118
CA = A.column_space()
119
CA
120
</input></sage>
121
122
<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>
123
124
<sage><input>
125
b in CA
126
</input></sage>
127
128
<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>
129
130
<sage><input>
131
NL.echelonized_basis()
132
</input></sage>
133
134
<sage><input>
135
CA == NL
136
</input></sage>
137
</section>
138
139
<xi:include href="../legal.xml" />
140
141
</article>
142
</pretext>
143
144