Sage and Linear Algebra Worksheet: FCLA Section LT
Sage has very capable linear transformations from \(\mathbb{Q}^n\) to \(\mathbb{Q}^m\text{.}\)
Section 1 Creation via Symbolic Functions
Start with a symbolic function.
Then specify the domain and codomain. We need to be careful about how T
prints, Sage likes rows.
At a most basic level, T
behaves as a function.
We can check Theorem LTTZZ, zero goes to zero.
Section 2 Creation via Matrices
We can also create a linear transformation from a matrix, as in Theorem MBLT, with one caveat. For a matrix \(A\text{,}\) the default is to create the function \(T(\mathbf{v})=\mathbf{v}A\text{.}\) The keywords option side='right'
will indicate that we want to put the vector on the right of the matrix.
Notice that we do not have to specify the domain or codomain, these are inferred from the size and type of the matrix. S
is not new, it is exactly the linear transformation T
above.
Again, notice how S
prints — the matrix representation is the transpose of what we like to use. This does not change the linear transformation as a function, it just changes how we think about it (we like linear combinations of columns, Sage likes linear combinations of rows).
Section 3 Creation via Values on a Basis
Starting with a domain and a codomain, we can provide a list of the images of basis vectors for the domain.
That's right — same function again.
We can check how this construction works.
We can give the domain an alternate basis and create a different linear transformation, despite seemingly having the same construction. First we build the domain with a different user basis.
Even though the matrix representation prints the same, this is not the same function, we will need ideas from Chapter R before we can understand the difference.
This code should consistently return False
.
Section 4 Basic Properties
Illustrations with T
.
A defining property, so always True
.
A defining property, so also always True
.
We can do “arithmetic” with linear transformations, though the addition seems to allow bad things to happen.
Scalar multiples also, and they are well-behaved.
The following is wrong. (In other words, there is a bug in Sage.)
As we can see…
The problem is that Sage is simply adding the matrices representing the linear transformations, without checking that they are defined using domains with the same basis. We will understand the subtlety better in Chapter R.
This work is Copyright 2016–2019 by Robert A. Beezer. It is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.