Matrix Trace Calculator
Find the trace of any square matrix up to 10x10. Get tr(A), the diagonal entries, the mean diagonal value and tr(A squared), instantly and exactly.
Matrix Trace Calculator
Background.
The trace of a square matrix is the simplest number you can pull out of it: add up the entries running down the main diagonal, from the top-left corner to the bottom-right, and ignore everything else. This calculator does that for any square matrix up to 10 by 10, and adds three things worth having beside it — the diagonal entries themselves so you can see what was summed, their mean, and the trace of A squared.
Type or paste your matrix with one row per line, entries separated by commas or spaces. Semicolons work as row separators and the bracketed form [[1,2],[3,4]] is accepted too. The matrix has to be square, because a rectangular one has no diagonal running corner to corner.
The trace looks trivial and is not. It equals the sum of the eigenvalues of A, which means you can read off the total of all n eigenvalues in one glance without solving a characteristic polynomial. It is unchanged by a change of basis, so it says something about the linear map itself rather than about the particular coordinates you wrote it in. It is linear, so the trace of a sum is the sum of the traces. And it satisfies the cyclic property tr(AB) = tr(BA) even when AB and BA are completely different matrices — a fact that quietly underpins a great deal of physics and statistics.
The tr(A squared) output is the companion number: it equals the sum of the squared eigenvalues, so together with the trace it pins down the mean and the spread of a matrix's spectrum without any eigenvalue solver at all. It is computed straight from the entries of A as the sum over i and j of a(i,j) times a(j,i), so no product matrix is ever formed. Where the trace and the determinant meet is the characteristic polynomial: the trace is its first non-leading coefficient and the determinant is its last.
What is matrix trace calculator?
The trace of an n x n matrix A, written tr(A), Tr(A) or Sp(A), is the sum of the entries on its main diagonal: tr(A) = a11 + a22 + ... + ann. It is defined only for square matrices. The trace is linear — tr(aA + bB) = a·tr(A) + b·tr(B) — satisfies the cyclic property tr(AB) = tr(BA), and is invariant under similarity, so tr(BAB^-1) = tr(A) for any invertible B. That last property is what makes the trace a property of the underlying linear transformation rather than of the particular basis it is written in. The trace coincides with the sum of the roots of the characteristic polynomial of A, that is, with the sum of its eigenvalues counted with multiplicity; in the characteristic polynomial itself, the trace appears as the coefficient b1 while the determinant appears as the final coefficient bn. Related identities: tr(A^T) = tr(A), because transposing leaves the diagonal untouched; tr(A^2) equals the sum of the squared eigenvalues; and tr(A^T A) equals the square of the Frobenius norm of A.
How to use this calculator.
- Type your square matrix into the box, one row per line, with entries separated by commas or spaces.
- You can also paste [[1,2],[3,4]] or use semicolons as row separators.
- Read the headline number: that is tr(A), the sum of the main diagonal, and also the sum of all n eigenvalues.
- Check the diagonal entries output to confirm the calculator picked up the numbers you meant — this is the fastest way to spot a mis-typed row.
- Read tr(A squared) if you want the sum of the squared eigenvalues, for instance to gauge how spread out the spectrum is.
- If the matrix is not square the calculator says so rather than guessing which diagonal you meant.
The formula.
The trace is defined as the sum of the entries on the main diagonal: tr(A) = a11 + a22 + ... + ann, taking one entry from each row and each column where the two indices agree. On the worked example A = [[2,7,1],[3,-4,5],[6,0,8]] the diagonal is 2, -4 and 8, so tr(A) = 2 + (-4) + 8 = 6 and the mean diagonal entry is 6/3 = 2. The off-diagonal entries play no part at all, which is why transposing a matrix leaves its trace unchanged. tr(A squared) needs slightly more care but still never requires forming a product matrix: the (i,i) entry of A times A is the dot product of row i of A with column i of A, so tr(A^2) = the sum over i and j of a(i,j) times a(j,i). For the same example that is (2^2 + (-4)^2 + 8^2) + 2 times (7 times 3 + 1 times 6 + 5 times 0) = 84 + 54 = 138. Forming A squared explicitly as [[31,-14,45],[24,37,23],[60,42,70]] and adding 31 + 37 + 70 gives the same 138, which is the cross-check the dossier records. Both numbers have eigenvalue readings: tr(A) is the sum of the eigenvalues of A and tr(A squared) is the sum of their squares, so for the upper-triangular matrix with diagonal 2, 3, 5 — whose eigenvalues simply are 2, 3 and 5 — the calculator returns 10 and 38, matching 2+3+5 and 4+9+25. All arithmetic runs at 60 significant digits and is rounded once, at the end, to 10 decimal places.
A worked example.
Take A = [[2, 7, 1], [3, -4, 5], [6, 0, 8]]. The main diagonal runs 2, then -4, then 8, so the diagonal entries output reads 2, -4, 8 and the trace is 2 + (-4) + 8 = 6. The mean diagonal entry is 6 divided by 3 = 2, which is also the average eigenvalue of A even though we never computed a single eigenvalue. The trace of A squared comes out as 138. You can confirm that two ways. Forming the product explicitly gives A squared = [[31, -14, 45], [24, 37, 23], [60, 42, 70]], whose diagonal 31, 37, 70 sums to 138. Or you can get it straight from the entries of A without forming any product at all, which is what the calculator does: the sum of the squared diagonal entries is 4 + 16 + 64 = 84, and every off-diagonal pair contributes twice its product, giving 2 times (7 times 3 plus 1 times 6 plus 5 times 0) = 2 times 27 = 54, and 84 + 54 = 138. Since the trace is the sum of the eigenvalues and tr(A squared) is the sum of their squares, this matrix has three eigenvalues that add to 6 and whose squares add to 138 — a wide spread, since three equal eigenvalues of 2 would have given only 12.
Frequently asked questions.
What is the trace of a matrix used for?
Can a rectangular matrix have a trace?
Is tr(AB) the same as tr(A) times tr(B)?
How are the trace and the determinant related?
What does tr(A squared) tell me?
References& sources.
- [1]Encyclopedia of Mathematics (EMS Press), 'Trace of a square matrix'. Defines the trace as 'the sum of the entries on the main diagonal of this matrix' and lists linearity, the cyclic property tr(AB) = tr(BA), similarity invariance, and that the trace coincides with the sum of the roots of the characteristic polynomial. Retrieved 2026-07-29.
- [2]Encyclopedia of Mathematics (EMS Press), 'Characteristic polynomial'. States that the coefficient b1 is the trace of A (b1 = Tr A = a11 + ... + ann) and that the final coefficient bn is det A. Retrieved 2026-07-29.
- [3]Golub, G. H. & Van Loan, C. F. (2013). Matrix Computations, 4th ed., Johns Hopkins University Press — sections 2.1 and 2.3, including the identity tr(A transpose A) = the squared Frobenius norm. Print reference; publisher page linked.
In this category
Embed
Quanta Pro
Paid features are coming later.
- All 977 calculators remain free
- No billing is enabled