Let's test out some other methods of the Matrix
object:
A = matrix(QQ, [[2, 5, 4], [3, 1, 2], [5, 4, 6]]) print("Matrix A:") show(A) # Scalar operations print("Determinant of A: {0}".format(A.det())) print("Rank of A: {0}".format(A.rank())) print("Euclidean norm: {0}".format(A.norm())) print("Frobenius norm: {0}".format(A.norm('frob'))) # Matrix operations print("Transpose of A:") show(A.transpose()) print("Inverse of A:") show(A.inverse()) print("Adjoint of A:") show(A.adjoint()) print("Testing adj(A)/det(A) == inverse(A)") A.adjoint()/A.det() == A.inverse()
The output should look like this:
We created an object that represents a 3 by 3 matrix of rational numbers, and used its methods to calculate the determinant and rank of A. We then calculated its inverse and its adjoint, and verified the relationship between them. We also used the norm
method to compute two different norms of the matrix. When called with no arguments...