Study and Productivity

How to Diagonalize a Matrix: Eigenvalues, P and D

Step-by-step diagonalization: characteristic polynomial, eigenspaces, the multiplicity test, building P and D, and using A = PDP⁻¹ to compute powers fast.

Saizul Amin
Saizul Amin7 Nov 2026 · 4 min read
How to Diagonalize a Matrix: Eigenvalues, P and D

Diagonalization is one of those topics where the recipe is short but every step hides a trap: a sign error in the characteristic polynomial, an eigenvector that is not really in the eigenspace, or a repeated eigenvalue that quietly breaks everything. This guide follows the recipe from start to finish and shows how to check each stage with the free Matrix Diagonalization Calculator.

What you are trying to find

To diagonalize a square matrix A is to write it as A = PDP⁻¹, where D is diagonal and P is invertible. The diagonal entries of D are the eigenvalues of A and the columns of P are matching eigenvectors. Once you have this form, the matrix behaves like a list of numbers. Its powers are A^k = P·D^k·P⁻¹, and D^k just raises each diagonal entry to the power k.

Step one: the characteristic polynomial

Eigenvalues are the roots of det(λI − A). For a 2×2 matrix this is λ² minus the trace times λ plus the determinant. For larger matrices the calculator uses an exact recursion rather than a cofactor expansion, so fractions never get rounded. Take the matrix with rows 4 1 and 2 3. Its trace is 7 and its determinant is 10, so the polynomial is λ² − 7λ + 10, which factors as (λ − 5)(λ − 2). The eigenvalues are 5 and 2.

A good habit is to check two facts that are always true: the eigenvalues add up to the trace and multiply to the determinant. The calculator shows both numbers next to the verdict.

Step two: the eigenspaces

For each eigenvalue, solve (A − λI)v = 0 by row reduction. For λ = 5, A − 5I has rows −1 1 and 2 −2, which reduces to a single equation −v1 + v2 = 0, so v = (1, 1). For λ = 2, A − 2I has rows 2 1 and 2 1, giving 2v1 + v2 = 0 and v = (−1, 2). The calculator shows the reduced matrix for each eigenvalue and the basis it reads from it.

Step three: the multiplicity test

Each eigenvalue has an algebraic multiplicity, how many times it is a root, and a geometric multiplicity, how many independent eigenvectors it has. The matrix is diagonalizable exactly when the two agree for every eigenvalue. Distinct eigenvalues always pass. Repeated ones are where the trouble is.

The shear matrix with rows 1 1 and 0 1 has the eigenvalue 1 twice, but A − I has rank 1, so there is only one independent eigenvector. That matrix cannot be diagonalized, and the calculator marks the short count in red. On the other hand, the 3×3 example in the tool with eigenvalue 2 repeated has two independent eigenvectors for it, so it is fine.

Step four: build and check

Put the eigenvectors in the columns of P in the same order as the eigenvalues on the diagonal of D. For our matrix P has rows 1 −1 and 1 2, D = diag(5, 2) and P⁻¹ has rows 2/3 1/3 and −1/3 1/3. The tool multiplies P·D·P⁻¹ with exact fractions and confirms that it returns A.

Using the result: powers

Set the power box to 5. D⁵ is diag(3125, 32), and A⁵ comes out with rows 2094 1031 and 2062 1063. You could get the same by multiplying A by itself five times, and the calculator does that too, but the diagonal form explains the pattern: the 5^k part grows much faster, so for large k the columns of A^k line up with the eigenvector (1, 1).

The same idea answers long-run questions about Markov chains. Load the Markov example and raise it to the 20th power to see the columns approach the steady state.

Special cases worth knowing

Symmetric matrices are always diagonalizable with real eigenvalues, and their eigenvectors can be made orthonormal, giving A = QDQᵀ. The calculator builds Q in exact square-root form. Some matrices have irrational eigenvalues; the Fibonacci matrix with rows 1 1 and 1 0 has eigenvalues 1/2 ± √5/2, and its P is shown in decimals. A rotation matrix has complex eigenvalues, so it cannot be diagonalized with real numbers even though it can be with complex ones.

All the work happens in your browser, is saved locally with undo and redo, and can be copied as text, exported as LaTeX or printed for revision.

Completely freeNo cost, no sign-up
Files stay privateEverything runs in your browser
Easy in your languageAvailable in many languages