# How to check the correctness of calculated eigenvalues?

Let's say you are given the following easy matrix:

$$\begin{bmatrix}{-1}&{0}\\ {1}&{1}\end{bmatrix}$$

and you've calculated the following two eigenvalues:

$\lambda_{1} = -1$

$\lambda_{2} = 1$

Is there a way to check whether the calculated eigenvalues are correct?

I know that with the eigenvectors you can just check everything all at once by checking it with this formula:

$$A. \vec{x} = \lambda \vec{x}$$

But how can you check the correctness of the computed results without having to calculate all the eigenvectors and fill in the formula?

• Check trace (T) and determinant (D): $T=0=\lambda_1+\lambda_2$ (OK) and $D=-1=\lambda_1\lambda_2$ (OK). Done. – Pierpaolo Vivo Jan 23 '16 at 19:35
• Are you sure the trace of a matrix is always equal 0? And the sum of the eigenvalues as well? – privetDruzia Jan 23 '16 at 19:37
• @privetDruzia: The trace of this particular matrix happens to be $0$. – Henning Makholm Jan 23 '16 at 19:39
• Never said that. The trace is the sum of diagonal entries, which is also equal to the sum of the eigenvalues (always). So the sum of diagonal entries of YOUR matrix (not ALL matrices) is $-1+1=0$, which is also equal to the sum of your eigenvalues. – Pierpaolo Vivo Jan 23 '16 at 19:39
• @PierpaoloVivo, that s the trick I'll always be using from now on! Does this also work for complex eigenvalues? Are there some corner cases this might not work? – privetDruzia Jan 23 '16 at 19:42

For a $2\times 2$ matrix $A$, the characteristic polynomial equation defining the eigenvalues is given by [https://en.wikipedia.org/wiki/Characteristic_polynomial] $$\lambda^2-(\mathrm{Tr}A)\lambda+\det(A)=0\ ,$$ where $A$ is the matrix trace (the sum of diagonal entries $a_{11}+a_{22}$), and $\det(A)$ is its determinant $a_{11}a_{22}-a_{12}a_{21}$. If you solve this equation, its two roots $\lambda_{1,2}$ are the eigenvalues of $A$. It follows from the general theory of quadratic equation that $\lambda_1+\lambda_2$ is equal to the coefficient of the $\lambda$ term (with a minus sign), while the product $\lambda_1\lambda_2$ is equal to the zeroth order (constant) term of the equation. Therefore, if you compute somehow two eigenvalues (call them $\mu_1,\mu_2$) and want to check whether they are correct or not, you need to verify that $\mu_1+\mu_2=a_{11}+a_{22}$ and $\mu_1\mu_2=a_{11}a_{22}-a_{12}a_{21}$. These two equations are sufficient to tell you with certainty whether your postulated eigenvalues are OK or not - but you need both conditions - you might easily engineer situations where the 'trace' test works, but the 'det' test fails (which means your postulated eigenvalues are wrong).

• didn't work for this example: imgur.com/ZqXZ1BC, I didn't even try to calculate the determinant as the first step of the check already fails. Did I misunderstand anything? – privetDruzia Jan 24 '16 at 9:10
• it works perfectly, instead: $-\frac{1}{2}-\frac{\mathrm{i} \sqrt{3}}{2}-\frac{1}{2}+\frac{i \sqrt{3}}{2}-2=-3$. – Pierpaolo Vivo Jan 24 '16 at 9:13
• For a $3\times 3$, the trace is the sum of the three diagonal elements – Pierpaolo Vivo Jan 24 '16 at 9:15
• How about the determinant? imgur.com/e0OLqYZ – privetDruzia Jan 24 '16 at 9:29
• wikihow.com/Find-the-Determinant-of-a-3X3-Matrix You'd need to check that the determinant computed from the entries of the matrix agrees with the product of eigenvalues you have computed. Let me further remark that the trace-det test is only conclusive for $2\times 2$ matrices. For larger sizes, it is a quick and nice crosscheck, but it is not conclusive. For instance, you might engineer a $3\times 3$ matrix $A$ and find three numbers $\{\mu_1,\mu_2,\mu_3\}$ such that the trace of $A$ (sum of diagonal elements) is equal to $\mu_1+\mu_2+\mu_3$, the determinant of $A$ is equal to... – Pierpaolo Vivo Jan 24 '16 at 10:20

Suppose you have a $2\times 2$ matrix, A. You can use the fact that $$\lambda^2 -\lambda\tau(A)+\det(A)=0$$ Where $\tau(A)$ is the trace of your matrix $A$.

• which eigenvalue does $\lambda$ refer to? the first, second or sum? Does this work for imaginary eigenvalues? – privetDruzia Jan 23 '16 at 19:38
• @privetDruzia: The characteristic polynomial of the $2 \times 2$-matrix $A$ is given by $P(X) = X^2 - \tau(A)X + \det(A)$, so this is just a reformulation of the fact that the eigenvalues are roots of the characteristic polynomial. So it holds for all eigenvalues of $A$. – Jendrik Stelzner Jan 23 '16 at 19:47
• Yes, it works for both $\lambda_1$ and $\lambda_2$. – fosho Jan 23 '16 at 19:49