đ The CoCalc Library - books, templates and other resources
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}{<} \newcommand{\gt}{>} \newcommand{\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="VR"></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 VR</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">Vector Representations</span> </h6></section></div>
%auto %html(hide=True) <div class="mathbook-content"><p id="p-1">It is easy to form vector representations of vectors in \(\mathbb{C}^n\text{.}\)</p></div>
%auto %html(hide=True) <div class="mathbook-content"><p id="p-2">We get a nonstandard basis quickly from the columns of a nonsingular matrix. The keyword <code class="code-inline tex2jax_ignore">algorithm='unimodular'</code> requests a matrix with determinant \(1\text{.}\)</p></div>
n = 6 A = random_matrix(QQ, n, algorithm='unimodular', upper_bound=9) A
%auto %html(hide=True) <div class="mathbook-content"><p id="p-3">The columns of <code class="code-inline tex2jax_ignore">A</code> become the âuser basisâ of a vector space.</p></div>
B = A.columns() V = (QQ^n).subspace_with_basis(B) V
u = random_vector(QQ, n) u
%auto %html(hide=True) <div class="mathbook-content"><p id="p-4">Now, we get values of the invertible linear transformation \(\rho_B\) with the Sage method <code class="code-inline tex2jax_ignore">.coordinate_vector()</code> method of the vector space.</p></div>
c = V.coordinate_vector(u) c
%auto %html(hide=True) <div class="mathbook-content"><p id="p-5">The inverse linear transformation is also available as the <code class="code-inline tex2jax_ignore">.linear_combination_of_basis()</code> method of the vector space.</p></div>
round_trip = V.linear_combination_of_basis(c) round_trip
%auto %html(hide=True) <div class="mathbook-content"><p id="p-6">And the automated check:</p></div>
u == round_trip
%auto %html(hide=True) <div class="mathbook-content"><p id="p-7">Notice that this is something we could do âby handâ with just reduced row-echelon form. The coordinitization of <code class="code-inline tex2jax_ignore">u</code> relative to the basis <code class="code-inline tex2jax_ignore">B</code> is just a (unique) solution to a linear system.</p></div>
aug = column_matrix(B + [u]) aug.rref()
%auto %html(hide=True) <div class="mathbook-content"><p id="p-8">The following stanza will always return <code class="code-inline tex2jax_ignore">True</code> as we âcoordinatizeâ and then use the coordinates to form a linear combination of the basis.</p></div>
w = random_vector(QQ, n) x = V.coordinate_vector(w) y = V.linear_combination_of_basis(x) y == w
%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">Abstract Vector Spaces</span> </h6></section></div>
%auto %html(hide=True) <div class="mathbook-content"><p id="p-9">Sage does not implement abstract vector spaces. It presumes we have âniceâ standard bases available and can apply an intermediate coordinatization ourselves.</p></div>
%auto %html(hide=True) <div class="mathbook-content"><article class="exercise-like" id="exercise-1"><h6 class="heading"> <span class="type">Demonstration</span> <span class="codenumber">1</span>.</h6> <p id="p-10">In \(P_3\text{,}\) the vector space of polynomials with degree at most \(3\text{,}\) find the vector representation of \(p = x^{3} + x^{2} + \frac{1}{2} \, x - \frac{33}{14}\) relative to the basis for \(P_3\text{:}\)</p> <div class="displaymath"> \begin{align*} B = \{& 5x^{3} + 2x^{2} + x + 1,\, -8x^{3} - 3x^{2} - x - 2,\\ & 7x^{3} + 4x^{2} + x + 2,\, -7x^{3} + 3x^{2} + x - 2\}\text{.} \end{align*} </div> <p id="p-11">Hint: Coordinatize with respect to the basis \(\left\{1, x, x^2, x^3\right\}\text{.}\)</p></article></div>
A = matrix(QQ, [[1, -2, 2, -2], [1, -1, 1, 1], [2, -3, 4, 3], [5, -8, 7, -7]]) B = A.columns() B
%auto %html(hide=True) <div class="mathbook-content"><p id="p-12"><code class="code-inline tex2jax_ignore">B</code> is a basis, since <code class="code-inline tex2jax_ignore">A</code> is nonsingular.</p></div>
A.is_singular()
%auto %html(hide=True) <div class="mathbook-content"><p id="p-13">Now coordinatize <code class="code-inline tex2jax_ignore">p</code>.</p></div>
p = vector(QQ, [-33/14, 1/2, 1, 1]) p
%auto %html(hide=True) <div class="mathbook-content"><p id="p-14">We'll get a coordinatization old-style.</p></div>
aug = column_matrix(B + [p]) r = aug.rref() r
%auto %html(hide=True) <div class="mathbook-content"><p id="p-15">Let's check to see if this is right and we can recover <code class="code-inline tex2jax_ignore">p</code>.</p></div>
soln = r.column(4) round_trip = sum([soln[i]*B[i] for i in range(4)]) round_trip, round_trip == p
%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>