Function reference · Linear algebra
trace
Returns the trace of a square matrix: the sum of its diagonal entries.
Notation
trace(matrix)
Write it in an expression: nerdamer('trace(matrix([1,2],[3,4]))'), or in the Playground.
nerdamer.trace
nerdamer.trace(...args: [M]): Expression
A method on the default import. Arguments can be strings, as in Notation.
Parameters
matrix- A square matrix.
Returns
The sum of the diagonal entries.
Examples
Good to know
- A matrix that isn't square is an error.
JavaScript examples
nerdamer.trace('matrix([1,2],[3,4])').text()
// → 5