Diagonalize Matrix Calculator - Eigen Decomposition Solver

Diagonalize matrix calculator that returns eigenvalues, eigenvectors, and the S, D, and S^-1 decomposition for 2x2 and 3x3 matrices with a step-by-step check.

Updated: June 16, 2026 • Free Tool

Diagonalize Matrix Calculator

Choose 2x2 to enter four entries, or 3x3 to enter nine entries. The matching grid appears below.

2x2 matrix A

Top-left entry of the 2x2 matrix.

Top-right entry of the 2x2 matrix.

Results

Determinant det(A)
0
Trace tr(A) 0
Characteristic polynomial 0
Eigenvalue lambda1 0
Eigenvalue lambda2 0
Eigenvalue lambda3 0
Diagonalizable over the reals 0
Reconstruction error |A - S D S^-1| 0

Eigenvector matrix S

Diagonal matrix D

S inverse S^-1

Reconstruction S D S^-1

What Is Diagonalize Matrix Calculator?

A diagonalize matrix calculator turns a square matrix A into the product A = S D S^-1, where D is a diagonal matrix of eigenvalues and the columns of S are the matching eigenvectors. Type the four 2x2 or nine 3x3 entries, the calculator solves the characteristic polynomial, finds a unit-length eigenvector for each real eigenvalue, and prints S, D, S^-1 with a reconstruction check that confirms the product matches A. The tool also flags defective or complex-eigenvalue cases.

  • Linear-algebra homework: Verify hand calculations of eigenvalues, eigenvectors, and the A = S D S^-1 decomposition on 2x2 and 3x3 problems.
  • Powers of a matrix: Compute A^k quickly by raising the diagonal entries of D to the k-th power, the trick behind Markov chains and Fibonacci-style recurrences.
  • Coupled differential equations: Diagonalize the coefficient matrix of a decoupled ODE system so the solution reduces to one scalar exponential per eigenvalue.
  • PCA and graphics: Check small rotation, scale, and covariance matrices whose eigenvectors give principal axes and whose eigenvalues give explained variance.

The work behind diagonalization is the same in every textbook: solve det(A - lambda I) = 0, pick one non-zero vector from the null space of A - lambda I for each root, and stack those vectors as the columns of S. S D S^-1 then returns A exactly.

When the characteristic polynomial needs the scalar det(A), the determinant calculator handles the same 2x2 and 3x3 input in one pass.

How Diagonalize Matrix Calculator Works

The diagonalize matrix calculator reads the matrix, builds the characteristic polynomial det(A - lambda I), finds the real eigenvalues, picks a unit-length eigenvector for each one, and reconstructs A = S D S^-1 element by element.

A = S * D * S^-1, D = diag(lambda_1, ..., lambda_n), p(lambda) = det(A - lambda I) = 0
  • A: The input 2x2 or 3x3 square matrix of real numbers.
  • lambda: A real number such that A v = lambda v for some non-zero v.
  • D: The diagonal matrix whose entries are the eigenvalues of A.
  • S: The matrix whose columns are the eigenvectors of A.

For a 2x2 matrix A = [[a, b], [c, d]] the characteristic polynomial is p(lambda) = lambda^2 - (a + d) lambda + (ad - bc). The roots come from the quadratic formula.

For a 3x3 matrix the characteristic polynomial is p(lambda) = -lambda^3 + tr(A) lambda^2 - M_2 lambda + det(A), where M_2 is the sum of the three 2x2 principal minors. The calculator finds the real roots numerically, falls back to a + bi when only complex roots exist.

Worked 3x3 example: A = [[1, 0, 0], [2, 1, -1], [0, -1, 1]]

Row 1 = (1, 0, 0), Row 2 = (2, 1, -1), Row 3 = (0, -1, 1).

p(lambda) = -lambda^3 + 3 lambda^2 - 2 lambda. Real roots lambda = 0, 1, 2. Unit eigenvectors v_1 = (0, 1, 1) / sqrt(2), v_2 = (1, 0, 2) / sqrt(5), v_3 = (0, -1, 1) / sqrt(2).

S = columns of v_1, v_2, v_3. D = diag(0, 1, 2). S D S^-1 = A. Reconstruction error = 0.

The decomposition lets you read A^20 as S diag(0, 1, 2^20) S^-1, the trick behind taking a 3x3 matrix to a high power without a hundred manual multiplications.

According to Wikipedia, a square matrix A is diagonalizable over the real numbers if and only if there exists an invertible matrix S such that A = S D S^-1, where D is a diagonal matrix.

According to Wolfram MathWorld, a non-zero vector v is an eigenvector of A with eigenvalue lambda when A v = lambda v, and the columns of S in A = S D S^-1 are precisely these eigenvectors.

When you need to invert S without going through Gaussian elimination by hand, the adjoint matrix calculator returns adj(S) / det(S) in the same 2x2 and 3x3 grid.

Key Concepts Explained

Four ideas cover the entire diagonalization pipeline the calculator runs. They are the same concepts that show up in any linear-algebra textbook, so a quick look at them makes the S, D, S^-1 panel feel like a worked solution rather than a black box.

Eigenvalue lambda and A v = lambda v

A real number lambda is an eigenvalue of A when a non-zero vector v satisfies A v = lambda v. v is a direction along which A only stretches or compresses the input.

Characteristic polynomial p(lambda) = det(A - lambda I)

Subtract lambda from each diagonal entry of A and take the determinant. The roots are the eigenvalues of A.

Eigenvectors and the null space of A - lambda I

For each real eigenvalue lambda, the set of solutions to (A - lambda I) v = 0 is a vector subspace. Picking any non-zero vector gives an eigenvector.

A = S D S^-1

Stack one eigenvector per real eigenvalue as a column of S and the matching eigenvalues on the diagonal of D. Then A = S D S^-1 is the spectral decomposition.

These four ideas are the entire toolbox the calculator uses. The only bookkeeping is the multiplicity count: when an eigenvalue repeats, the geometric multiplicity must equal the algebraic multiplicity for the matrix to be diagonalizable.

Because the calculator normalizes every eigenvector to length 1, you can cross-check the column entries of S with a vector magnitude calculator to confirm the norm comes out to one.

How to Use This Calculator

Pick the matrix size, type the entries, and read the eigenvalues, eigenvectors, and the S, D, S^-1 panels in the right-hand column. The numbers update on every keystroke, so you do not need to press a separate Calculate button to see a new result.

  1. 1 Choose the matrix size: Select 2x2 for four entries, or 3x3 for nine entries. The matching grid appears below.
  2. 2 Type the matrix entries: Real numbers, decimals allowed. The determinant, trace, and characteristic polynomial update on every keystroke.
  3. 3 Read the eigenvalues: Real eigenvalues appear with four decimal places. Complex conjugate pairs appear as a + bi and a - bi.
  4. 4 Read S, D, and S^-1: S is the matrix of unit eigenvectors as columns, D is the diagonal eigenvalue matrix, and S^-1 is the matrix inverse of S.
  5. 5 Check the reconstruction: The bottom-right panel shows the product S D S^-1 element by element. The maximum absolute difference from A is reported in the reconstruction-error field.

Suppose a 3x3 coefficient matrix from a coupled ODE system is A = [[1, 0, 0], [2, 1, -1], [0, -1, 1]]. Switch to 3x3, type the entries, and read lambda = 0, 1, 2 with the matching eigenvector columns. S D S^-1 reconstructs A exactly.

When the same matrix is also used for multiplication, transpose, or other operations beyond diagonalization, the matrix calculator covers the general 2x2 and 3x3 linear-algebra workflow.

Benefits of Using This Calculator

The diagonalize matrix calculator keeps every step of the spectral decomposition on screen at once, so the user sees the characteristic polynomial, the eigenvalues, the eigenvector matrix, and the reconstruction check together.

  • 2x2 and 3x3 in one tool: A size selector swaps between the 4-entry 2x2 input and the 9-entry 3x3 input, covering the two sizes that show up in homework, ODE systems, and small covariance matrices.
  • Real-time characteristic polynomial: The closed-form p(lambda) updates on every keystroke, so the user can read the polynomial and the eigenvalues together when checking hand work.
  • Eigenvectors normalized to length 1: Each eigenvector is shown as a unit vector, so the S panel is consistent across different inputs and easy to compare with textbook examples.
  • A = S D S^-1 reconstruction check: The bottom-right panel multiplies S D S^-1 element by element and reports the maximum absolute difference from A. Zero means the decomposition is exact.
  • Defective and complex-eigenvalue handling: When the matrix has complex eigenvalues or fewer independent eigenvectors than its size, the calculator flags the matrix as not diagonalizable over the reals.

For small covariance matrices where principal-component analysis comes down to a single 2x2 or 3x3 eigen-decomposition, the linear regression calculator covers the regression side of the same workflow.

When the same matrix is also used for multiplication, transpose, or other operations beyond diagonalization, the matrix calculator covers the general 2x2 and 3x3 linear-algebra workflow.

Factors That Affect Your Results

A handful of input choices and structural facts decide whether the S, D, S^-1 panel lines up with the matrix you intended, and whether the diagonalization is meaningful at all.

Matrix size

The characteristic polynomial is quadratic for 2x2 and cubic for 3x3. The eigenvalue algorithm and the eigenvector null-space calculation differ.

Eigenvalue multiplicity

A repeated eigenvalue needs as many linearly independent eigenvectors as its algebraic multiplicity. When it does not, the matrix is defective.

Real vs complex eigenvalues

A 2x2 with negative discriminant or a 3x3 with only complex roots cannot be diagonalized over the real numbers. The calculator reports a + bi.

Singular matrices (det(A) = 0)

When det(A) = 0, at least one eigenvalue is zero. The diagonalization still exists when the rest of the structure allows it.

Decimal precision

Output is rounded to four decimal places for display, but the internal calculation uses full double precision. The reconstruction-error field shows the actual residual.

  • The calculator is restricted to 2x2 and 3x3 square matrices with real entries. For 4x4 and larger the cubic root finder would have to give way to a full QR iteration, outside the scope of this tool.
  • The displayed eigenvectors are normalized to length 1, so the S matrix is not unique; any scaled eigenvector is also valid and any column-wise sign change also gives a valid decomposition.
  • Numerical root finding for the 3x3 cubic can miss very close repeated roots; a small change in the inputs near a defective matrix can flip the geometric multiplicity and the diagonalizability verdict.

According to MIT OpenCourseWare 18.06 (Strang), a matrix is diagonalizable exactly when it has a full set of n linearly independent eigenvectors, in which case A = X Lambda X^-1 with X as the eigenvector matrix.

diagonalize matrix calculator showing a 2x2 and a 3x3 input grid with the eigenvalues, eigenvector matrix S, diagonal matrix D, and S^-1 result panels
diagonalize matrix calculator showing a 2x2 and a 3x3 input grid with the eigenvalues, eigenvector matrix S, diagonal matrix D, and S^-1 result panels

Frequently Asked Questions

Q: What does it mean to diagonalize a matrix?

A: Diagonalizing a matrix A means writing A = S D S^-1 where D is a diagonal matrix. The diagonal entries of D are the eigenvalues of A, and the columns of S are the corresponding eigenvectors. Once you have S, D, and S^-1, every polynomial in A reduces to the same polynomial in D, which is cheap to evaluate because D only has values on the diagonal.

Q: How do you diagonalize a 2x2 matrix step by step?

A: Compute the characteristic polynomial p(lambda) = lambda^2 - tr(A) lambda + det(A) and solve it with the quadratic formula. The two roots are the eigenvalues. For each real eigenvalue lambda, find a non-zero vector v that satisfies (A - lambda I) v = 0 and put those vectors as the columns of S. Then D = diag of the eigenvalues and A = S D S^-1.

Q: How do you diagonalize a 3x3 matrix?

A: Build p(lambda) = det(A - lambda I) = -lambda^3 + tr(A) lambda^2 - M_2 lambda + det(A), where M_2 is the sum of the three 2x2 principal minors. Find the real roots of that cubic, then for each real lambda find a non-zero vector v with (A - lambda I) v = 0. Stack those vectors as the columns of S, place the eigenvalues on the diagonal of D, and verify A = S D S^-1.

Q: How do you know if a matrix is diagonalizable?

A: A real matrix is diagonalizable over the reals when it has n real eigenvalues and each eigenvalue has as many linearly independent eigenvectors as its algebraic multiplicity. If the characteristic polynomial has complex roots, or if a repeated eigenvalue has fewer independent eigenvectors than its multiplicity, the matrix is not diagonalizable over the reals and the calculator reports it as such.

Q: Can every matrix be diagonalized?

A: No. A rotation matrix by 90 degrees has complex eigenvalues i and -i, and a Jordan block like [[1, 1], [0, 1]] has a repeated eigenvalue 1 with only one eigenvector, so neither is diagonalizable over the real numbers. Symmetric matrices and matrices with n distinct real eigenvalues are the most common diagonalizable cases.

Q: What is the formula A = S D S^-1 used for?

A: The decomposition A = S D S^-1 is the spectral decomposition of A. It is used to compute A^k cheaply (raise the diagonal entries of D to the k-th power), to decouple systems of differential equations, to compute matrix exponentials, and to find the principal axes and explained variance in principal component analysis.