Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132935 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="SLT">
13
<title>Sage and Linear Algebra Worksheet</title>
14
<subtitle>FCLA Section SLT</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>Surjective Linear Transformations</title>
23
24
<p>Two carefully-crafted linear transformations: <c>T</c> is surjective, <c>S</c> is not.</p>
25
26
<sage><input>
27
A = matrix(QQ, [[2, 2, 5, -2], [2, 3, 1, -4], [-3, -4, -4, 5]])
28
T = linear_transformation(QQ^4, QQ^3, A, side='right')
29
</input></sage>
30
31
<sage><input>
32
T.is_surjective()
33
</input></sage>
34
35
<p>The range is known in Sage as the <q>image.</q> For a surjective linear transformation, it will be the entire codomain. Note that the image is a vector space.</p>
36
37
<sage><input>
38
T.image()
39
</input></sage>
40
41
<sage><input>
42
T.image() == T.codomain()
43
</input></sage>
44
45
<sage><input>
46
B = matrix(QQ, [[1, -2, 0, 3], [3, -5, 1, 7], [-1, 4, 2, -7]])
47
S = linear_transformation(QQ^4, QQ^3, B, side='right')
48
</input></sage>
49
50
<sage><input>
51
S.is_surjective()
52
</input></sage>
53
54
<sage><input>
55
IM = S.image()
56
IM
57
</input></sage>
58
59
<sage><input>
60
IM == S.codomain()
61
</input></sage>
62
</section>
63
64
<section>
65
<title>Pre-Images</title>
66
67
<exercise>
68
<statement>
69
<p>We can create inputs associated with any output. First, we make an arbitrary output, but make sure it really is an output, as a linear combination of a basis of the image (see basis above). We print the two vectors in the opposite of what we would consider the <q>normal</q> order.</p>
70
</statement>
71
</exercise>
72
73
<sage><input>
74
bas = IM.basis()
75
out = ()*bas[0] + ()*bas[1]
76
inp = S.preimage_representative(out)
77
out, inp
78
</input></sage>
79
80
<p>A check on our work.</p>
81
82
<sage><input>
83
S(inp)
84
</input></sage>
85
86
<exercise>
87
<statement>
88
<p>We can make other inputs, using the kernel.</p>
89
90
<p>Any value of <c>new_inp</c> is in the preimage of <c>out</c>, and every element of the preimage can be built this way. Notice the role the kernel plays, much like in the worksheet about injective linear transformations.</p>
91
</statement>
92
</exercise>
93
94
<sage><input>
95
K = S.kernel()
96
K
97
</input></sage>
98
99
<sage><input>
100
z = K.random_element()
101
new_inp = inp + z
102
new_inp, S(new_inp)
103
</input></sage>
104
105
<exercise>
106
<statement>
107
<p>Elements outside the range (image) will have empty preimages. We mildly <q>wreck</q> an element of the range.</p>
108
109
<p>With two initial entries determined by the zeros and ones in the basis vectors, the third entry must be determined, so we can <q>twiddle</q> it just a bit to obtain a vector of the codomain that lies outside the range. We will ask Sage for a pre-image representative anyway and see what happens.</p>
110
</statement>
111
</exercise>
112
113
<sage><input>
114
in_range = ()*bas[0] + ()*bas[1]
115
in_range
116
</input></sage>
117
118
<sage><input>
119
outside_range = vector(QQ, [ , , ])
120
S.preimage_representative(outside_range)
121
</input></sage>
122
</section>
123
124
<xi:include href="../legal.xml" />
125
126
</article>
127
</pretext>
128
129