{%hackmd 5xqeIJ7VRCGBfLtfMi0_IQ %}
# Find the spectral decomposition
## Problem
Let
$$
A = \begin{bmatrix}
0 & 0 & 1 & 1 \\
0 & 0 & 1 & 1 \\
1 & 1 & 0 & 0 \\
1 & 1 & 0 & 0
\end{bmatrix}.
$$
Find the spectral decomposition of $A$.
## Thought
The spectral decomposition of $A$ is a way to write $A$ as
$$
A = \sum_{j = 1}^q \mu_j P_j
$$
such that
- $P_i^2 = P_i$ for any $i$,
- $P_iP_j = O$ for any $i$ and $j$, and
- $\sum_{j=1}^q P_j = I_n$.
Intuitively, $P_j$'s are projection matrices whose ranges are orthogonal to each other and span the whole space.
In practice, we may first find the eigenvalues $\lambda_1, \ldots, \lambda_n$ and an orthonormal basis $\{\bu_1, \ldots, \bu_n\}$ of $\mathbb{R}^n$. Then
$$
\begin{aligned}
A &= \lambda_1\bu_1\bu_1\trans + \cdots + \lambda_n\bu_n\bu_n\trans \\
&= \mu_1P_1 + \cdots + \mu_qP_q,
\end{aligned}
$$
where $\mu_1, \ldots, \mu_q$ are the distinct eigenvalues of $A$ and $P_j$ is the sum of $\bu_i\bu_i\trans$ for all $\lambda_i = \mu_j$.
## Sample answer
According to [Find an orthonormal basis composed of eigenvectors](https://hackmd.io/@jephianlin/rJSU_qwm0), we already have $\lambda_1 = 2$, $\lambda_2 = -2$, $\lambda_3 = \lambda_4 = 0$. Thus, we may set $\mu_1 = 2$, $\mu_2 = -2$ and $\mu_3 = 0$ with $q = 3$.
The corresponding eigenvectors are $\bu_1$, $\bu_2$, $\bu_3$, and $\bu_4$. As $\bu_3$ and $\bu_4$ both correspond to the eigenvalue $\mu_3 = 0$, we will add them together to form a projection matrix onto $\ker(A - 0I)$. In summary, we have
$$
\begin{aligned}
A &= \lambda_1\bu_1\bu_1\trans + \lambda_2\bu_2\bu_2\trans + \lambda_3\bu_3\bu_3\trans + \lambda_4\bu_4\bu_4\trans \\
&= \mu_1\bu_1\bu_1\trans + \mu_2\bu_2\bu_2\trans + \lambda_3(\bu_3\bu_3\trans + \bu_4\bu_4\trans) \\
&= 2P_1 + (-2)P_2 + 0P_3,
\end{aligned}
$$
where
$$
P_1 = \frac{1}{4}\begin{bmatrix}
1 & 1 & 1 & 1 \\
1 & 1 & 1 & 1 \\
1 & 1 & 1 & 1 \\
1 & 1 & 1 & 1 \\
\end{bmatrix},\
P_2 = \frac{1}{4}\begin{bmatrix}
1 & 1 & -1 & -1 \\
1 & 1 & -1 & -1 \\
-1 & -1 & 1 & 1 \\
-1 & -1 & 1 & 1 \\
\end{bmatrix},
$$
and
$$
P_3 = \frac{1}{2}\begin{bmatrix}
1 & -1 & 0 & 0 \\
-1 & 1 & 0 & 0 \\
0 & 0 & 1 & -1 \\
0 & 0 & -1 & 1
\end{bmatrix},
$$
which is the spectral decomposition of $A$.
*This note can be found at Course website > Learning resources.*