Q:

Projections onto Matrices

I just need some guidance whether I have the concept down.
Consider a $2\times 2$ matrix together with the inner product $\langle A, B\rangle= \operatorname{Trace}(A^TB)$, and let 
$$W=\operatorname{Span} \left( \begin{bmatrix} 1&0 \\ 0&1 \end{bmatrix}, \begin{bmatrix} 1&1\\1&1\end{bmatrix}\right)$$
i) Find the matrix in W closest to
$$C=\begin{bmatrix}1&1\\-3&3\end{bmatrix}$$ where $A$ is the first matrix of the span, $B$ is the second
$$\text{Projection} =\frac{\langle C, A\rangle}{\|A\|^2} \cdot A + \frac{\langle C, B\rangle}{\|B\|^2} \cdot B = \frac{4}{2} \cdot \begin{bmatrix} 1&0 \\ 0&1 \end{bmatrix}+\frac{2}{8} \cdot \begin{bmatrix} 1&1\\1&1\end{bmatrix} = \begin{bmatrix} \frac{18}{8}&\frac{2}{8}\\ \frac{2}{8}&\frac{18}{2}\end{bmatrix}$$
Is this the closest matrix? Thanks for the help

A:

The projection formula you have quoted is true only when $A$ and $B$ are orthogonal.  In this case
$$\langle A,B\rangle={\rm trace}\, B=2\ ,$$
so the formula does not apply.  One way to solve the problem is as follows.  The required projection will have the form
$$P=\lambda_1A+\lambda_2B\ ,\tag1$$
and we can write
$$C=\lambda_1A+\lambda_2B+M\ ,\tag2$$
where $M$ is orthogonal to both $A$ and $B$.  Take the inner product of both sides with $A$ to get
$$\langle A,C\rangle=\lambda_1\langle A,A\rangle+\lambda_2\langle A,B\rangle
  +\langle A,M\rangle\ .$$
Noting that $\langle A,M\rangle=0$ and doing the calculations for the other inner products gives
$$2\lambda_1+2\lambda_2=4\ .$$
Now take the inner product of both sides of $(2)$ with $B$ to get another equation, solve to find $\lambda_1,\lambda_2$, substitute back into $(1)$ to find $P$.

