Algosim documentation: tr

tr

Trace of a matrix.

Syntax

Description

If A is a square matrix, then tr(A) is the trace of A, that is, the sum of the entries on the main diagonal. Hence,

tr(A) = ∑(MainDiagonal(A)).

Examples

A ≔ ❨❨6, 3, 2, 1❩, ❨0, 1, 7, 5❩, ❨−2, 3, 5, 8❩, ❨7, 9, 0, 1❩❩
⎛ 6   3   2   1⎞
⎜ 0   1   7   5⎟
⎜−2   3   5   8⎟
⎝ 7   9   0   1⎠
tr(A)
13
∑(MainDiagonal(A))
13
compute(tr(RandomMatrix(1000)), n, 1, 10)
515.912182885
509.814408976
492.672293025
519.399897533
495.911285001
491.120517927
497.941658813
503.288770157
495.07591446
510.217154223

See also