## Definition

Let $$A \in \mathbb{C}^{n \times n}$$. $$A$$ is said to be diagonalizable if there exist $$P$$ and $$D$$ in $$\mathbb{C}^{n \times n}$$ such that $$D$$ is a diagonal matrix and $$A = PDP^{-1}$$.

## Testing if a matrix is diagonalizable

$$A$$ is diagonalizable if and only if for every eigenvalue $$\lambda$$ of $$A$$, the algebraic multiplicity of $$\lambda$$ is equal to the geometric multiplicity of $$\lambda$$.

An equivalent characterization is that the sum of the geometric multiplicities of the eigenvalues of $$A$$ is $$n$$.

### Examples

1. Let $$A = \begin{bmatrix} 1 & 2\\ 0 & 1\end{bmatrix}.$$ Note that $$p_A = (1-\lambda)^2$$. Hence, the only eigenvalue of $$A$$ is $$1$$. Now $$A - I = \begin{bmatrix} 0 & 2\\ 0 & 0\end{bmatrix}.$$ The nullity of this matrix is $$1$$, implying that the geometric multiplicity is $$1$$, not $$2$$. So $$A$$ is not diagonalizable.

2. Let $$A = \begin{bmatrix} 4 & 0 & -2\\ 2 & 5 & 4\\ 0 & 0 & 5\end{bmatrix}.$$ Note that $$p_A = (4-\lambda)(5-\lambda)^2$$. So the eigenvalues are $$4$$ and $$5$$.

The geometric multiplicity of $$4$$ is $$1$$ since the geometric multiplicity cannot be $$0$$ and cannot exceed the algebraic multiplity of $$4$$, which is $$1$$.

Now, note that $$A - 5I = \begin{bmatrix} -1 & 0 & -2 \\ 2 & 0 &4 \\ 0 & 0 & 0\end{bmatrix}$$. This matrix has rank $$1$$ since the second row is $$-2$$ times the first row and the third row is a row of $$0$$'s. Hence, the nullity of $$A-5I$$ is $$2$$, implying that the geometric multiplicity of $$5$$ is $$2$$.

So $$A$$ is diagonalizable as the sum of the geometric multiplities is $$3$$.

## Finding $$P$$ and $$D$$

Now that we know the matrix $$A$$ in the second example above is diagonalizable, how do we actually find $$P$$ and $$D$$?

First, observe that $$A= PDP^{-1}$$ can be rewritten as $$AP = PD$$. Column $$i$$ of the left-hand side is given by $$AP_i$$ where $$P_i$$ denotes the $$i$$ column of $$P$$ and column $$i$$ of the right-hand side is given by $$PD_i$$. Since $$D$$ is a diagonal matrix, $$PD_i = D_{i,i} P_i$$. Thus $$P_i$$ must be an eigenvector with eigenvalue $$D_{i,i}$$. Since we need $$P$$ to be invertible, we need $$n$$ linearly independent eigenvectors. This is why we need the sum of the geometric multiplicities to equal $$n$$.

To form $$D$$, first list all the eigenvalues (including multiple appearances) in any order. (Hence, an eigenvalue with algebraic multiplicity $$k$$ will appear $$k$$ times in the list.) Then form $$D$$ with this list of values as the diagonal.

For our example, the list could be $$4,5,5$$. So we can set $$D = \begin{bmatrix} 4 & 0 & 0\\ 0 & 5 & 0\\0 & 0 & 5\end{bmatrix}$$.

To form $$P$$, first find a basis for each eigenspace. To form the first column of $$P$$, take a vector from the basis for the eigenspace of the first diagonal entry of $$D$$ and remove that vector from future inclusion into $$P$$. For each subsequent column $$i$$, take a vector from the basis for the eigenspace of the $$i$$th diagonal entry of $$D$$ and remove it from future includsion into $$P$$.

For our example, we first need to find a basis for the eigenspace of $$4$$ and a basis for the eigenspace of $$5$$.

For the eigenvalue $$4$$, we want to find a basis for the nullspace of $$A-4I = \begin{bmatrix} 0 & 0 &-2 \\ 2 & 1 & 4 \\ 0 & 0 & 1 \end{bmatrix}$$. Row-reducing this matrix to RREF gives the matrix $$\begin{bmatrix} 1 & \frac{1}{2} & 0 \\ 0 & 0 & 1 \\ 0 & 0 & 0 \end{bmatrix}$$. Hence, all solutions to $$\begin{bmatrix} 1 & \frac{1}{2} & 0 \\ 0 & 0 & 1 \\ 0 & 0 & 0 \end{bmatrix} \begin{bmatrix} x_1 \\ x_2 \\ x_3 \end{bmatrix} = \begin{bmatrix} 0 \\ 0 \\ 0\end{bmatrix}$$ are of the form $$\begin{bmatrix} x_1 \\ x_2 \\ x_3 \end{bmatrix} = \begin{bmatrix} -\frac{1}{2}s \\ s \\ 0\end{bmatrix} = s \begin{bmatrix} -\frac{1}{2} \\ 1 \\ 0 \end{bmatrix}$$ since $$x_2$$ is a free variable. Thus, the single vector $$\begin{bmatrix} -\frac{1}{2} \\ 1 \\ 0\end{bmatrix}$$ forms a basis for the eigenspace.

For the eigenvalue $$5$$, we want to find a basis for the nullspace of $$A - 5I = \begin{bmatrix} -1 & 0 & -2 \\ 2 & 0 &4 \\ 0 & 0 & 0\end{bmatrix}$$. Row-reducing this matrix gives $$\begin{bmatrix} 1 & 0 & 2 \\ 0 & 0 & 0 \\ 0 & 0 & 0\end{bmatrix}$$. Hence, all solutions to $$\begin{bmatrix} 1 & 0 & 2 \\ 0 & 0 & 0 \\ 0 & 0 & 0 \end{bmatrix} \begin{bmatrix} x_1 \\ x_2 \\ x_3 \end{bmatrix} = \begin{bmatrix} 0 \\ 0 \\ 0\end{bmatrix}$$ are of the form $$\begin{bmatrix} x_1 \\ x_2 \\ x_3 \end{bmatrix} = \begin{bmatrix} -2t \\ s \\ t\end{bmatrix} = s \begin{bmatrix} 0 \\ 1 \\ 0 \end{bmatrix} + t \begin{bmatrix} -2 \\ 0 \\ 1 \end{bmatrix}$$ since $$x_2$$ and $$x_3$$ are free variables. Hence, a basis for the nullspace is $$\left\{\begin{bmatrix} 0 \\ 1 \\0\end{bmatrix}, \begin{bmatrix} -2 \\ 0 \\ 1\end{bmatrix}\right\}$$.

To form the first column of $$P$$, we take a vector from the basis for the eigenspace of $$4$$. There is only one such vector. So $$P$$ is now $$P = \begin{bmatrix} -\frac{1}{2} & * & *\\ 1 & * & *\\ 0 & * & *\end{bmatrix}$$.

For the second column, we take a vector from the basis for the eigenspace of $$5$$. There are two vectors to choose from. We choose $$\begin{bmatrix} 0 \\ 1 \\0\end{bmatrix}$$. So $$P$$ is now $$P = \begin{bmatrix} -\frac{1}{2} & 0 & *\\ 1 & 1 & *\\ 0 & 0 & *\end{bmatrix}$$. And we have no choice but to take the remaining vector in the basis for eigenspace of $$5$$ to fill the last column of $$P$$. Hence, $$P = \begin{bmatrix} -\frac{1}{2} & 0 & -2\\ 1 & 1 & 0\\ 0 & 0 & 1\end{bmatrix}$$.

Note that $$P^{-1} = \begin{bmatrix} -2 & 0 & -4\\ 2 & 1 & 4\\ 0 & 0 & 1\end{bmatrix}$$. One can now verify that $$A = PDP^{-1}$$.

## Exercises

1. Let $$A = \begin{bmatrix} 1 & -2 \\ 1 & 0\end{bmatrix}$$, $$D = \begin{bmatrix} \frac{1+\sqrt{7}i}{2} & 0 \\ 0 & \frac{1-\sqrt{7}i}{2} \end{bmatrix}$$, and $$P = \begin{bmatrix} \frac{1+\sqrt{7}i}{2} & \frac{1-\sqrt{7}i}{2} \\ 1 & 1 \end{bmatrix}.$$

1. Find $$P^{-1}$$.

2. Check that $$A = PDP^{-1}$$.

2. Let $$A = \begin{bmatrix} 8 & -9 \\ 4 & -4 \end{bmatrix}$$. You are given that $$2$$ is the only eigenvalue of $$A$$. Give a basis for the eigenspace of this eigenvalue.