gizmobench

Eigenvalue Calculator

Type or paste a real matrix from 2 x 2 up to 6 x 6 and this returns every eigenvalue with the eigenvector that belongs to it. It is worked out the way numerical libraries do it, by balancing the matrix, reducing it to Hessenberg form and running a shifted QR iteration, rather than by writing down the characteristic polynomial and rooting it, which loses most of the accuracy of the entries once a matrix is bigger than 3 x 3. Three things then get shown that free calculators usually leave out: each pair is substituted back into the matrix and the residual of A v minus lambda v is printed beside it, the trace and determinant are checked against the sum and product of the eigenvalues, and a matrix with fewer eigenvectors than eigenvalues is called defective and given only the vectors it really has instead of a repeated one.

Matrix A2 x 2

A blank cell counts as 0. Paste a whole matrix into any cell and it fills the grid.

Eigenvalues and vectorsfull basis

characteristic polynomial λ² - 7λ + 10

  1. λ₁5residual 0v = (1, 1)
  2. λ₂2residual 2.2e-16v = (1, -2)

trace 7 = 5 + 2 det 10 = 5 x 2

2 eigenvalues and two independent eigenvectors.

λ₁
5
λ₂
2
Trace / det
7 / 10
Max residual
2.2e-16
Decimal places

A residual is the length of A v minus lambda v, with the vector scaled to length 1: it is how far this pair is from being exact, and 0 means the substitution came back exact in double precision. Vectors are printed divided through by their first entry, which is why a vector reads as (1, -2) rather than (-0.4472, 0.8944).

Three cases, worked

Each line below is computed by the same code that answers the calculator above, so the examples and the tool can never disagree.

  • [[4, 1], [2, 3]]λ² - 7λ + 10
    5 and 2, vectors (1, 1) and (1, -2)
  • Rotation [[0, -1], [1, 0]]a conjugate pair
    i and -i, vectors (1, -i) and (1, i)
  • Shear [[1, 1], [0, 1]]defective
    1 and 1, only one independent eigenvector
Accuracy. Eigenvalues are computed numerically for real matrices from 2 x 2 up to 6 x 6, and every pair is substituted back so the residual of A v minus lambda v is printed next to it. The trace and determinant are checked against the sum and product of the eigenvalues as a second test. A defective matrix returns only the eigenvectors that exist rather than a fabricated full basis, and a run that does not converge says so instead of returning a number.

Common questions

How are the eigenvalues found, if not from the characteristic polynomial?
By the same route a numerical library takes. The matrix is first balanced, which is a diagonal similarity that evens out the row and column sizes without changing any eigenvalue. It is then reduced by Householder reflections to Hessenberg form, one subdiagonal with zeros underneath. A Francis double-shift QR iteration runs on that form, chasing a bulge down the subdiagonal until a subdiagonal entry goes negligible and a block splits off: a 1 x 1 block gives a real eigenvalue, and a 2 x 2 block is solved from its own trace and determinant, which is where a complex pair comes from. Rooting the characteristic polynomial is avoided on purpose. Polynomial roots are violently sensitive to their coefficients, so forming the coefficients of a 5 x 5 or 6 x 6 and then solving throws away most of the accuracy the entries had. The polynomial is still printed for 2 x 2 and 3 x 3, where people want to see it and where it comes straight from the trace, the minors and the determinant.
What is the residual shown next to each eigenvalue?
It is the length of A v minus lambda v, with the eigenvector scaled to length 1. If lambda and v were exact, that would be zero, so the number is a direct measure of how far the pair is from exact, and it is comparable between pairs and between matrices because the vector always has the same length. For [[4, 1], [2, 3]] the tool returns 5 and 2 with vectors (1, 1) and (1, -2), and the residuals come back at 0 and 2.2e-16, which is to say the substitution is exact or one rounding step away from it. A residual near 1e-8 rather than 1e-16 is not a bug: it is what a repeated or nearly repeated eigenvalue can support, and seeing it is the point of printing it.
Why does my matrix have fewer eigenvectors than eigenvalues?
Because it is defective. The shear [[1, 1], [0, 1]] has the eigenvalue 1 twice, but every eigenvector of it is a multiple of (1, 0), so there is one independent direction for two eigenvalues and no basis of eigenvectors exists at all. The tool measures this rather than guessing: it counts the independent directions in the null space of A minus lambda I by elimination with complete pivoting, which is the geometric multiplicity of that eigenvalue. When that count comes out under the number of times the eigenvalue occurs, the extra copies are listed with no vector and the matrix is called defective. Printing the same vector twice, which is the common alternative, would suggest a second independent direction that does not exist. A repeated eigenvalue is not defective by itself: the identity times 2 has the eigenvalue 2 twice and a full pair of vectors.
Does it handle complex eigenvalues?
Yes, and they are the normal case for a rotation. The quarter-turn [[0, -1], [1, 0]] has no real eigenvector at all, and this returns i and -i with vectors (1, -i) and (1, i). A real matrix can only produce complex eigenvalues in conjugate pairs, so the second of a pair is given the exact conjugate of the first vector rather than whatever a separate solve happened to land on. Complex numbers are printed the way they are written by hand: i, -i, 3 + 4i, 3 - i.
Why is one of my eigenvalues 6.7e-16 instead of 0?
Because the arithmetic is done in double precision and the iteration cannot land on exact zero from a matrix that does not decouple. [[1, 2, 3], [4, 5, 6], [7, 8, 9]] is singular, so one eigenvalue is mathematically 0, and this returns 16.1168, -1.1168 and 6.7e-16. Showing that last value as a flat 0 would be a claim the arithmetic never made, so it is printed as the tiny number it is, with its residual beside it and the eigenvector (1, -2, 1) that goes with it. The determinant shown underneath is computed separately, by exact integer elimination when every entry is a whole number, so it reads 0 for that matrix and the gap between it and the product of the eigenvalues is where the rounding went.
How do I get a matrix in quickly, and what can a cell hold?
Paste it. A block of numbers dropped into any cell spreads across the grid from that cell and grows the grid to fit, so [[4, 1], [2, 3]], 4 1; 2 3 and two tab separated lines all arrive the same way. A cell takes a whole number, a decimal, exponent form like 1.5e-2, a fraction like 1/2, and the long minus sign that comes with anything copied out of a PDF. A blank cell counts as 0, so a mostly empty matrix still computes, though an entirely blank grid is refused rather than answered as the zero matrix. Sizes run from 2 x 2 to 6 x 6, the result can be shown at 4, 8 or 12 decimal places, and everything runs in your browser with nothing uploaded and no account.

Eigenvalues are computed numerically for real matrices from 2 x 2 up to 6 x 6, and every pair is substituted back so the residual of A v minus lambda v is printed next to it. The trace and determinant are checked against the sum and product of the eigenvalues as a second test. A defective matrix returns only the eigenvectors that exist rather than a fabricated full basis, and a run that does not converge says so instead of returning a number.