Last Updated 10/21/2022
Special Matrices
SageMath has convenient ways to define common special matrices such as diagonal, identity, and zero matrices.
To define the diagonal matrix , we list the diagonal elements with the diagonal_matrix command.
To define an identity matrix, we use the identity_matrix command. For example, the identity matrix is defined by identity_matrix(4).
Alternatively, an identity matrix is a diagonal matrix. For example, can be defined as a diagonal matrix with 1 as the diagonal elements.
Likewise, we can define the zero matrices by the zero_matrix(m,n)command.
Try this!
Define the zero matrix.