Last updated: August 1, 2026
Matrix Trace Calculator
Creators
Dharmendra SinghReviewers

Creators
Dharmendra SinghReviewers
Quick Answer
Enter a square matrix in row format to add its main diagonal entries and compute tr(A). The calculator also reports the average diagonal entry and the accepted matrix size, making it easy to verify the result and connect it with eigenvalue-sum interpretations.
Enter a square matrix to add its main diagonal entries and compute the trace.
Creators
Dharmendra SinghReviewers

Creators
Dharmendra SinghReviewers
Formula
The trace of a square matrix is the sum of its diagonal entries.
Where:
- A=square matrix
- tr(A)=trace of the matrix
Worked Examples
2×2 trace
Compute tr([[1,2],[3,4]]).
- 1Identify the diagonal entries 1 and 4.
- 2Add them to get 5.
3×3 diagonal matrix
Diagonal entries add directly.
- 1Read the diagonal entries 2, 3, and 4.
- 2Add them.
Upper triangular matrix
Only the diagonal matters.
- 1Ignore off-diagonal entries.
- 2Sum 1 + 2 + 3.
Non-square input
Trace requires a square matrix.
- 1Check the shape first.
- 2Reject rectangular input.
Introduction
Add the main diagonal of a square matrix and see the average diagonal entry at the same time.
Overview
Add the main diagonal of a square matrix and see the average diagonal entry at the same time.
Trace
Eigenvalue sum checks
Similarity invariants
Quick diagonal summaries
Input format
Enter a square matrix in row form.
Separate rows with semicolons
Separate entries with commas or spaces
Brackets are optional
Keep row lengths consistent
Formula and method
The trace of a square matrix is the sum of its diagonal entries.
- A matters:
square matrix.
- Tr(A) matters:
trace of the matrix.
Validation rules
The calculator uses deterministic validation before it computes the final result.
The matrix must be square
Every entry must be finite
The matrix must be nonempty
Off-diagonal entries do not affect the trace
Interpreting the outputs
Use the main result first, then the secondary fields to verify the structure and meaning of the answer.
trace is the diagonal sum
averageDiagonal divides the trace by the matrix size
matrixSize confirms the accepted dimension
A zero trace does not mean the matrix is zero
Common use cases
These are typical reasons to use this calculator in study or applied work.
Eigenvalue sum checks
Similarity invariants
Quick diagonal summaries
Matrix identity verification
FAQs
Can I take the trace of a rectangular matrix?
No. Trace is defined only for square matrices.
Do off-diagonal entries matter?
No. Only the main diagonal contributes to the trace.
What does averageDiagonal mean?
It is the trace divided by the matrix size.
Can the trace be zero?
Yes. A nonzero matrix can still have zero trace.
Can I use decimals?
Yes. Any finite real entries are supported.
Why is trace important?
It equals the sum of eigenvalues and appears in many matrix identities.