Omni Calculator logo

Matrix Trace Calculator

Created by Anna Szczepanek, PhD
Reviewed by Rijk de Wet
Last updated: Jan 18, 2024


Omni's matrix trace calculator is here to help you learn about the important mathematical concept of the trace of a matrix. Although it's not hard to learn how to calculate the trace of a matrix, it is important to understand the theoretical properties of the matrix trace. After reading the article below, you'll be able to answer the following questions:

  • What is the trace of a matrix?
  • What properties does the matrix trace have?
  • What's the connection between trace and eigenvalues?
  • Is the trace of a matrix a linear transformation?
  • ... and many more!

Let's go!

What is the trace of a matrix?

We define the trace of a matrix as the sum of all the diagonal elements of this matrix. The matrix in question must be square, i.e., it must have as many columns as it has rows. For instance, the trace of the 2×22 × 2 matrix, AA,

A=[1234]A = \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}

is equal to 1+4=51 + 4 = 5. The trace of matrix AA is denoted by tr(A)\operatorname{tr}(A).

As you can see, it's not difficult to learn how to calculate the trace of a matrix. Let's now talk about the properties of the trace.

Matrix trace properties

If AA, BB, and CC are all square matrices, then their traces satisfy the following properties:

  • tr(A+B)=tr(A)+tr(B)\operatorname{tr}(A + B) = \operatorname{tr}(A) + \operatorname{tr}(B)

  • tr(kA)=ktr(A)\operatorname{tr}(k A) = k \operatorname{tr}(A), where kk is a scalar. You can visit the matrix by scalar calculator if you're unsure about this type of multiplication.

  • tr(AB)=tr(BA)\operatorname{tr}(AB) = \operatorname{tr}(BA)

  • tr(ABC)=tr(BCA)=tr(CAB)\operatorname{tr}(ABC) = \operatorname{tr}(BCA) = \operatorname{tr}(CAB)

  • tr(AT)=tr(A)\operatorname{tr}(A^T) = \operatorname{tr}(A), where ATA^T is the matrix transpose of AA

  • tr(AB)=tr(A)tr(B)\operatorname{tr}(A \otimes B) = \operatorname{tr}(A) \operatorname{tr}(B), where \otimes denotes the tensor product (aka the Kronecker product) of matrices.

  • tr(A)\operatorname{tr}(A) is equal to the sum of the eigenvalues of AA.

  • tr(In)=n\operatorname{tr}(I_n) = n, where InI_n is the n×nn \times n identity matrix.

💡 One can show that the first four properties above describe the trace operator uniquely. That is, if you're given an operator on matrices that satisfies them, it must be the trace operator! Nice, isn't it?

What is the cyclicity of the trace?

The trace is famous for its cyclic property. It basically means that the trace is invariant under cyclic permutations — the cyclical rearrangement of the matrices in a matrix product expression. For instance, for three matrices AA, BB, and CC, we have

tr(ABC)=tr(BCA)=tr(CAB)\footnotesize \operatorname{tr}(ABC) = \operatorname{tr}(BCA) = \operatorname{tr}(CAB)

and for four matrices we have

tr(ABCD)=tr(BCDA)=tr(CDAB)=tr(DABC)\footnotesize \operatorname{tr}(ABCD) = \operatorname{tr}(BCDA) \\= \operatorname{tr}(CDAB) = \operatorname{tr}(DABC)

Do you see the pattern? In general, for nn matrices, we get

tr(A1An)=tr(A2AnA1)=tr(A3AnA1A2)=\footnotesize \operatorname{tr}(A_1 \ldots A_n) = \operatorname{tr}(A_2 \ldots A_n A_1) \\ = \operatorname{tr}(A_3 \ldots A_n A_1 A_2) = \ldots

This is the cyclic property of the trace operator. It's good to remember this properly as it is often very useful in various math problems with matrix trace.

❗ The trace is the same for cyclic permutations, but it is not immune to any permutation! It may happen that tr(ABC)tr(ACB)\operatorname{tr}(ABC) \neq \operatorname{tr}(ACB)! Can you come up with an example?

How do I calculate the trace of a matrix?

To calculate the trace of a matrix by hand, you need to:

  1. Write down the coefficients of the matrix.
  2. Identify the diagonal entries — the diagonal going from the upper-left corner to the bottom-right corner.
  3. Add all the diagonal entries together.
  4. The result you've got in Step 3 is exactly the trace of your matrix!

To verify if your computations are correct, use Omni's matrix trace calculator!

How to use this matrix trace calculator?

This trace of a matrix calculator is very user-friendly! To use it, you need to:

  1. Choose the matrix size.
  2. Enter the matrix coefficients.
  3. The trace of your matrix gets calculated and displayed immediately.
  4. Remember the blank fields are interpreted as zeros!

FAQ

What is the trace of projection matrix?

The trace of a projection matrix is equal to the dimension of the space that the matrix projects onto (the target space). This is a special case of a more general result that the trace of an idempotent matrix (recall A is called idempotent when A² = A) is equal to the rank of this matrix.

Is the trace of a matrix a linear transformation?

Yes, the trace operation is linear. That is, it satisfies tr(x·A + y·B) = x × tr(A) + y × tr(B), where A and B are square matrices of the same size, and x and y are scalars.

How do I calculate the eigenvalues of a 2×2 matrix given trace and determinant?

Recall that the eigenvalues are the roots of the characteristic polynomial of a matrix. Since the characteristic polynomial of a 2×2 matrix A reads p(λ) = x² − tr(A)·λ + det(A), the formula for its eigenvalues is ½ tr(A) ± ½√(tr(A)² − 4·det(A)).

Anna Szczepanek, PhD
Matrix size
2 × 2
a₁a₂
b₁b₂
Enter the coefficients in the fields below.
Blanks are interpreted as zeros. Precision: 6 decimal places.
First row
a₁
a₂
Second row
b₁
b₂
Results
Your matrix:
00
00
Trace: 0
Check out 35 similar linear algebra calculators 🔢
Adjoint matrixCharacteristic polynomialCholesky decomposition… 32 more
People also viewed…

BMR - Harris-Benedict equation

Harris-Benedict calculator uses one of the three most popular BMR formulas. Knowing your BMR (basal metabolic weight) may help you make important decisions about your diet and lifestyle.

Egyptian fraction

Learn how to write fractions like an ancient Egyptian with our Egyptian fractions calculator.

Korean age

If you're wondering what would your age be from a Korean perspective, use this Korean age calculator to find out.

Reverse FOIL

With our reverse FOIL calculator, you will learn how to factor trinomials in the blink of an eye!
Copyright by Omni Calculator sp. z o.o.
Privacy, Cookies & Terms of Service