How to use Lagrange polynomials to express the matrix of a linear operator? I am currently going through some of the exercises in Linear Algebra by Hoffman and Kunze, 2nd edition, and I have come across a question that I don't know how to solve. This is Exercise 5 of Section 6.8.
Suppose $T$ is the diagonalizable linear operator on $\mathbb R^3$:
$$
A = \begin{bmatrix}
    1 & 0 & 0 \\
    0 & 2 & 0  \\
    0 & 0 & 2 
\end{bmatrix}.
$$
Now the part I don't understand is the following:

Use the Lagrange polynomials to write the matrix $A$ in the form 
$$A=E_1+2E_2,\:\: E_1+E_2=I,\:\:  E_1E_2=0.$$ 

I have the equation for $$p_j(x)=\frac{x-c_i}{c_j-c_i},$$ but I'm not sure how to apply it to a $3 \times 3$ matrix. Any help would be greatly appreciated. Thanks!
 A: You've stated the operator $T$ incorrectly. $T$ is the diagonalizable operator on $\mathbb{R}^3$ discussed in Example 3 in Section 6.2. It is represented in the standard basis of $\mathbb{R}^3$ by the matrix
$$
A = \begin{bmatrix}
\phantom{-}5 & -6 & -6 \\
-1 & \phantom{-}4 & \phantom{-}2 \\
\phantom{-}3 & -6 & -4
\end{bmatrix}.
$$
In the said example, the authors showed that $T$ has characteristic values $1$ and $2$, that it is diagonalizable, and a basis of $\mathbb{R}^3$ was computed in which $T$ is represented by the diagonal matrix
$$
\begin{bmatrix}
1 & 0 & 0 \\
0 & 2 & 0 \\
0 & 0 & 2
\end{bmatrix}.
$$
The purpose of the exercise is not to use the latter representation of the matrix, because that defeats the purpose – to use it you must have already computed the basis in which it has this nice form.
No, what we want to do is use the projection operators to describe the operator $T$ as it is given to us – with respect to the standard basis.
The method to do so is outlined on page 217. We compute the Lagrange polynomials corresponding to each of the characteristic values $c_1 = 1$ and $c_2 = 2$. In this case, they are simply given by
$$
\begin{align}
p_1 = \frac{x - 2}{1 - 2} = 2 - x,\\
p_2 = \frac{x - 1}{2 - 1} = x - 1.
\end{align}
$$
The projection maps $E_1$ and $E_2$ are then given by $p_1(T)$ and $p_2(T)$, respectively. So, $E_1$ is represented in the standard basis by the matrix
$$
2I - A = \begin{bmatrix}
2 & 0 & 0 \\
0 & 2 & 0 \\
0 & 0 & 2
\end{bmatrix} - \begin{bmatrix}
\phantom{-}5 & -6 & -6 \\
-1 & \phantom{-}4 & \phantom{-}2 \\
\phantom{-}3 & -6 & -4
\end{bmatrix} = \begin{bmatrix}
-3 & \phantom{-}6 & \phantom{-}6 \\
\phantom{-}1 & -2 & -2 \\
-3 & \phantom{-}6 & \phantom{-}6
\end{bmatrix}.
$$
and $E_2$ is represented in the standard basis by the matrix
$$
A - I = \begin{bmatrix}
\phantom{-}5 & -6 & -6 \\
-1 & \phantom{-}4 & \phantom{-}2 \\
\phantom{-}3 & -6 & -4
\end{bmatrix} - \begin{bmatrix}
1 & 0 & 0 \\
0 & 1 & 0 \\
0 & 0 & 1
\end{bmatrix} = \begin{bmatrix}
\phantom{-}4 & -6 & -6 \\
-1 & \phantom{-}3 & \phantom{-}2 \\
\phantom{-}3 & -6 & -5
\end{bmatrix},
$$
