trace

trace(A)

Try it yourself:


trace(): sum a matrix diagonal

trace(A) adds the main diagonal entries of a square matrix. For [[a,b],[c,d]], the trace is a+d.

Why it matters

Trace is invariant under a change of basis and equals the sum of eigenvalues, counted with multiplicity. It appears in linear systems, statistics, and matrix calculus.

Related matrix tools

Use det() for the determinant, transpose() to reflect a matrix, diag() to work with diagonal entries, and sum() for general aggregation. identity() has trace equal to its dimension.

Caveat

Trace requires a square matrix; check dimensions first with size().

Try Trace in Calcul.io

Start with one of the editable examples above, then replace its arguments with your own values. Keeping the function on a separate calculator line makes the input and result easy to compare. For a longer workflow, assign the result to a variable or reference that line in the next expression.

Check the shown signature before adding optional arguments, and use the related-function links to compare operations with similar purposes.

All functions