Documentation Center

  • Trial Software
  • Product Updates

Compute Determinants and Traces of Square Matrices

MuPAD® provides the functions for performing many special operations on matrices. You can compute the dimensions of a matrix, swap or delete columns and rows, or transpose a matrix. For square matrices, you can compute determinants and traces.

To compute the determinant of a square matrix, use the det function. For example, compute the determinant of the following 2×2 matrix:

A := matrix(2, 2, [a, b, c, d]):
det(A)

Now, compute the determinant of the 12×12 Hilbert matrix:

det(linalg::hilbert(12))

To compute a sum of the diagonal elements of a square matrix (the trace of a matrix), use the linalg::tr function. For example, the trace of the matrix A is:

A := matrix(2, 2, [a, b, c, d]):
linalg::tr(A)

Now, compute the trace of the 12×12 Hilbert matrix:

H := linalg::hilbert(12):
linalg::tr(H)

Was this topic helpful?