Matrix Diagonalization Calculator
Enter a 2×2 or 3×3 matrix to find P and D with A = PDP⁻¹, to see whether it is diagonalizable and, if you like, to compute a power Ak quickly.
What is diagonalization?
A square matrix A is diagonalizable if it can be written as A = PDP⁻¹, where D is a diagonal matrix and P is an invertible matrix. The diagonal entries of D are the eigenvalues of A and the columns of P are the corresponding eigenvectors. In the basis of eigenvectors the linear map x ↦ Ax simply stretches each coordinate by an eigenvalue, which is why diagonal form is the simplest possible description of a map.
When is a matrix diagonalizable?
An n×n matrix is diagonalizable exactly when it has n linearly independent eigenvectors. Equivalently, for every eigenvalue the geometric multiplicity (dimension of its eigenspace) equals the algebraic multiplicity (its multiplicity as a root of the characteristic polynomial). If all n eigenvalues are distinct, diagonalizability is automatic. A matrix such as the 2×2 matrix with rows (1, 1) and (0, 1) has the repeated eigenvalue 1 but only one eigenvector direction, so it is defective and cannot be diagonalized.
How the calculator works
It computes the characteristic polynomial, finds the eigenvalues, and obtains the eigenvectors exactly as the null spaces of A − λI by row reduction. If every eigenvalue is rational and the multiplicities match, it assembles P and D, inverts P with exact fractions, and verifies three identities: AP = PD, PDP⁻¹ = A and P⁻¹AP = D. When eigenvalues are irrational or complex, the calculator says so instead of printing rounded entries; the eigenvalue calculator shows those cases in exact radical form.
Fast matrix powers
The main practical use of diagonalization is computing powers: Ak = PDkP⁻¹, and Dk only needs each diagonal entry raised to the k-th power. This gives closed formulas for recurrences, for example a recurrence such as an = an−1 + 2an−2 from the matrix with rows (1, 1) and (2, 0), whose eigenvalues are 2 and −1, and for Markov chain long-run behaviour. (The Fibonacci matrix has the irrational eigenvalue (1 + √5)/2, so it is outside what this exact-fraction tool can show.) Enter a value of k between 1 and 60 and the tool compares the result with repeated multiplication as an independent check.
Worked examples
These examples are computed by the same engine as the calculator above, so you can compare each step with your own working.
2×2 with distinct eigenvalues, A⁵
- Matrix A:
[[4, 1], [2, 3]] - Compute A^k (0 = skip):
5
Diagonal matrix D
diag(5, 2)
Matrix P (columns are eigenvectors)
[1, −1/2] [1, 1]
A^5
[2094, 1031] [2062, 1063]
All 2 eigenvalues are distinct, so A is automatically diagonalizable.
P is not unique: scaling an eigenvector or reordering the eigenvalues gives another valid P and a correspondingly reordered D.
Step-by-step solution
Formula used
A = P D P⁻¹, D = diag(λ₁, …, λₙ), P = [v₁ … vₙ]
Aᵏ = P Dᵏ P⁻¹
CalculateCharacteristic polynomial
det(A − λI) = 0
p(λ) = λ² − 7λ + 10
A =4123
CalculateEigenvalues with multiplicities
λ = 5: algebraic multiplicity 1, geometric multiplicity 1
λ = 2: algebraic multiplicity 1, geometric multiplicity 1
CalculateEigenvectors (null spaces of A − λI)
λ = 5: v = (1, 1)ᵀ
λ = 2: v = (−1/2, 1)ᵀ
CalculateBuild P (eigenvectors as columns), D (eigenvalues on the diagonal) and P⁻¹
P =1−1211D =5002P⁻¹ =2313−2323
CheckVerify exactly
A·P = P·D ✓
P·D·P⁻¹ = A ✓
P⁻¹·A·P = D ✓
P·D·P⁻¹ =4123
ResultDiagonalization
A = P·D·P⁻¹
D =5002
CalculatePowers: A^5 = P·D^5·P⁻¹
Aᵏ = P Dᵏ P⁻¹ (only the diagonal entries are raised to the power k)
D^5 =31250032A^5 =2094103120621063
CheckCheck against repeated multiplication
Multiplying A by itself 5 times gives exactly the same matrix ✓
Recurrence matrix, eigenvalues 2 and −1, A¹⁰
- Matrix A:
[[1, 1], [2, 0]] - Compute A^k (0 = skip):
10
Diagonal matrix D
diag(2, −1)
Matrix P (columns are eigenvectors)
[1, −1/2] [1, 1]
A^10
[683, 341] [682, 342]
All 2 eigenvalues are distinct, so A is automatically diagonalizable.
P is not unique: scaling an eigenvector or reordering the eigenvalues gives another valid P and a correspondingly reordered D.
Step-by-step solution
Formula used
A = P D P⁻¹, D = diag(λ₁, …, λₙ), P = [v₁ … vₙ]
Aᵏ = P Dᵏ P⁻¹
CalculateCharacteristic polynomial
det(A − λI) = 0
p(λ) = λ² − λ − 2
A =1120
CalculateEigenvalues with multiplicities
λ = 2: algebraic multiplicity 1, geometric multiplicity 1
λ = −1: algebraic multiplicity 1, geometric multiplicity 1
CalculateEigenvectors (null spaces of A − λI)
λ = 2: v = (1, 1)ᵀ
λ = −1: v = (−1/2, 1)ᵀ
CalculateBuild P (eigenvectors as columns), D (eigenvalues on the diagonal) and P⁻¹
P =1−1211D =200−1P⁻¹ =2313−2323
CheckVerify exactly
A·P = P·D ✓
P·D·P⁻¹ = A ✓
P⁻¹·A·P = D ✓
P·D·P⁻¹ =1120
ResultDiagonalization
A = P·D·P⁻¹
D =200−1
CalculatePowers: A^10 = P·D^10·P⁻¹
Aᵏ = P Dᵏ P⁻¹ (only the diagonal entries are raised to the power k)
D^10 =1024001A^10 =683341682342
CheckCheck against repeated multiplication
Multiplying A by itself 10 times gives exactly the same matrix ✓
3×3 with eigenvalues 1, 2, 3
- Matrix A:
[[2, 0, 0], [1, 3, 0], [-1, 1, 1]] - Compute A^k (0 = skip):
3
Diagonal matrix D
diag(1, 3, 2)
Matrix P (columns are eigenvectors)
[0, 0, −1/2] [0, 2, 1/2] [1, 1, 1]
A^3
[8, 0, 0] [19, 27, 0] [−1, 13, 1]
All 3 eigenvalues are distinct, so A is automatically diagonalizable.
P is not unique: scaling an eigenvector or reordering the eigenvalues gives another valid P and a correspondingly reordered D.
Step-by-step solution
Formula used
A = P D P⁻¹, D = diag(λ₁, …, λₙ), P = [v₁ … vₙ]
Aᵏ = P Dᵏ P⁻¹
CalculateCharacteristic polynomial
det(A − λI) = 0
p(λ) = λ³ − 6λ² + 11λ − 6
A =200130−111
CalculateEigenvalues with multiplicities
λ = 1: algebraic multiplicity 1, geometric multiplicity 1
λ = 3: algebraic multiplicity 1, geometric multiplicity 1
λ = 2: algebraic multiplicity 1, geometric multiplicity 1
CalculateEigenvectors (null spaces of A − λI)
λ = 1: v = (0, 0, 1)ᵀ
λ = 3: v = (0, 2, 1)ᵀ
λ = 2: v = (−1/2, 1/2, 1)ᵀ
CalculateBuild P (eigenvectors as columns), D (eigenvalues on the diagonal) and P⁻¹
P =00−120212111D =100030002P⁻¹ =32−12112120−200
CheckVerify exactly
A·P = P·D ✓
P·D·P⁻¹ = A ✓
P⁻¹·A·P = D ✓
P·D·P⁻¹ =200130−111
ResultDiagonalization
A = P·D·P⁻¹
D =100030002
CalculatePowers: A^3 = P·D^3·P⁻¹
Aᵏ = P Dᵏ P⁻¹ (only the diagonal entries are raised to the power k)
D^3 =1000270008A^3 =80019270−1131
CheckCheck against repeated multiplication
Multiplying A by itself 3 times gives exactly the same matrix ✓
Defective matrix
- Matrix A:
[[1, 1], [0, 1]] - Compute A^k (0 = skip):
0
Diagonalizable?
No (defective matrix)
λ = 1: algebraic 2 > geometric 1
Step-by-step solution
Formula used
A is diagonalizable ⇔ geometric multiplicity = algebraic multiplicity for every eigenvalue
CalculateCharacteristic polynomial
det(A − λI) = 0
p(λ) = λ² − 2λ + 1
A =1101
CalculateEigenvalues with multiplicities
λ = 1: algebraic multiplicity 2, geometric multiplicity 1
ResultNot diagonalizable
For λ = 1 the algebraic multiplicity is 2 but there are only 1 independent eigenvector (geometric multiplicity).
A matrix is diagonalizable exactly when every eigenvalue has geometric multiplicity equal to its algebraic multiplicity. Here the eigenvectors cannot fill all 2 columns of P.
A is called defective; its Jordan form has a block larger than 1×1.
Complex eigenvalues (rotation)
- Matrix A:
[[0, -1], [1, 0]] - Compute A^k (0 = skip):
0
Diagonalization over the rationals
Not possible with rational entries
eigenvalues: i, −i
A matrix with distinct eigenvalues (even complex ones) is diagonalizable over the complex numbers; that form is not computed here.
Step-by-step solution
Formula used
A = P·D·P⁻¹ with D = diag(eigenvalues), P = eigenvectors as columns
CalculateCharacteristic polynomial
det(A − λI) = 0
p(λ) = λ² + 1
A =0−110
CalculateEigenvalues with multiplicities
λ = i: algebraic multiplicity 1, geometric multiplicity 1
λ = −i: algebraic multiplicity 1, geometric multiplicity 1
ResultEigenvalues are not all rational
Some eigenvalues are irrational or complex, so P and D cannot be written with exact fractions. This calculator diagonalizes only when all eigenvalues are rational.
Use the eigenvalue and eigenvector calculator to see the exact eigenvalues and vectors.
Frequently asked questions
Is every matrix diagonalizable?
No. Defective matrices, which have fewer independent eigenvectors than their size, are not. Symmetric real matrices are always diagonalizable.
Is P unique?
No. You can scale each eigenvector or reorder the eigenvalues. Different choices give different P and D, but the same A.
Why does the calculator refuse some matrices?
Rotation-like matrices have complex eigenvalues and some matrices have irrational ones. Their P and D cannot be shown with exact fractions, so the tool reports this honestly rather than rounding.
How do I compute A^100?
Diagonalize A, raise each diagonal entry of D to the 100th power and multiply P D^100 P⁻¹. This tool supports exponents up to 60 with an exact verification.