<s>[INST] If $B^2$= this matrix, find $B$ Find the real matrix $B$ such that
$$ B^2 = \begin{pmatrix} 2 & 0 & 1 \\ 0 & 1 & 0 \\ 1 & 0 & 2 \end{pmatrix} $$
I think I am meant to use egenvalues to solve this, but would i find the egenvalues for $B^2$ or what? I am stuck on what to do.
 [/INST] This is not general as the other answers, but works in this case. We have $B^2=I+P $,  where $$P=\begin {bmatrix}1&0&1\\0&0&0\\1&0&1\end {bmatrix}. $$ As $2P=P^2$ and it commutes with $I $, we have $$(I+\alpha P)^2=I+2\alpha P+2\alpha^2P=I+(2\alpha +2\alpha^2)P . $$So we can choose  $\alpha= \frac{\sqrt3-1}2$. Thus
$$
B=I+\left(\frac {\sqrt3-1}2\right)\,P=\begin {bmatrix}\frac {\sqrt3+1}2&0&\frac {\sqrt3-1}2\\ 0&1&0\\ \frac {\sqrt3-1}2&0&\frac {\sqrt3+1}2\end {bmatrix}. $$
</s>