Previous Up Next

5.47.3 Trace of a matrix: trace

The trace of a square matrix is the sum of the diagonal elements. The trace command finds the trace of a matrix.

Example

Input:

trace([[1,2],[3,4]])

Output:

5

Previous Up Next