Why the Order in \(P\) Matters
To diagonalize a matrix, it is not enough to collect eigenvectors and eigenvalues separately. Their order must match: the first diagonal entry of \(D\) belongs to the first column of \(P\), the second diagonal entry belongs to the second column, and so on. A correct collection with an incorrect pairing generally does not give a diagonalization.
Throughout, matrices and vectors have real entries. Let \(\mathbf{A}\in\mathbb{R}^{n\times n}\). An eigenvector of \(\mathbf{A}\) is a nonzero vector \(\mathbf{v}\) for which \(\mathbf{A}\mathbf{v}=\lambda\mathbf{v}\) for some scalar \(\lambda\), called its eigenvalue. For a diagonalization, the chosen eigenvectors must form a basis of \(\mathbb{R}^n\). We place that ordered basis into the columns of \(\mathbf{P}\).
The order is encoded in a simple equation. Multiplying \(\mathbf{A}\mathbf{P}\) applies \(\mathbf{A}\) to each column of \(\mathbf{P}\). Multiplying \(\mathbf{P}\mathbf{D}\) scales column \(i\) of \(\mathbf{P}\) by the \(i\)-th diagonal entry of \(\mathbf{D}\). Therefore the correct pairing gives \(\mathbf{A}\mathbf{P}=\mathbf{P}\mathbf{D}\). If the columns of \(\mathbf{P}\) form a basis, then \(\mathbf{P}\) is invertible and this equation is equivalent to \(\mathbf{A}=\mathbf{P}\mathbf{D}\mathbf{P}^{-1}\).
The Column-by-Column Test
Proof. The \(i\)-th column of \(\mathbf{A}\mathbf{P}\) is \(\mathbf{A}\mathbf{v}_i\), because matrix multiplication by \(\mathbf{P}\) applies \(\mathbf{A}\) to each column. Since \(\mathbf{D}\) is diagonal, the \(i\)-th column of \(\mathbf{P}\mathbf{D}\) is \(d_i\mathbf{v}_i\). Two matrices are equal exactly when all corresponding columns are equal. Thus \(\mathbf{A}\mathbf{P}=\mathbf{P}\mathbf{D}\) holds exactly when \(\mathbf{A}\mathbf{v}_i=d_i\mathbf{v}_i\) for every \(i\). If the columns form a basis, \(\mathbf{P}\) is invertible. Right-multiplying \(\mathbf{A}\mathbf{P}=\mathbf{P}\mathbf{D}\) by \(\mathbf{P}^{-1}\) gives \(\mathbf{A}=\mathbf{P}\mathbf{D}\mathbf{P}^{-1}\). Conversely, if that diagonalization equation holds, right-multiplying it by \(\mathbf{P}\) gives \(\mathbf{A}\mathbf{P}=\mathbf{P}\mathbf{D}\). \(\square\)
This gives a direct way to check a proposed ordering: compare the columns of \(\mathbf{A}\mathbf{P}\) and \(\mathbf{P}\mathbf{D}\). It also separates two requirements. The column equations check the eigenvalue pairings; the columns must also form a basis for \(\mathbf{P}\) to be invertible and give a diagonalization.
Worked Examples of Pairing and Reordering
Worked Example: Two Eigenvectors in Either Order
Let \(\mathbf{A}=\begin{bmatrix}4&1\\0&2\end{bmatrix}\). Use eigenvectors \(\mathbf{v}_1=\begin{bmatrix}1\\0\end{bmatrix}\) with eigenvalue \(4\), and \(\mathbf{v}_2=\begin{bmatrix}-1\\2\end{bmatrix}\) with eigenvalue \(2\). Form \(\mathbf{P}\) and \(\mathbf{D}\) in that order, then swap the eigenvectors and make the corresponding change to \(\mathbf{D}\).
First check the eigenvector equations:
With \(\mathbf{v}_1\) first and \(\mathbf{v}_2\) second, take \(\mathbf{P}=\begin{bmatrix}1&-1\\0&2\end{bmatrix}\) and \(\mathbf{D}=\begin{bmatrix}4&0\\0&2\end{bmatrix}\). The columns of \(\mathbf{P}\) form a basis, as row reduction shows:
Check the pairing by computing both products:
Now put \(\mathbf{v}_2\) first and \(\mathbf{v}_1\) second. The consistent choice is \(\mathbf{P}'=\begin{bmatrix}-1&1\\2&0\end{bmatrix}\) and \(\mathbf{D}'=\begin{bmatrix}2&0\\0&4\end{bmatrix}\). The products agree:
Check: the first column on each side is \(\mathbf{A}\mathbf{v}_2=2\mathbf{v}_2\), and the second is \(\mathbf{A}\mathbf{v}_1=4\mathbf{v}_1\). Both orders give a valid diagonalization because both matrices of columns are bases and the eigenvalues have been reordered with their eigenvectors.
Worked Example: Repeated Eigenvalues Still Need Matching Columns
Consider \(\mathbf{A}=\begin{bmatrix}2&0&1\\0&2&0\\0&0&5\end{bmatrix}\). Choose \(\mathbf{v}_1=\begin{bmatrix}1\\0\\0\end{bmatrix}\) and \(\mathbf{v}_3=\begin{bmatrix}0\\1\\0\end{bmatrix}\), each with eigenvalue \(2\), and \(\mathbf{v}_2=\begin{bmatrix}1\\0\\3\end{bmatrix}\), with eigenvalue \(5\). Use the order \((\mathbf{v}_1,\mathbf{v}_2,\mathbf{v}_3)\).
The eigenvector checks are \(\mathbf{A}\mathbf{v}_1=\begin{bmatrix}2\\0\\0\end{bmatrix}=2\mathbf{v}_1\), \(\mathbf{A}\mathbf{v}_2=\begin{bmatrix}5\\0\\15\end{bmatrix}=5\mathbf{v}_2\), and \(\mathbf{A}\mathbf{v}_3=\begin{bmatrix}0\\2\\0\end{bmatrix}=2\mathbf{v}_3\). Thus use \(\mathbf{P}=\begin{bmatrix}1&1&0\\0&0&1\\0&3&0\end{bmatrix}\) and \(\mathbf{D}=\operatorname{diag}(2,5,2)\). The columns are independent because these row operations reduce \(\mathbf{P}\) to the identity:
Multiplying verifies the assigned diagonal entries:
Check: the middle column is multiplied by \(5\), while the first and third columns are each multiplied by \(2\). The repeated diagonal entry does not make the ordering irrelevant: it is still the eigenvalue belonging to each column, and the three selected columns must still form a basis.
Worked Example: A Three-Eigenvalue Ordering
Let \(\mathbf{A}=\begin{bmatrix}1&1&0\\0&2&0\\0&0&3\end{bmatrix}\). Use the eigenvectors \(\mathbf{u}_1=\begin{bmatrix}1\\0\\0\end{bmatrix}\) for eigenvalue \(1\), \(\mathbf{u}_2=\begin{bmatrix}1\\1\\0\end{bmatrix}\) for eigenvalue \(2\), and \(\mathbf{u}_3=\begin{bmatrix}0\\0\\1\end{bmatrix}\) for eigenvalue \(3\). Arrange them in the order \((\mathbf{u}_3,\mathbf{u}_1,\mathbf{u}_2)\).
Indeed, \(\mathbf{A}\mathbf{u}_3=\begin{bmatrix}0\\0\\3\end{bmatrix}=3\mathbf{u}_3\), \(\mathbf{A}\mathbf{u}_1=\begin{bmatrix}1\\0\\0\end{bmatrix}=\mathbf{u}_1\), and \(\mathbf{A}\mathbf{u}_2=\begin{bmatrix}2\\2\\0\end{bmatrix}=2\mathbf{u}_2\). Therefore set \(\mathbf{P}=\begin{bmatrix}0&1&1\\0&0&1\\1&0&0\end{bmatrix}\) and \(\mathbf{D}=\operatorname{diag}(3,1,2)\). The columns are independent, as shown by reducing \(\mathbf{P}\):
The column-by-column products are:
Check: in this chosen order, the columns of \(\mathbf{A}\mathbf{P}\) are \(3\mathbf{u}_3\), \(\mathbf{u}_1\), and \(2\mathbf{u}_2\), exactly as prescribed by the diagonal entries \(3,1,2\).
Reordering Both Matrices Consistently
The examples illustrate a general fact. Let \(\pi\) be a permutation of the indices \(1,\dots,n\), meaning a rearrangement in which every index appears exactly once. Starting with eigenvectors \(\mathbf{v}_1,\dots,\mathbf{v}_n\) and corresponding eigenvalues \(\lambda_1,\dots,\lambda_n\), form a new ordered list \(\mathbf{v}_{\pi(1)},\dots,\mathbf{v}_{\pi(n)}\). The matching diagonal must then have entries \(\lambda_{\pi(1)},\dots,\lambda_{\pi(n)}\) in that order.
Proof. A permutation changes only the order of the vectors, not which vectors are in the list. Any linear combination of the reordered list can be written as a linear combination of the original list, with the coefficients assigned to the corresponding original indices. Since the original list is a basis, it is independent and spans \(\mathbb{R}^n\); the reordered list therefore has the same properties and is also a basis. For each position \(j\), its \(j\)-th column is \(\mathbf{v}_{\pi(j)}\), and \(\mathbf{A}\mathbf{v}_{\pi(j)}=\lambda_{\pi(j)}\mathbf{v}_{\pi(j)}\). The \(j\)-th diagonal entry of the proposed diagonal matrix is precisely \(\lambda_{\pi(j)}\). The column-by-column theorem now gives \(\mathbf{A}\mathbf{P}_{\pi}=\mathbf{P}_{\pi}\mathbf{D}_{\pi}\). Since the reordered columns form a basis, \(\mathbf{P}_{\pi}\) is invertible, so this equation gives a diagonalization. \(\square\)
When eigenvalues repeat, swapping two eigenvectors with the same eigenvalue leaves the diagonal matrix unchanged, but the columns of \(\mathbf{P}\) have still been swapped. More generally, one may choose a different basis within an eigenspace, provided the complete chosen list remains a basis of \(\mathbb{R}^n\) and each selected vector is paired with its own eigenvalue.
Common Mistake: Reordering Only \(P\)
For the first example, suppose the columns are swapped to form \(\mathbf{P}'=\begin{bmatrix}-1&1\\2&0\end{bmatrix}\), but the original \(\mathbf{D}=\operatorname{diag}(4,2)\) is kept. This incorrectly assigns eigenvalue \(4\) to \(\mathbf{v}_2\) and eigenvalue \(2\) to \(\mathbf{v}_1\). The products expose the mismatch:
They are not equal. The correction is to reorder the diagonal entries as well, using \(\mathbf{D}'=\operatorname{diag}(2,4)\), which gives \(\mathbf{A}\mathbf{P}'=\mathbf{P}'\mathbf{D}'\). A reliable check is to read each column of \(\mathbf{P}\) and ask which eigenvalue multiplies it; those values, in that order, are the diagonal entries of \(\mathbf{D}\).
Check Your Understanding
For each question, keep track of the ordered columns and verify any proposed pairing with the column equations.
- If the columns of \(\mathbf{P}\) are eigenvectors for eigenvalues \(2,5,2\), what is the matching diagonal matrix \(\mathbf{D}\)?
- Suppose \(\mathbf{A}\mathbf{P}=\mathbf{P}\mathbf{D}\), where \(\mathbf{D}=\operatorname{diag}(1,3)\). What eigenvalue equation does the second column of \(\mathbf{P}\) satisfy?
- A basis of eigenvectors has eigenvalues \(1,2,4\) in its current order. Write the diagonal entries after reordering the columns in the order third, first, second.
- Why does swapping two eigenvectors with the same eigenvalue leave \(\mathbf{D}\) unchanged but still change the column order in \(\mathbf{P}\)?
- For \(\mathbf{A}=\begin{bmatrix}4&1\\0&2\end{bmatrix}\), use the eigenvectors in the first worked example to show what goes wrong if they are swapped but the diagonal entries are not.