A second way to build a linear transformation is to use a matrix, as motivated by Theorem MBLT. But there is one caveat. We have seen that Sage has a preference for rows, so when defining a linear transformation with a product of a matrix and a vector, Sage forms a linear combination of the rows of the matrix with the scalars of the vector. This is expressed by writing the vector on the left of the matrix, where if we were to interpret the vector as a 1-row matrix, then the definition of matrix multiplication would do the right thing.
Remember throughout, a linear transformation has very little to do with the mechanism by which we define it. Whether or not we use matrix multiplication with vectors on the left (Sage internally) or matrix multiplication with vectors on the right (your text), what matters is the function that results. One concession to the “vector on the right” approach is that we can tell Sage that we mean for the matrix to define the linear transformation by multiplication with the vector on the right. Here is our running example again — with some explanation following.
The way T prints reflects the way Sage carries T internally. But notice that we defined T in a way that is consistent with the text, via the use of the optional side='right' keyword. If you rework examples from the text, or use Sage to assist with exercises, be sure to remember this option. In particular, when the matrix is square it might be easy to miss that you have forgotten this option. Note too that Sage uses a more general term for a linear transformation, “vector space morphism.” Just mentally translate from Sage-speak to the terms we use here in the text.
If the standard way that Sage prints a linear transformation is too confusing, you can get all the relevant information with a handful of commands.
So we can build a linear transformation in Sage from a matrix, as promised by Theorem MBLT. Furthermore, Theorem MLTCV says there is a matrix associated with every linear transformation. This matrix is provided in Sage by the .matrix() method, where we use the option side='right' to be consistent with the text. Here is Example MOLT reprised, where we define the linear transformation via a Sage symbolic function and then recover the matrix of the linear transformation.