Skip to main content
Skip to calculator
Advertisement

Last updated: August 1, 2026

Matrix Trace Calculator

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.

Helpful
Not helpful
Save as image
Share
Embed
Cite
Write feedback

Formula

The trace of a square matrix is the sum of its diagonal entries.

Where:

  • A=square matrix
  • tr(A)=trace of the matrix
Matrix TraceThe trace is a fast scalar summary of a square matrix because it depends only on the main diagonal.Matrix TraceMatrix view[ a₁₁ a₁₂ ⋯ ][ a₂₁ a₂₂ ⋯ ][ ⋮ ⋮ ⋱ ]Core formulatr(A) = Σ aᵢᵢOnly diagonal entries matterSquare matrices onlyThe trace equals the sum of eigenvalues
The trace is a fast scalar summary of a square matrix because it depends only on the main diagonal.

Worked Examples

2×2 trace

Compute tr([[1,2],[3,4]]).

  1. 1Identify the diagonal entries 1 and 4.
  2. 2Add them to get 5.
Final Answer: trace = 5, averageDiagonal = 2.5

3×3 diagonal matrix

Diagonal entries add directly.

  1. 1Read the diagonal entries 2, 3, and 4.
  2. 2Add them.
Final Answer: trace = 9

Upper triangular matrix

Only the diagonal matters.

  1. 1Ignore off-diagonal entries.
  2. 2Sum 1 + 2 + 3.
Final Answer: trace = 6

Non-square input

Trace requires a square matrix.

  1. 1Check the shape first.
  2. 2Reject rectangular input.
Final Answer: The calculator returns a validation error.

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.