Beginner

Matrix Trace Calculator

Find the trace of any square matrix by summing the entries along its main diagonal.
Enter n rows of n numbers, separated by spaces or commas.
Trace tr(A)
14

Sum of the main diagonal entries

Matrix size
3 × 3
Diagonal entries
2, 5, 7
Entry A[1,1]2
Entry A[2,2]5
Entry A[3,3]7
Step by step
  1. 1

    Diagonal entry A[1,1]

    2
  2. 2

    Diagonal entry A[2,2]

    5
  3. 3

    Diagonal entry A[3,3]

    7
  4. 4

    Trace tr(A)

    2 + 5 + 7 = 14
Results are estimates for general information only and are not professional advice — always verify important results independently before relying on them. Read the full disclaimer.
Quick answer

How does this calculator work?

The trace of a square matrix is the sum of its main diagonal entries, written tr(A) = ΣA[i,i]. Enter the matrix as rows of numbers; the tool checks that it is square, then adds the top-left to bottom-right diagonal elements to return a single scalar trace value.

Formula
tr(A) = A[1,1] + A[2,2] + ... + A[n,n] = Σ A[i,i]
How this is calculated

Enter a square matrix A with one row per line, using spaces or commas to separate the numbers within a row. The calculator parses the text into an n×n array. Every row must contain the same number of entries, and the count of rows must equal the count of columns; otherwise the matrix is not square and the trace is undefined.

The trace is defined only for square matrices and equals the sum of the entries on the main diagonal, the positions A[i][i] running from the top-left to the bottom-right corner. The calculator collects these diagonal entries A[1,1], A[2,2], …, A[n,n] and adds them together to produce a single scalar value.

The trace is a linear operation: tr(A + B) = tr(A) + tr(B) and tr(cA) = c·tr(A). It also equals the sum of the eigenvalues of A and is invariant under similarity transformations, since tr(AB) = tr(BA). Off-diagonal entries never affect the result, so only the diagonal needs to be valid; non-numeric or ragged input is rejected.

Frequently asked questions

The trace, written tr(A), is the sum of the entries on the main diagonal of a square matrix — the elements running from the top-left to the bottom-right corner.

No. The trace is only defined for square matrices, where the number of rows equals the number of columns. This tool reports an error for non-square input.

Yes. The trace of a matrix equals the sum of its eigenvalues (counted with multiplicity), which makes it a useful quick invariant in linear algebra.

Also known as

matrix trace
trace of matrix
sum of diagonal
diagonal sum
tr(a)
trace calculator

APA

TG we-Calculate Editorial Team. (2026). Matrix Trace Calculator [Online calculator]. TG we-Calculate. https://we-calculate.com/calculator/matrix-trace-calculator

Chicago

TG we-Calculate Editorial Team. "Matrix Trace Calculator." TG we-Calculate. 2026. https://we-calculate.com/calculator/matrix-trace-calculator.

IEEE

TG we-Calculate Editorial Team, "Matrix Trace Calculator," TG we-Calculate, 2026. [Online]. Available: https://we-calculate.com/calculator/matrix-trace-calculator

BibTeX

@misc{wecalculate_matrix_trace_calculator, title = {Matrix Trace Calculator}, author = {{TG we-Calculate Editorial Team}}, howpublished = {\url{https://we-calculate.com/calculator/matrix-trace-calculator}}, year = {2026}, note = {TG we-Calculate} }

Did this calculator help you?