Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132928 views
License: OTHER
Kernel:
%%html <link href="https://pretextbook.org/beta/mathbook-content.css" rel="stylesheet" type="text/css" /> <link href="https://aimath.org/mathbook/mathbook-add-on.css" rel="stylesheet" type="text/css" /> <style>.subtitle {font-size:medium; display:block}</style> <link href="https://fonts.googleapis.com/css?family=Open+Sans:400,400italic,600,600italic" rel="stylesheet" type="text/css" /> <link href="https://fonts.googleapis.com/css?family=Inconsolata:400,700&subset=latin,latin-ext" rel="stylesheet" type="text/css" /><!-- Hide this cell. --> <script> var cell = $(".container .cell").eq(0), ia = cell.find(".input_area") if (cell.find(".toggle-button").length == 0) { ia.after( $('<button class="toggle-button">Toggle hidden code</button>').click( function (){ ia.toggle() } ) ) ia.hide() } </script>

Important: to view this notebook properly you will need to execute the cell above, which assumes you have an Internet connection. It should already be selected, or place your cursor anywhere above to select. Then press the "Run" button in the menu bar above (the right-pointing arrowhead), or press Shift-Enter on your keyboard.

ParseError: KaTeX parse error: \newcommand{\lt} attempting to redefine \lt; use \renewcommand

Sage and Linear Algebra Worksheet: FCLA Section VR

Robert Beezer
Department of Mathematics and Computer Science
University of Puget Sound
Fall 2019
Section 1 Vector Representations

It is easy to form vector representations of vectors in Cn.\mathbb{C}^n\text{.}

We get a nonstandard basis quickly from the columns of a nonsingular matrix. The keyword algorithm='unimodular' requests a matrix with determinant 1.1\text{.}

n = 6 A = random_matrix(QQ, n, algorithm='unimodular', upper_bound=9) A

The columns of A become the “user basis” of a vector space.

B = A.columns() V = (QQ^n).subspace_with_basis(B) V
u = random_vector(QQ, n) u

Now, we get values of the invertible linear transformation ρB\rho_B with the Sage method .coordinate\_vector() method of the vector space.

c = V.coordinate_vector(u) c

The inverse linear transformation is also available as the .linear\_combination\_of\_basis() method of the vector space.

round_trip = V.linear_combination_of_basis(c) round_trip

And the automated check:

u == round_trip

Notice that this is something we could do “by hand” with just reduced row-echelon form. The coordinitization of u relative to the basis B is just a (unique) solution to a linear system.

aug = column_matrix(B + [u]) aug.rref()

The following stanza will always return True as we “coordinatize” and then use the coordinates to form a linear combination of the basis.

w = random_vector(QQ, n) x = V.coordinate_vector(w) y = V.linear_combination_of_basis(x) y == w
Section 2 Abstract Vector Spaces

Sage does not implement abstract vector spaces. It presumes we have “nice” standard bases available and can apply an intermediate coordinatization ourselves.

Demonstration 1.

In P3,P_3\text{,} the vector space of polynomials with degree at most 3,3\text{,} find the vector representation of p=x3+x2+12x3314p = x^{3} + x^{2} + \frac{1}{2} \, x - \frac{33}{14} relative to the basis for P3:P_3\text{:}

B={5x3+2x2+x+1,8x33x2x2,7x3+4x2+x+2,7x3+3x2+x2}.\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*}

Hint: Coordinatize with respect to the basis {1,x,x2,x3}.\left\{1, x, x^2, x^3\right\}\text{.}

A = matrix(QQ, [[1, -2, 2, -2], [1, -1, 1, 1], [2, -3, 4, 3], [5, -8, 7, -7]]) B = A.columns() B

B is a basis, since A is nonsingular.

A.is_singular()

Now coordinatize p.

p = vector(QQ, [-33/14, 1/2, 1, 1]) p

We'll get a coordinatization old-style.

aug = column_matrix(B + [p]) r = aug.rref() r

Let's check to see if this is right and we can recover p.

soln = r.column(4) round_trip = sum([soln[i]*B[i] for i in range(4)]) round_trip, round_trip == p

This work is Copyright 2016–2019 by Robert A. Beezer. It is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.