# Diagonal matrices - order of eigenvalues, eigenvalues and the resulting diagonal elements?

Consider matrix $A=\left[\begin{matrix}1 & -2\\-2 & 1\\\end{matrix}\right]$, with characteristic equation $\begin{vmatrix}1-\lambda & -2\\-2 & 1-\lambda\\\end{vmatrix}=(\lambda+1)(\lambda-3)$

$\lambda_1=-1$ gives eigenvector $\begin{bmatrix}1\\1\\\end{bmatrix}$ and $\lambda_2=3$ gives eigenvector $\begin{bmatrix}-1\\1\\\end{bmatrix}$, resulting in $P=\begin{bmatrix}1&-1\\1&1\\\end{bmatrix}$

$D=P^TAP=\begin{bmatrix}1&1\\-1&1\\\end{bmatrix}\begin{bmatrix}1&-2\\-2&1\\\end{bmatrix}\begin{bmatrix}1&-1\\1&1\\\end{bmatrix}$ gives me $D=\begin{bmatrix}-1&0\\0&3\\\end{bmatrix}$

But, the answer tells me it's supposed to be $D=\begin{bmatrix}3&0\\0&-1\\\end{bmatrix}$

Does the order of eigenvalues and eigenvectors make a difference? If so, how? Or is both of the resulting $D$ "equal" and correct? Also, maybe I made a mistake somewhere...

Thank you!

• It's $P^{-1}AP$ for eigenvalue decomposition. And no the order doesn't matter if you also change the order of the eigenvectors. – percusse Dec 8 '17 at 9:43

Or is both of the resulting $D$ "equal" and correct? Also, maybe I made a mistake somewhere...

Your answer is fine too, but it doesn't only change $D$, it's connected with $P$:

Does the order of eigenvalues and eigenvectors make a difference? If so, how?

The order of the eigenvalues on the diagonal in $D$, match the order of the corresponding eigenvectors in the columns of $P$ : if eigenvector $\vec v_i$ is in the $i$-th column of $P$, then the corresponding eigenvalue $\lambda_i$ is on the $i$-th (diagonal) position in $D$ and vice versa.

• Thank you! So it's just a matter of preference? If I want my i-th eigenvector to be the first "basis" then I use that in the first column of P, and its corresponding eigenvalue in the first diagonal position of D? Is that what you mean that it's "connected with P"? That it's dependent on my choice of P? – Defindun Dec 8 '17 at 10:11
• @Defindun Indeed: the order of the eigenvalues in $D$ is directly linked to the order of the (corresponding) eigenvectors in $P$. You can choose the order of the eigenvalues (in $D$) or the eigenvectors (in $P$), but one choice will determine the other. – StackTD Dec 8 '17 at 10:19
• Okey, so is there a "convention" or preference of what order to use? I wonder since my textbook actually told me the answer was the "opposite"? Thanks! – Defindun Dec 8 '17 at 10:24
• @Defindun I don't think there is a convention. In some contexts, you might want to order the eigenvalues in a specific way (e.g. if they're real, in ascending or descending order) but usually there is no real preference. When there are more possible answers, textbooks often only give one. This can be confusing as it doesn't necessarily mean that this answer is the only correct one... – StackTD Dec 8 '17 at 10:27

$D_1=\left(\frac1{\sqrt{2}}\begin{bmatrix}1&1\\-1&1\\\end{bmatrix}\right)\begin{bmatrix}1&-2\\-2&1\\\end{bmatrix}\left(\frac1{\sqrt2}\begin{bmatrix}1&-1\\1&1\\\end{bmatrix}\right)$ gives me $D_1=\begin{bmatrix}-1&0\\0&3\\\end{bmatrix}$

$D_2=\left(\frac1{\sqrt2}\begin{bmatrix}-1&1\\1&1\\\end{bmatrix}\right)\begin{bmatrix}1&-2\\-2&1\\\end{bmatrix}\left(\frac1{\sqrt2}\begin{bmatrix}-1&1\\1&1\\\end{bmatrix}\right)$ gives me $D_2=\begin{bmatrix}3&0\\0&-1\\\end{bmatrix}$

Yes, the order matters, also remember to normalize your matrix if you want them to be orthogonal.

The $i$-diagonal entry correspond to the $i$-th column of $P$.

• Thank you! So, it's necessary to normalize even for it to be orthogonal, not just to be orthonormal? – Defindun Dec 8 '17 at 10:12
• If you want to write $P^TAP$, it seems that you are assuming $P^T=P^{-1}$. We require the matrix to be orthogonal, that is the columns of the matrix forms an orthonormal basis. So yup, we have to normalize it. – Siong Thye Goh Dec 8 '17 at 10:18
• Alright, thank you very much! – Defindun Dec 8 '17 at 10:27