Tutorials › Linear Algebra › Choosing and Ordering Eigenvectors in P

Diagonalization · Tutorial 533 of 1000

Choosing and Ordering Eigenvectors in P

Learn to arrange eigenvectors in \(P\), match their eigenvalues in \(D\), and reorder both consistently.

Intermediate 9 min read

What You'll Learn

  • Interpret the columns of an eigenvector matrix as an ordered list
  • Match each column with its eigenvalue on the diagonal of \(D\)
  • Check a proposed pairing using \(AP=PD\)
  • Reorder eigenvectors and eigenvalues consistently
  • Understand why repeated eigenvalues do not remove the need for a basis of eigenvectors
  • Detect and correct an eigenvector–eigenvalue ordering mismatch

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}\).

Definition: If \(\mathbf{v}_1,\dots,\mathbf{v}_n\) are eigenvectors of \(\mathbf{A}\), with respective eigenvalues \(\lambda_1,\dots,\lambda_n\), the associated ordered matrices are \(\mathbf{P}=\begin{bmatrix}\mathbf{v}_1&\cdots&\mathbf{v}_n\end{bmatrix}\) and \(\mathbf{D}=\operatorname{diag}(\lambda_1,\dots,\lambda_n)\). The \(i\)-th diagonal entry of \(\mathbf{D}\) must be the eigenvalue of the \(i\)-th column 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

Theorem: Let \(\mathbf{P}=\begin{bmatrix}\mathbf{v}_1&\cdots&\mathbf{v}_n\end{bmatrix}\) and let \(\mathbf{D}=\operatorname{diag}(d_1,\dots,d_n)\). Then \(\mathbf{A}\mathbf{P}=\mathbf{P}\mathbf{D}\) if and only if \(\mathbf{A}\mathbf{v}_i=d_i\mathbf{v}_i\) for every \(i\). If, in addition, the columns of \(\mathbf{P}\) form a basis of \(\mathbb{R}^n\), this is equivalent to \(\mathbf{A}=\mathbf{P}\mathbf{D}\mathbf{P}^{-1}\).

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:

$$ \mathbf{A}\mathbf{v}_1 =\begin{bmatrix}4&1\\0&2\end{bmatrix}\begin{bmatrix}1\\0\end{bmatrix} =\begin{bmatrix}4\\0\end{bmatrix} =4\mathbf{v}_1,\qquad \mathbf{A}\mathbf{v}_2 =\begin{bmatrix}4&1\\0&2\end{bmatrix}\begin{bmatrix}-1\\2\end{bmatrix} =\begin{bmatrix}-2\\4\end{bmatrix} =2\mathbf{v}_2. $$

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:

$$ \begin{bmatrix}1&-1\\0&2\end{bmatrix} \xrightarrow{R_2\to \frac12R_2} \begin{bmatrix}1&-1\\0&1\end{bmatrix} \xrightarrow{R_1\to R_1+R_2} \begin{bmatrix}1&0\\0&1\end{bmatrix}. $$

Check the pairing by computing both products:

$$ \mathbf{A}\mathbf{P} =\begin{bmatrix}4&1\\0&2\end{bmatrix}\begin{bmatrix}1&-1\\0&2\end{bmatrix} =\begin{bmatrix}4&-2\\0&4\end{bmatrix}, \qquad \mathbf{P}\mathbf{D} =\begin{bmatrix}1&-1\\0&2\end{bmatrix}\begin{bmatrix}4&0\\0&2\end{bmatrix} =\begin{bmatrix}4&-2\\0&4\end{bmatrix}. $$

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:

$$ \mathbf{A}\mathbf{P}' =\begin{bmatrix}-2&4\\4&0\end{bmatrix}, \qquad \mathbf{P}'\mathbf{D}' =\begin{bmatrix}-2&4\\4&0\end{bmatrix}. $$

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:

$$ \begin{bmatrix}1&1&0\\0&0&1\\0&3&0\end{bmatrix} \xrightarrow{R_2\leftrightarrow R_3} \begin{bmatrix}1&1&0\\0&3&0\\0&0&1\end{bmatrix} \xrightarrow{R_2\to \frac13R_2} \begin{bmatrix}1&1&0\\0&1&0\\0&0&1\end{bmatrix} \xrightarrow{R_1\to R_1-R_2} \begin{bmatrix}1&0&0\\0&1&0\\0&0&1\end{bmatrix}. $$

Multiplying verifies the assigned diagonal entries:

$$ \mathbf{A}\mathbf{P} =\begin{bmatrix}2&5&0\\0&0&2\\0&15&0\end{bmatrix}, \qquad \mathbf{P}\mathbf{D} =\begin{bmatrix}2&5&0\\0&0&2\\0&15&0\end{bmatrix}. $$

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}\):

$$ \begin{bmatrix}0&1&1\\0&0&1\\1&0&0\end{bmatrix} \xrightarrow{R_1\leftrightarrow R_3} \begin{bmatrix}1&0&0\\0&0&1\\0&1&1\end{bmatrix} \xrightarrow{R_2\leftrightarrow R_3} \begin{bmatrix}1&0&0\\0&1&1\\0&0&1\end{bmatrix} \xrightarrow{R_2\to R_2-R_3} \begin{bmatrix}1&0&0\\0&1&0\\0&0&1\end{bmatrix}. $$

The column-by-column products are:

$$ \mathbf{A}\mathbf{P} =\begin{bmatrix}0&1&2\\0&0&2\\3&0&0\end{bmatrix}, \qquad \mathbf{P}\mathbf{D} =\begin{bmatrix}0&1&2\\0&0&2\\3&0&0\end{bmatrix}. $$

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.

Theorem: Suppose the columns \(\mathbf{v}_1,\dots,\mathbf{v}_n\) form a basis of \(\mathbb{R}^n\) and satisfy \(\mathbf{A}\mathbf{v}_i=\lambda_i\mathbf{v}_i\). For any permutation \(\pi\), the reordered columns \(\mathbf{v}_{\pi(1)},\dots,\mathbf{v}_{\pi(n)}\) form a basis and give a diagonalization when paired with \(\operatorname{diag}(\lambda_{\pi(1)},\dots,\lambda_{\pi(n)})\).

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:

$$ \mathbf{A}\mathbf{P}'=\begin{bmatrix}-2&4\\4&0\end{bmatrix}, \qquad \mathbf{P}'\mathbf{D} =\begin{bmatrix}-4&2\\8&0\end{bmatrix}. $$

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.

  1. If the columns of \(\mathbf{P}\) are eigenvectors for eigenvalues \(2,5,2\), what is the matching diagonal matrix \(\mathbf{D}\)?
  2. 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?
  3. 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.
  4. Why does swapping two eigenvectors with the same eigenvalue leave \(\mathbf{D}\) unchanged but still change the column order in \(\mathbf{P}\)?
  5. 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.

Test yourself: Linear Algebra final exam practice

Ready to check what you know? Work a full-length practice final, then open the complete worked solutions.

Want all 1,114 practice problems?

This tutorial covers one topic. Calc Pass covers the full Calculus AB & BC curriculum (the core of Calculus I and II): full review, every practice question, and step-by-step solutions to each one.

QR code to download the Calc Pass app

Get the Calc Pass App

Scan to download and practice on the go, with instant scoring.

Calc Pass Volume 1: 1,114 Practice Questions book cover

Vol. 1: 1,114 Questions

The complete practice question bank, organized by AB & BC topic.

View on Amazon
Calc Pass Volume 2: Solutions Manual book cover

Vol. 2: Solutions Manual

Fully worked solutions to every question in Volume 1.

View on Amazon