Matrix Diagonalization Calculator with Steps

Find P, D, and P⁻¹ for a real 2×2 or 3×3 matrix, or identify why it is defective. Real and complex eigenbases are supported, and all values stay in your browser.

Enter Matrix A

Enter real integers, decimals, or scientific notation. Complex eigenvalues and eigenvectors are calculated when necessary.

Put rows on separate lines and separate entries with spaces, commas, or tabs. A valid 2×2 or 3×3 matrix changes the size automatically.

Diagonalization Result

Ready to calculate

Enter a valid matrix to test whether it has a complete eigenbasis.

Independent eigenvectors
Number field
Relative reconstruction error

Advertisement

Step-by-Step Diagonalization

Calculate a matrix to see its characteristic equation, eigenspaces, diagonalizability test, factors, and verification.

Matrix Diagonalization Formulas

Eigenvalues

det(λI − A) = 0

The roots become the diagonal entries of D.

Eigenvectors

(A − λI)v = 0

Choose enough independent eigenvectors to form the columns of P.

Diagonalization

A = PDP⁻¹ ⇔ D = P⁻¹AP

Each diagonal entry of D must match the eigenvalue of the same column of P.

Number field: The calculator first tests diagonalizability over . If nonreal eigenpairs are needed, it reports a diagonalization over . A matrix that has fewer than n independent eigenvectors is defective and cannot be diagonalized over either field.

How to Use the Calculator

  1. Select a 2×2 or 3×3 matrix and enter every real value, or paste a complete matrix.
  2. Choose the displayed precision; intermediate calculations keep full browser precision.
  3. Select Diagonalize matrix.
  4. Review the characteristic polynomial and eigenspaces. If the eigenvectors span the whole space, the result shows P, D, P⁻¹, and a reconstruction check.

Worked 2×2 Example

For A = [[4,1],[2,3]], the characteristic equation is λ² − 7λ + 10 = 0, so the eigenvalues are 5 and 2. Corresponding eigenvectors are proportional to [1,1]ᵀ and [1,−2]ᵀ.

P = [[1,1],[1,−2]], D = diag(5,2), and A = PDP⁻¹

Repeated eigenvalue

The identity matrix is diagonalizable because its repeated eigenspace has full dimension. By contrast, [[2,1],[0,2]] has only one eigenvector direction and is defective.

Complex diagonalization

The real rotation matrix [[0,−1],[1,0]] is not diagonalizable over , but it is diagonalizable over with eigenvalues i and −i.

How to Interpret P and D

The columns of P define an eigenvector coordinate system. The diagonal matrix D describes the same transformation in that basis: each coordinate is multiplied independently by its eigenvalue. The inverse P⁻¹ converts ordinary coordinates into the eigenbasis.

A repeated eigenvalue is not automatically a problem. Compare its algebraic multiplicity with its geometric multiplicity, the eigenspace dimension. A shortfall makes the matrix defective.

Matrix Diagonalization FAQs

What does it mean to diagonalize a matrix?

It means finding an invertible P and diagonal D such that A = PDP⁻¹. The columns of P are eigenvectors, and the corresponding eigenvalues appear in D.

Is every square matrix diagonalizable?

No. An n × n matrix needs n linearly independent eigenvectors over the chosen number field.

How does the calculator test diagonalizability?

It finds each eigenspace by complex row reduction and adds their dimensions. The matrix is diagonalizable when that total equals the matrix size.

Can a real matrix be diagonalizable only over ℂ?

Yes. Nonreal eigenvalues rule out a real diagonal matrix but may still supply a complete complex eigenbasis.

Why can my P and D differ from another correct answer?

Eigenvectors may be rescaled or reordered. The same rescaling or ordering must be reflected in the matching columns of P and diagonal entries of D.

What does reconstruction error mean?

It is the largest entrywise difference between A and PDP⁻¹, divided by the largest magnitude used for scale. Small nonzero values are expected from floating-point rounding.

Are my matrix values private?

Yes. Parsing, calculation, copying, and text-file creation happen locally in your browser. This page’s calculator code does not transmit or store matrix entries.

Calculation Notes and Limits

Last reviewed: August 5, 2026 by the Starlight Tools editorial team. The diagonalization condition and construction were checked against MIT Linear Methods lecture notes on diagonalization.

The calculator accepts finite real entries with magnitude no greater than 10⁹⁰ and matrices of size 2×2 or 3×3. It uses double-precision floating-point arithmetic, groups numerically indistinguishable roots with a relative tolerance, and normalizes eigenvectors for readable output. Nearly repeated eigenvalues and nearly defective matrices are sensitive to rounding; use exact or high-precision software when a proof or research-grade result is required.

Explore more tools