📚 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="SLT">12<title>Sage and Linear Algebra Worksheet</title>13<subtitle>FCLA Section SLT</subtitle>1415<!-- header inclusion needs -xinclude switch on xsltproc -->16<frontmatter>17<xi:include href="../header.xml" />18</frontmatter>1920<section>21<title>Surjective Linear Transformations</title>2223<p>Two carefully-crafted linear transformations: <c>T</c> is surjective, <c>S</c> is not.</p>2425<sage><input>26A = matrix(QQ, [[2, 2, 5, -2], [2, 3, 1, -4], [-3, -4, -4, 5]])27T = linear_transformation(QQ^4, QQ^3, A, side='right')28</input></sage>2930<sage><input>31T.is_surjective()32</input></sage>3334<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>3536<sage><input>37T.image()38</input></sage>3940<sage><input>41T.image() == T.codomain()42</input></sage>4344<sage><input>45B = matrix(QQ, [[1, -2, 0, 3], [3, -5, 1, 7], [-1, 4, 2, -7]])46S = linear_transformation(QQ^4, QQ^3, B, side='right')47</input></sage>4849<sage><input>50S.is_surjective()51</input></sage>5253<sage><input>54IM = S.image()55IM56</input></sage>5758<sage><input>59IM == S.codomain()60</input></sage>61</section>6263<section>64<title>Pre-Images</title>6566<exercise>67<statement>68<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>69</statement>70</exercise>7172<sage><input>73bas = IM.basis()74out = ()*bas[0] + ()*bas[1]75inp = S.preimage_representative(out)76out, inp77</input></sage>7879<p>A check on our work.</p>8081<sage><input>82S(inp)83</input></sage>8485<exercise>86<statement>87<p>We can make other inputs, using the kernel.</p>8889<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>90</statement>91</exercise>9293<sage><input>94K = S.kernel()95K96</input></sage>9798<sage><input>99z = K.random_element()100new_inp = inp + z101new_inp, S(new_inp)102</input></sage>103104<exercise>105<statement>106<p>Elements outside the range (image) will have empty preimages. We mildly <q>wreck</q> an element of the range.</p>107108<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>109</statement>110</exercise>111112<sage><input>113in_range = ()*bas[0] + ()*bas[1]114in_range115</input></sage>116117<sage><input>118outside_range = vector(QQ, [ , , ])119S.preimage_representative(outside_range)120</input></sage>121</section>122123<xi:include href="../legal.xml" />124125</article>126</pretext>127128129