Sage MR Matrix Representations

It is very easy to create matrix representations of linear transformations in Sage. Our examples in the text have used abstract vector spaces to make it a little easier to keep track of the domain and codomain. With Sage we will have to consistently use variants of QQ^n, but we will use non-obvious bases to make it nontrivial and interesting. Here are the components of our first example, one linear function, two vector spaces, four bases.



We create alternate versions of the domain and codomain by providing them with bases other than the standard ones. Then we build the linear transformation and ask for its .matrix(). We will use numerals to distinguish our two examples.



Now, we do it again, but with the bases D and E.



So once the pieces are in place, it is quite easy to obtain a matrix representation. You might experiment with examples from the text, by first mentally converting elements of abstract vector spaces into column vectors via vector representations using simple bases for the abstract spaces.

The linear transformations T1 and T2 are not different as functions, despite the fact that Sage treats them as unequal (since they have different matrix representations). We can check that the two functions behave identically, first with random testing. Repeated execution of the following compute cell should always produce True.



A better approach would be to see if T1 and T2 agree on a basis for the domain, and to avoid any favoritism, we will use the basis of U itself. Convince yourself that this is a proper application of Theorem LTDB to demonstrate equality.



Or we can just ask if they are equal functions (a method that is implemented using the previous idea about agreeing on a basis).



We can also demonstrate Theorem FTMR — we will use the representation for T1. We need a couple of vector representation linear transformations.



Now we experiment with a “random” element of the domain. Study the third computation carefully, as it is the Sage version of Theorem FTMR. You might compute some of the pieces of this expression to build up the final expression, and you might duplicate the experiment with a different input and/or with the T2 version.







One more time, but we will replace the vector representation linear transformations with Sage conveniences. Recognize that the .linear_combination_of_basis() method is the inverse of vector representation (it is “un-coordinatization”).



We have concentrated here on the first version of the conclusion of Theorem FTMR. You could experiment with the second version in a similar manner. Extra credit: what changes do you need to make in any of these experiments if you remove the side='right' option?