Diagonalize Matrix Calculator
Welcome to the diagonalize matrix calculator, where we'll take you on a mathematical journey to the land of matrix diagonalization. We'll go through the topic of how to diagonalize a matrix using its eigenvalues and eigenvectors together. This process is extremely useful in advanced array calculations, since it's so much easier to deal with a diagonal matrix rather than a full one.
But is it a simple algorithm? Is every array a diagonalizable matrix? Sit back, grab your morning/afternoon coffee, and let's find out. Enter a 2×2 or 3×3 matrix, click Diagonalize, and the calculator instantly returns the eigenvalues, eigenvectors, the change-of-basis matrix P, the diagonal matrix D, and the inverse P−1 — verifying that A = P · D · P−1.
What is a matrix?
A matrix is an array of elements (usually numbers) arranged in a fixed number of rows and columns. An example of a matrix would be:
A = | 3 −1 |
| 0 2 |
| 1 −1 |
We say a matrix has cells into which we write the elements. Matrices appear naturally when dealing with:
- Systems of equations (Cramer's rule and the reduced row echelon form);
- Vectors and vector spaces;
- 3-dimensional geometry (the dot product and the cross product);
- Linear transformations (translation and rotation); and
- Graph theory and discrete mathematics.
We can look at matrices as an extension of the numbers we already know. As such, it makes sense to define basic operations on them — like addition and subtraction — and to compute important values such as the rank or, as we do here, the diagonalization.
Diagonal matrix: definition and properties
We call a square array of numbers a diagonal matrix if its only non-zero entries lie on the main diagonal:
D = | x₁ 0 … 0 |
| 0 x₂ … 0 |
| ⋮ ⋮ ⋱ ⋮ |
| 0 0 … xₙ |
Diagonal matrices are easy objects to work with:
- The sum and product of diagonal matrices is again a diagonal matrix.
- Diagonal matrices are transpose-invariant: if
Dis diagonal, thenDᵀ = D. - The k-th power of a diagonal matrix is diagonal, with each entry raised to the k-th power: the (i, i) entry becomes
xᵢᵏ.
That last property is why diagonalization is so valuable: computing Aᵏ = P · Dᵏ · P−1 is dramatically cheaper than multiplying the full matrix by itself k times.
Eigenvalues and eigenvectors
A number λ is an eigenvalue of a square matrix A if there is a non-zero vector v (an eigenvector) such that:
A · v = λ · v
The eigenvalues are the roots of the characteristic polynomial det(A − λI) = 0:
- 2×2:
λ² − tr(A)·λ + det(A) = 0 - 3×3:
λ³ − tr(A)·λ² + q·λ − det(A) = 0, whereqis the sum of the principal 2×2 minors.
For each eigenvalue λ, the eigenvectors are the non-zero solutions of (A − λI)·v = 0 — the null space of A − λI. The calculator finds this basis using Gaussian elimination.
How to diagonalize a matrix?
A square n×n matrix A is diagonalizable exactly when it has n linearly independent eigenvectors. When that happens:
- Find all eigenvalues λ₁, λ₂, …, λₙ (with multiplicity).
- Find a basis of eigenvectors and place them as the columns of P.
- Build D as the diagonal matrix whose entries are the eigenvalues, in the same order as the columns of P.
- Then
A = P · D · P−1.
A matrix is not diagonalizable over the real numbers when it has complex eigenvalues, or when a repeated eigenvalue is defective — its geometric multiplicity (the number of independent eigenvectors) is smaller than its algebraic multiplicity. The calculator detects both cases and explains what went wrong.
Quick fact: a matrix with n distinct eigenvalues is always diagonalizable, and every real symmetric matrix is diagonalizable with orthogonal eigenvectors.
Example: using the diagonalize matrix calculator
Take the matrix
A = | 4 1 |
| 2 3 |
Its characteristic equation is λ² − 7λ + 10 = 0, giving eigenvalues λ₁ = 5 and λ₂ = 2. Solving (A − λI)·v = 0 gives eigenvectors [1, 1] for λ = 5 and [1, −2] for λ = 2. Therefore:
P = | 1 1 | D = | 5 0 | A = P · D · P⁻¹
| 1 −2 | | 0 2 |
Because the two eigenvalues are distinct, the matrix is diagonalizable — and the calculator confirms the factorization automatically.
Units and currencies
Matrix entries are pure numbers, so this calculator works with any context you like. Use the units selector to label your data:
- Metric (SI): physics and engineering data — inertia tensors, stress/strain, coupled oscillators.
- US / Imperial: structural and mechanical engineering in US customary units.
- Currency (USD, RUB, EUR, GBP and more): covariance matrices, portfolio risk, and Markov transition models in finance.
FAQs
Is every matrix diagonalizable?
No. A matrix must have enough linearly independent eigenvectors. Matrices with complex eigenvalues or defective repeated eigenvalues cannot be diagonalized over the real numbers.
Are P and D unique?
No. Reordering the eigenvalues (and the matching eigenvector columns) gives a different but equally valid pair (P, D). Eigenvectors can also be scaled by any non-zero constant.
What is the point of diagonalization?
It turns hard matrix operations — powers, exponentials, solving linear systems of differential equations — into simple element-wise operations on the diagonal.
How big a matrix does this handle?
This tool diagonalizes 2×2 and 3×3 matrices, covering the vast majority of textbook and applied problems.