Audited 29 Jul 2026·Last updated 31 Jul 2026·3 citations·Tier 3·0 uses

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

One row per line. Separate entries with commas or spaces.
Trace tr(A)
6
The sum of the entries on the main diagonal, which also equals the sum of the eigenvalues of A.
Matrix size (n)
3
Main-diagonal entries
2, -4, 8
Mean diagonal entry
2
tr(A squared)
138

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.

  1. Type your square matrix into the box, one row per line, with entries separated by commas or spaces.
  2. You can also paste [[1,2],[3,4]] or use semicolons as row separators.
  3. Read the headline number: that is tr(A), the sum of the main diagonal, and also the sum of all n eigenvalues.
  4. 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.
  5. Read tr(A squared) if you want the sum of the squared eigenvalues, for instance to gauge how spread out the spectrum is.
  6. If the matrix is not square the calculator says so rather than guessing which diagonal you meant.

The formula.

tr(A) = Σᵢ aᵢᵢ = a₁₁ + a₂₂ + … + aₙₙ

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.

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.

matrix2, 7, 1 3, -4, 5 6, 0, 8

Frequently asked questions.

What is the trace of a matrix used for?
It is the fastest route to the sum of the eigenvalues: the trace equals the sum of the roots of the characteristic polynomial, so you get the total of all n eigenvalues without solving anything. It is also basis-independent, meaning it describes the linear transformation itself rather than the coordinates you happened to write it in, which is why it appears throughout physics and statistics — the expected value of a quadratic form, the degrees of freedom of a projection, and the sum of the variances in a covariance matrix are all traces.
Can a rectangular matrix have a trace?
No. A trace needs a main diagonal running from the top-left corner to the bottom-right, and only a square matrix has one. This calculator returns an error rather than summing some partial diagonal, because there is no standard convention for what that would mean. If your matrix is rectangular, the quantities that are defined for it are its rank, its Frobenius norm, and its singular values.
Is tr(AB) the same as tr(A) times tr(B)?
No — that is one of the most common mistakes with traces. What is true is the cyclic property, tr(AB) = tr(BA), which holds even when AB and BA are entirely different matrices and even when they have different sizes. The trace is linear in addition, so tr(A + B) = tr(A) + tr(B) and tr(kA) = k tr(A), but it is not multiplicative. The determinant is the other way round: det(AB) = det(A)det(B), but det(A + B) has no simple form.
How are the trace and the determinant related?
They are the first and last coefficients of the same characteristic polynomial. The trace is the sum of the eigenvalues and the determinant is their product, so for a 2 by 2 matrix the characteristic polynomial is exactly lambda squared minus (trace) lambda plus (determinant). For larger matrices the intermediate coefficients are the other elementary symmetric functions of the eigenvalues. That is why knowing both numbers pins down a 2 by 2 spectrum completely but only constrains a larger one.
What does tr(A squared) tell me?
It is the sum of the squared eigenvalues. Paired with the trace it gives you the mean and the spread of the spectrum without any eigenvalue solver: if the trace is 6 across three eigenvalues the mean is 2, and if tr(A squared) is much larger than 3 times 2 squared = 12 then those eigenvalues are far from equal. For a symmetric matrix tr(A squared) also equals the squared Frobenius norm, since tr(A transpose times A) is the sum of every squared entry.

In this category

Embed

Quanta Pro

Paid features are coming later.

  • All 977 calculators remain free
  • No billing is enabled
Coming soon