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="IVLT">
13
<title>Sage and Linear Algebra Worksheet</title>
14
<subtitle>FCLA Section IVLT</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>Invertible Linear Transformations</title>
23
24
<p>A carefully-crafted invertible linear transformation from <m>\mathbb{Q}^5</m> to <m>\mathbb{Q}^5</m>.</p>
25
26
<sage><input>
27
A = matrix(QQ, [[1, 1, -1, -2, 0], [-3, -2, 1, 4, 7],
28
[2, 2, -1, -3, -4], [-4, -3, 3, 8, 3], [5, 6, -7, -8, 8]])
29
T = linear_transformation(QQ^5, QQ^5, A, side='right')
30
T
31
</input></sage>
32
33
<sage><input>
34
T.is_injective(), T.is_surjective()
35
</input></sage>
36
37
<sage><input>
38
T.is_invertible()
39
</input></sage>
40
41
<sage><input>
42
S = T.inverse()
43
S
44
</input></sage>
45
46
<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>
47
48
<sage><input>
49
comp = S*T
50
comp
51
</input></sage>
52
53
<sage><input>
54
comp.is_identity()
55
</input></sage>
56
</section>
57
58
<section>
59
<title>Defining an Invertible Linear Transformation on Bases</title>
60
61
<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>
62
63
<sage><input>
64
C = random_matrix(QQ, 7, 7, algorithm='unimodular', upper_bound=99)
65
Cbasis = C.columns()
66
D = random_matrix(QQ, 7, 7, algorithm='unimodular', upper_bound=99)
67
Dbasis = D.columns()
68
</input></sage>
69
70
<p>Vector spaces with defined user bases.</p>
71
72
<sage><input>
73
Cspace = (QQ^7).subspace_with_basis(Cbasis)
74
Dspace = (QQ^7).subspace_with_basis(Dbasis)
75
Cspace, Dspace
76
</input></sage>
77
78
<p>The invertible linear transformation defined with images as the vectors in the codomain basis <c>D</c>.</p>
79
80
<sage><input>
81
T = linear_transformation(Cspace, QQ^7, Dbasis)
82
T
83
</input></sage>
84
85
<sage><input>
86
T.is_invertible()
87
</input></sage>
88
89
<p>Now we simply <q>turn around</q> the definition, to make the inverse.</p>
90
91
<sage><input>
92
S = linear_transformation(Dspace, QQ^7, Cbasis)
93
S
94
</input></sage>
95
96
<sage><input>
97
S.is_invertible()
98
</input></sage>
99
100
<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>
101
102
<sage><input>
103
comp = S*T
104
comp.is_identity()
105
</input></sage>
106
107
<sage><input>
108
v = random_vector(QQ, 7)
109
v, T(S(v)) == v, S(T(v)) == v
110
</input></sage>
111
</section>
112
113
<section>
114
<title>Rank and Nullity</title>
115
116
<p>A general (<ie /> not invertible) linear transformation from <m>\mathbb{Q}^6</m> to <m>\mathbb{Q}^5</m>.</p>
117
118
<sage><input>
119
F = matrix(QQ, [[1, 0, 2, -1, -4, 2], [-1, -1, -4, 3, 6, -5], [0, 1, 3, -2, -4, 5],
120
[0, 4, 6, -8, -4, 8], [0, 1, 2, -2, -2, 3]])
121
R = linear_transformation(QQ^6, QQ^5, F, side='right')
122
R
123
</input></sage>
124
125
<p>Rank is dimension of range (image). Note there are not left/right variants.</p>
126
127
<sage><input>
128
R.image()
129
</input></sage>
130
131
<sage><input>
132
R.rank()
133
</input></sage>
134
135
<p>Nullity is dimension of kernel. Note there are not left/right variants.</p>
136
137
<sage><input>
138
R.kernel()
139
</input></sage>
140
141
<sage><input>
142
R.nullity()
143
</input></sage>
144
145
<p>Note that rank and nullity sum to the dimension of the domain (which is <m>6</m> here).</p>
146
</section>
147
148
<xi:include href="../legal.xml" />
149
150
</article>
151
</pretext>
152
153