ZestCalc

Matrix Diagonalization Calculator

Rewrite a square matrix as PDP⁻¹, so its action splits into simple scaling along its eigenvectors. If it can't be done, see exactly why.

Matrix

Enter a square matrix up to 6×6, or start from an example.

Up to 6 rows and 6 columns.

Use integers, decimals, or fractions such as 1/3. Paste rows from a spreadsheet or a Python list into any cell.

Input

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

Diagonalization

Updates as you type.

A=PDP−1A = P D P^{-1}
P=P =
1-1
12
D=D =
50
02
P−1=P^{-1} =
2/31/3
-1/31/3

Each column of P is an eigenvector, and the entry of D in the same column is its eigenvalue.

Now powers are easy, because only D needs raising: An=PDnP−1A^n = P D^n P^{-1}.

Building P and D

λ:5,2\lambda: 5,\quad 2

Start from the eigenvalues, counting each one's repeats and its independent eigenvectors.

Step 0 of 5

What diagonalizing means

To diagonalize a square matrix is to write it as a product of three matrices:

A=PDP−1A = PDP^{-1}

The columns of PP are eigenvectors of AA, and DD is a diagonal matrix holding their eigenvalues. You can find both with the Eigenvalue and Eigenvector Calculator. Reading right to left, P−1P^{-1} switches to the basis of eigenvectors, DD scales along each one, and PP switches back. It's a Change of Basis Calculator in which the matrix becomes as simple as it can be.

When it works

An n×nn \times n matrix can be diagonalized exactly when it has nn independent eigenvectors. That's guaranteed when its nn eigenvalues are all different, and a real symmetric matrix always qualifies. A repeated eigenvalue may or may not have enough:

[2002] works, but [2102] doesn’t.\begin{bmatrix} 2 & 0 \\ 0 & 2 \end{bmatrix} \text{ works, but } \begin{bmatrix} 2 & 1 \\ 0 & 2 \end{bmatrix} \text{ doesn't.}

Both have the eigenvalue 2 twice, but the second has only one eigen-direction. A matrix like that is called defective. Complex eigenvalues are a separate matter: a rotation can be diagonalized, but only with complex numbers in PP and DD.

What it's good for

Powers are the classic use. Each P−1PP^{-1}P in the middle cancels, which leaves only DD to raise:

An=PDnP−1A^n = P D^n P^{-1}

Raising a diagonal matrix to a power just raises each entry, so the Matrix Power Calculator has a closed form for these matrices. That's how the Fibonacci matrix gives a formula for the nnth Fibonacci number, and why the long-run behavior of a Markov chain depends on its largest eigenvalues. The same idea solves systems of differential equations, since each eigen-direction can be handled alone.