When does this equality hold: $(A + B)^2 = A^2 + B^2$? Where $A$ and $B$ are matrices. Given
$A = 
\begin{bmatrix}
2 & -1 \\
2 & -1
\end{bmatrix}
$
and
$
B = 
\begin{bmatrix}
a & 1\\
b & -1
\end{bmatrix}
$
, what are the values of $a$ and $b$ if $(A+B)^2 = A^2 + B^2$?
I think if the equality holds then $AB + BA = 0$.
$
AB =
\begin{bmatrix}
2a-b & 3\\
2a-b & 3
\end{bmatrix}
$
and
$
BA = 
\begin{bmatrix}
2a + 2 & -a-1\\
2b-2 & -b + 1
\end{bmatrix}
$
$\therefore
AB + BA =
\begin{bmatrix}
4a-b+2 & 2 - a\\
2a+b-2 & 4-b\\
\end{bmatrix}
$
I think there are no values of $a$ and $b$ for which $AB+BA = 0$.
Is this correct, or are there any mistakes in my solution?

Yes. There are no such values.
For $AB+BA=0$, we must have $$a=2,b=4$$ and $$4a-b+2=0$$ that is simply not possible.
