calculating eigen values from an equation 
I'm trying to use this equation(in yellow) to calculate the eigen values of B = \begin{pmatrix}
1&1&1\\
1&1&1\\
1&1&1\\
\end{pmatrix}
but I'm getting $$-λ^3+3λ^2-3λ$$
and the proper answer using the other method is
$$det( \begin{pmatrix}
1-λ&1&1\\
1&1-λ&1\\
1&1&1-λ\\
\end{pmatrix})$$
$$=-λ^3+3λ^2$$
Anyone see where I could have gone wrong or if the yellow equation only works in certain situations?

$\DeclareMathOperator\tr{tr}$The full proper formula for $n=3$ is:
$$\det(M-\lambda I_3)=(-1)^3\lambda^3 + (-1)^2\tr(M)\lambda^2 + (-1)\cdot \frac 12\big[(\tr M)^2-\tr(M^2)\big]\lambda + \det(M)$$
In this case:
$$\tr\begin{pmatrix}1&1&1\\1&1&1\\1&1&1\end{pmatrix}^2
=\tr \begin{pmatrix}3&3&3\\3&3&3\\3&3&3\end{pmatrix}
=9$$
So the result is indeed $-\lambda^3+3\lambda^2$.
