Matrix Diagonalization Checker

Determine whether a square matrix is diagonalizable. Compute eigenvalues, eigenvectors, algebraic and geometric multiplicities, and obtain the diagonal form D and transformation matrix P such that A = P D P⁻¹. Supports 2×2, 3×3, 4×4 and 5×5 matrices.

[
]
Enter real numbers for each matrix entry. Use decimals or fractions.
Examples: Diag 2×2 Defective 2×2 Diag 3×3 Defective 3×3 Diag 4×4 Defective 4×4
Privacy first: All computations are performed locally in your browser. No data is sent to any server.

What Is Matrix Diagonalization?

In linear algebra, a square matrix A is said to be diagonalizable if it is similar to a diagonal matrix. That is, there exists an invertible matrix P and a diagonal matrix D such that:

A = P D P⁻¹

The columns of P are the eigenvectors of A, and the diagonal entries of D are the corresponding eigenvalues. Diagonalization is one of the most powerful tools in linear algebra because it simplifies many matrix operations — raising a matrix to a power, computing exponentials, solving systems of differential equations, and more become trivial once the matrix is diagonal.

If A has n linearly independent eigenvectors, then A is diagonalizable.

The key condition: for every eigenvalue λ, the geometric multiplicity (dimension of the eigenspace) must equal the algebraic multiplicity (multiplicity as a root of the characteristic polynomial).

Why Diagonalization Matters

  • Computational efficiency: Powers of a diagonal matrix are computed by raising each diagonal entry to the power, making Aⁿ = P Dⁿ P⁻¹ extremely fast.
  • Differential equations: Systems of linear ODEs x' = A x are solved by diagonalizing A, decoupling the system into independent scalar equations.
  • Markov chains: The long-term behavior of a Markov chain is determined by the dominant eigenvalue and eigenvector of its transition matrix.
  • Principal component analysis (PCA): PCA relies on the eigen-decomposition of the covariance matrix to identify the principal directions of data.
  • Quantum mechanics: Observables are represented by Hermitian operators, which are always diagonalizable (spectral theorem).

How the Diagonalization Checker Works

The tool computes the characteristic polynomial det(A − λI) and finds its roots — the eigenvalues. For each eigenvalue λ, it solves the homogeneous system (A − λI)v = 0 to find the eigenvectors. The algebraic multiplicity of λ is the number of times it appears as a root; the geometric multiplicity is the dimension of the null space of (A − λI). The matrix is diagonalizable if and only if these two multiplicities are equal for every eigenvalue.

For 2×2 and 3×3 matrices, the tool uses exact analytic formulas (quadratic or cubic with Newton refinement). For 4×4 and 5×5 matrices, the characteristic polynomial coefficients are computed via the Faddeev–LeVerrier algorithm, and all roots are found simultaneously using the Durand–Kerner iteration. This robust numerical method ensures that all eigenvalues (including complex) are accurately located. The eigenvectors are then computed using Gaussian elimination. Finally, the decomposition is verified by reconstructing A from P, D, and P⁻¹, giving you confidence in the results.

Numerical accuracy: All computations are performed in double-precision floating-point. For well-conditioned matrices, the results are accurate to about 10⁻¹² relative error. The verification step provides a practical check; if the discrepancy exceeds 10⁻⁶, the tool will indicate a verification failure, alerting you to potential numerical issues.

Step-by-Step Process

  1. Select the matrix size (2×2, 3×3, 4×4, or 5×5) and enter its entries.
  2. The tool computes the characteristic polynomial and finds all eigenvalues (real and complex).
  3. For each eigenvalue, the algebraic multiplicity is recorded.
  4. The null space of (A − λI) is computed to obtain the eigenvectors and the geometric multiplicity.
  5. If all multiplicities match, the matrix is diagonalizable; the tool builds P and D.
  6. The decomposition is verified by computing P·D·P⁻¹ and comparing to the original matrix.

Examples & Case Studies

Example 1: Diagonalizable 2×2 Matrix

Consider A = [[2, 1], [1, 2]]. The characteristic polynomial is (λ−3)(λ−1) = 0, giving eigenvalues λ₁ = 3 and λ₂ = 1. Each has algebraic multiplicity 1. For λ₁ = 3, the eigenvector is (1, 1); for λ₂ = 1, the eigenvector is (1, −1). These are linearly independent, so A is diagonalizable. With P = [[1, 1], [1, −1]] and D = diag(3, 1), we have A = P D P⁻¹. This is a classic example of a symmetric matrix with distinct eigenvalues.

Example 2: Non-Diagonalizable (Defective) 2×2 Matrix

Consider A = [[1, 1], [0, 1]]. The characteristic polynomial is (λ−1)² = 0, so λ = 1 is the only eigenvalue with algebraic multiplicity 2. The eigenspace is spanned by (1, 0), so the geometric multiplicity is 1. Since 1 ≠ 2, the matrix is not diagonalizable. This is the prototypical defective matrix, often used to illustrate the importance of the geometric multiplicity condition.

Application: Population Dynamics

In ecology, the Leslie matrix model describes age-structured population growth. The matrix is usually diagonalizable, and the dominant eigenvalue gives the long-term growth rate, while the corresponding eigenvector gives the stable age distribution. For example, a Leslie matrix with fertility rates and survival probabilities can be analyzed using diagonalization to predict population trends and design conservation strategies.

Key Theorems & Conditions

Condition Diagonalizable? Example
All eigenvalues are distinct ✓ Always [[2,1],[1,2]]
Symmetric matrix (A = Aᵀ) ✓ Always (Spectral Theorem) [[1,2],[2,1]]
Algebraic multiplicity = Geometric multiplicity for every λ ✓ Yes [[2,0],[0,2]]
Some eigenvalue has algebraic multiplicity > geometric multiplicity ✗ No (defective) [[1,1],[0,1]]
Triangular matrix with distinct diagonal entries ✓ Yes [[2,1],[0,3]]

In practice, numerical rounding may cause very close but not exactly equal eigenvalues. The tool uses a tolerance of 10⁻⁸ for comparing algebraic and geometric multiplicities, which is suitable for most real-world applications.

The Spectral Theorem

One of the most beautiful results in linear algebra is the Spectral Theorem: every real symmetric matrix is orthogonally diagonalizable. That is, there exists an orthogonal matrix Q (Q⁻¹ = Qᵀ) such that Qᵀ A Q = D. This has profound implications in statistics (PCA), physics (principal axes), and optimization (quadratic forms). The theorem extends to Hermitian matrices in the complex setting.

The Jordan Canonical Form

For matrices that are not diagonalizable, the Jordan canonical form provides the next best thing. Every square matrix is similar to a block-diagonal matrix where each block is a Jordan block — a matrix with a single eigenvalue on the diagonal and 1's on the super-diagonal. The Jordan form reveals the structure of defective matrices and is essential in differential equations and control theory. Our checker identifies when a matrix is defective and explains why diagonalization fails.

Common Misconceptions

  • “All square matrices are diagonalizable.” False — defective matrices (like [[1,1],[0,1]]) are not diagonalizable.
  • “If a matrix has repeated eigenvalues, it is not diagonalizable.” False — consider the identity matrix I₂, which has λ = 1 (multiplicity 2) and is diagonal (and thus diagonalizable).
  • “Diagonalization only works for symmetric matrices.” False — many non-symmetric matrices are diagonalizable (e.g., [[2,1],[1,2]]).
  • “The eigenvectors of a diagonalizable matrix are always orthogonal.” False — orthogonality requires the matrix to be normal (AᵀA = AAᵀ), which includes symmetric matrices but not all diagonalizable matrices.

Applications Across Disciplines

  • Data Science & Machine Learning: PCA, LDA, and spectral clustering all rely on eigen-decomposition.
  • Engineering: Vibration analysis, control systems (state-space models), and structural mechanics.
  • Physics: Quantum mechanics (Hamiltonian operators), classical mechanics (normal modes), and electromagnetism.
  • Economics: Input-output models, Markov chains, and dynamic systems.
  • Computer Graphics: Principal component analysis for shape analysis, face recognition, and dimensionality reduction.

Rooted in linear algebra theory – This tool is built on the foundational work of Cayley, Hamilton, Jordan, and others. The implementation follows standard numerical methods for eigen-decomposition, with careful handling of edge cases. Verified against multiple authoritative references including Strang's Linear Algebra and Its Applications, Meyer's Matrix Analysis and Applied Linear Algebra, and the Matrix Cookbook. Reviewed by the GetZenQuery tech team, last updated July 2026.

Frequently Asked Questions

A square matrix A is diagonalizable if it is similar to a diagonal matrix D, i.e., there exists an invertible matrix P such that A = P D P⁻¹. This is equivalent to saying that A has a full set of linearly independent eigenvectors.

A matrix is diagonalizable if and only if, for every eigenvalue, the algebraic multiplicity equals the geometric multiplicity. Our tool computes both and tells you whether the condition holds.

The algebraic multiplicity of an eigenvalue λ is the number of times it appears as a root of the characteristic polynomial. The geometric multiplicity is the dimension of the eigenspace (the null space of A − λI). For diagonalizability, these must be equal for every eigenvalue.

Yes, over the complex numbers. For example, a rotation matrix has complex conjugate eigenvalues and is diagonalizable over C. Our tool handles complex eigenvalues and indicates diagonalizability in the complex sense.

Orthonormal diagonalization (or orthogonal diagonalization) requires the eigenvectors to be orthonormal, which is possible only for normal matrices (AᵀA = AAᵀ). Symmetric matrices are always orthogonally diagonalizable. Our tool gives the general diagonalization, which does not require orthogonality.

The tool uses double-precision arithmetic (≈ 15 decimal digits). For most matrices, the eigenvalues and eigenvectors are accurate to about 10⁻¹² relative error. However, for severely ill-conditioned matrices (e.g., nearly defective), the accuracy may degrade. The verification step (A ≈ P·D·P⁻¹) provides a practical check; if the discrepancy exceeds 10⁻⁶, the tool will indicate a verification failure, alerting you to potential numerical issues.

Currently the tool supports 2×2, 3×3, 4×4, and 5×5 real matrices. For larger sizes, the numerical methods become less reliable and the computational cost increases significantly.

Check out MathWorld, Khan Academy, or the classic text Linear Algebra and Its Applications by Gilbert Strang.
References: Strang, G. Linear Algebra and Its Applications (4th ed.); Meyer, C. Matrix Analysis and Applied Linear Algebra; MathWorld: Matrix Diagonalization; Wikipedia: Diagonalizable Matrix.
Validation: The tool has been tested against a wide range of matrices, including diagonal, defective, symmetric, and random matrices, with verification errors typically below 10⁻¹².