Matrix Diagonalization Calculator

Enter the four entries of a 2×2 matrix to diagonalize it.

How it is calculated

For the matrix [[a, b], [c, d]] the tool computes the trace tr = a + d and determinant det = ad − bc. The eigenvalues are the roots of λ² − tr·λ + det = 0, that is λ = (tr ± √(tr² − 4·det)) ÷ 2. The larger root is shown first. If the discriminant is negative the eigenvalues are complex and the tool returns no result. A repeated eigenvalue is accepted only for a scalar matrix (b = c = 0 and a = d); any other matrix with a repeated eigenvalue cannot be diagonalized and shows nothing. Each eigenvector is taken as [b, λ − a] (or [λ − d, c] when b is zero), left unnormalised and printed to 4 decimals; a diagonal matrix gives [1, 0] and [0, 1]. The columns of P are the eigenvectors and D has the eigenvalues on its diagonal, so A = P·D·P⁻¹. You assemble P and D yourself. Scaled copies of an eigenvector are equally valid.

Worked example

Take [[4, 1], [2, 3]]. Trace = 7, determinant = 4 × 3 − 1 × 2 = 10. The discriminant is 49 − 40 = 9, with square root 3. So λ1 = (7 + 3) ÷ 2 = 5.0000 and λ2 = (7 − 3) ÷ 2 = 2.0000. Eigenvector for 5: [b, λ − a] = [1.0000, 1.0000]. Eigenvector for 2: [1.0000, -2.0000]. Check: A × [1, 1] = [5, 5] = 5 × [1, 1]. So D = diag(5, 2) and P has columns [1, 1] and [1, −2]. The determinant shown is 10.0000.

Try this example →

Common mistakes

  • Feeding in a rotation-like matrix such as [[0, −1], [1, 0]]. Its eigenvalues are complex, so the tool returns nothing; it works only with real eigenvalues.
  • Entering the entries in column order instead of row order. The fields are a, b (top row) and c, d (bottom row); swapping b and c transposes the matrix and changes the eigenvectors.
  • Expecting an answer for a shear such as [[1, 1], [0, 1]]. It has a repeated eigenvalue but only one independent eigenvector, so it is not diagonalizable and the tool shows no result. Only the identity-like scalar matrix [[3, 0], [0, 3]] passes with a repeated value.
  • Expecting one fixed eigenvector. Any non-zero multiple is correct, so [1, 1] and [2, 2] describe the same direction, and the tool does not normalise to unit length.
  • Ignoring the order of the eigenvalues. The larger one is always listed first, so on [[2, 0], [0, 5]] the first eigenvector is [0, 1] and the second is [1, 0]; build P and D in the same order.

About this calculator

Diagonalizing a 2×2 matrix A means writing it as A = PDP⁻¹, where D is a diagonal matrix of A's eigenvalues and P's columns are the corresponding eigenvectors. This calculator finds the eigenvalues by solving the characteristic equation det(A − λI) = 0 (a quadratic for a 2×2 matrix), finds each eigenvalue's eigenvector by solving (A − λI)v = 0, and shows the two eigenvalues (the diagonal of D), their eigenvectors (the columns of P) and the determinant. When the matrix isn't diagonalizable over the reals — its eigenvalues are complex, or a repeated eigenvalue doesn't have enough independent eigenvectors — no result is shown.

Linear algebra students and engineers diagonalize matrices because it makes repeated operations trivial — computing Aⁿ reduces to PDⁿP⁻¹, where raising a diagonal matrix to a power just means raising each diagonal entry — which is exactly how closed-form solutions to linear recurrence relations (like the Fibonacci sequence) and systems of linear differential equations are derived, and it's a core step in principal component analysis and vibration/eigenmode analysis in mechanical engineering.

Was this helpful?

You can pick up to 3 reactions.

Comments (1)

  • Editorial team

    Check the eigenvalues with two identities: they add up to the trace and multiply to the determinant. For the default matrix, 3 + 1 equals the trace 4, and 3 × 1 equals the determinant 3. The tool covers real 2×2 matrices only. Which matrix size would you like supported next, and do you need complex eigenvalues too?

Popular calculators

All Calculators