Linear Algebra Computations using SageMath Linear Algebra


SageMath References

Additional SageMath References

  • CoCalc website. A great place to run your SageMath code and save your work.

Your SageMath Computations

Type your own Sage computation below and click “Evaluate”.

Linear Algebra Computations Templates

A few useful things you can do with vectors:

Basic matrix arithmetic:

Gauss-Jordan Algorithm can be done in an instant using RREF(A) when you are in a hurry:

Elementary Row Operations

When you want to check your individual elementary row operations (EROs):

Find the inverse of a matrix:

Compute a determinant of a square matrix:

Basic Eigentheory:

A few results about diagonalizable matrices:

Here's how you can check your work after doing the Gram-Schmidt Algorithm by hand.
  • \( A=[\vec{v}_1 | \cdots | \vec{v}_k] \) for matrix with vectors \( S=\{ \vec{v}_1,\ldots,\vec{v}_k \} \) put into the columns
  • Compute: \( \boxed{\, A^{\top} * A\, } \), call this matrix \( B\).
  • Interpret results:
    • \( B\) is a diagonal matrix if and only if \( S \) is an orthogonal set
    • \( B\) is the identity matrix \( I_n \) if and only if \( S \) is an orthonormal set
Observe that this works because the ith row times jth column of \( A^{\top}*A \) is the dot product \( \vec{v}_i \circ \vec{v}_j \).

SageMath can do Gram-Schmidt with some limitations. For reasons I do not quite understand, SAGEMath can't output ortho-normal sets of vectors. So you can either manually do it, type out the code to have each vector divided by it's norm. To do this, you need to create a matrix with the vectors \( \vec{v}_i\) put into the rows.

Here we use Sage to help us build and check the theory of projection transformations and their matrices: