Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132935 views
License: OTHER
%auto %html(hide=True) <div class="mathbook-content"> <link rel="stylesheet" type="text/css" href="http://buzzard.ups.edu/mathbook-content.css"> <link rel="stylesheet" type="text/css" href="https://aimath.org/mathbook/mathbook-add-on.css"> </div>
%auto %html(hide=True) <div class="mathbook-content"><div class="hidden-content" style="display:none">\( \newcommand{\lt}{&lt;} \newcommand{\gt}{&gt;} \newcommand{\amp}{&amp;} \)</div></div>
%auto %html(hide=True) <div class="mathbook-content"><table width="90%" style="font-size: 200%;"><tr></tr></table></div>
%auto %html(hide=True) <div class="mathbook-content"><section class="article" id="MR"></section></div>
%auto %html(hide=True) <div class="mathbook-content"><section class="frontmatter" id="frontmatter-1"></section></div>
%auto %html(hide=True) <div class="mathbook-content"> <h2 class="heading"> <span class="title">Sage and Linear Algebra Worksheet:</span> <span class="subtitle">FCLA Section MR</span> </h2> <div class="author"> <div class="author-name">Robert Beezer</div> <div class="author-info">Department of Mathematics and Computer Science<br>University of Puget Sound</div> </div> <div class="date">Fall 2019</div> </div>
%auto %html(hide=True) <div class="mathbook-content"><section class="section" id="section-1"><h6 class="heading hide-type"> <span class="type">Section</span> <span class="codenumber">1</span> <span class="title">A Linear Transformation and some Bases</span> </h6></section></div>
%auto %html(hide=True) <div class="mathbook-content"><p id="p-1">In this section we define a linear transformation from \(\mathbb{C}^6\) to \(\mathbb{C}^4\text{.}\) The definition is a \(4\times 6\) matrix of rank \(4\) that we will use to multiply input vectors with a matrix-vector product. It is not important if the linear transformation is injective and/or surjective.</p></div>
m, n = 4, 6 A = random_matrix(QQ, m, n, algorithm='echelonizable', rank=m, upper_bound=9) A
T = linear_transformation(A, side='right') T
%auto %html(hide=True) <div class="mathbook-content"><p id="p-2">And we construct two random bases, one for the domain and one for the codomain, extracted from the columns of unimodular matrices.</p></div>
Dmat = random_matrix(QQ, n, n, algorithm='unimodular', upper_bound=9) D = Dmat.columns() D
Cmat = random_matrix(QQ, m, m, algorithm='unimodular', upper_bound=9) C = Cmat.columns() C
%auto %html(hide=True) <div class="mathbook-content"><section class="section" id="section-2"><h6 class="heading hide-type"> <span class="type">Section</span> <span class="codenumber">2</span> <span class="title">A Matrix Representation, Old Style</span> </h6></section></div>
%auto %html(hide=True) <div class="mathbook-content"><p id="p-3">We will coordinatize the outputs of the linear transformation, for inputs from the basis of the domain, relative to the basis of the codomain, and pack them in a matrix.</p></div>
%auto %html(hide=True) <div class="mathbook-content"><p id="p-4">Outputs on the domain basis first.</p></div>
outputs = [T(b) for b in D] outputs
%auto %html(hide=True) <div class="mathbook-content"><p id="p-5">We make a vector space for the codomain, with the desired basis.</p></div>
VC = (QQ^m).subspace_with_basis(C) VC
%auto %html(hide=True) <div class="mathbook-content"><p id="p-6">Now, coordinate versions of the outputs.</p></div>
coord = [VC.coordinate_vector(t) for t in outputs] coord
%auto %html(hide=True) <div class="mathbook-content"><p id="p-7">And then we pack them into a matrix.</p></div>
rep = column_matrix(coord) rep
%auto %html(hide=True) <div class="mathbook-content"><p id="p-8">Does the representation “work” as it should? We need a vector space for the domain before we can check.</p></div>
VD = (QQ^n).subspace_with_basis(D) VD
%auto %html(hide=True) <div class="mathbook-content"><p id="p-9">OK, coordinatize input, multiply by representation matrix, un-coordinatize (linear combination). This is the fundamental Theorem FTMR at work.</p></div>
u = random_vector(QQ, 6) out = VC.linear_combination_of_basis(rep*VD.coordinate_vector(u)) u, out, T(u) == out
%auto %html(hide=True) <div class="mathbook-content"><p id="p-10">Nice.</p></div>
%auto %html(hide=True) <div class="mathbook-content"><section class="section" id="section-3"><h6 class="heading hide-type"> <span class="type">Section</span> <span class="codenumber">3</span> <span class="title">A Matrix Representation, Sage Style</span> </h6></section></div>
%auto %html(hide=True) <div class="mathbook-content"><p id="p-11">Now we do it Sage style. The matrix of the linear transformation first, as we like to see it.</p></div>
T.matrix(side='right')
%auto %html(hide=True) <div class="mathbook-content"><p id="p-12">Now we replace the domain and codomain with new vector spaces, carrying different bases. We are not really “restricting” the domain and codomain, we are replacing them by the same vector space, but each has a different basis.</p></div>
S = T.restrict_domain(VD).restrict_codomain(VC) rep2 = S.matrix(side='right') rep2
%auto %html(hide=True) <div class="mathbook-content"><p id="p-13">Bingo! This is representation we found above. A one-liner in Sage.</p></div>
rep2 == rep
%auto %html(hide=True) <div class="mathbook-content"><section class="section" id="section-4"><h6 class="heading hide-type"> <span class="type">Section</span> <span class="codenumber">4</span> <span class="title">Sneak Preview</span> </h6></section></div>
%auto %html(hide=True) <div class="mathbook-content"><p id="p-14">Ponder the following computation — matrix representations and nonsingular matrices with columns from the two bases.</p></div>
S.matrix(side='right') - Cmat.inverse()*T.matrix(side='right')*Dmat
%auto %html(hide=True) <div class="mathbook-content"><p id="p-15">Notice how Sage is conflicted about if <code class="code-inline tex2jax_ignore">S</code> and <code class="code-inline tex2jax_ignore">T</code> are equal or not.</p></div>
S == T
S.is_equal_function(T)
%auto %html(hide=True) <div class="mathbook-content"><article class="conclusion" id="conclusion-1"><h5 class="heading"><span></span></h5></article></div>
%auto %html(hide=True) <div class="mathbook-content"><p id="p-16">This work is Copyright 2016–2019 by Robert A. Beezer. It is licensed under a <a class="external" href="https://creativecommons.org/licenses/by-sa/4.0/" target="_blank">Creative Commons Attribution-ShareAlike 4.0 International License</a>.</p></div>
%auto %html(hide=True) <div class="mathbook-content"><table width="90%" style="font-size: 200%;"><tr></tr></table></div>