# Is $(A+B)^2 = A^2 + B^2$ if $A$ and $B$ are matrices

If $A$ and $B$ are matrices is $(A+B)^2 = A^2 + B^2$?

I thought because, $AB + BA = AB - AB = 0$.

-
Consider matrices that are all zero except the entry in the top-left position. They will behave like numbers, which don't satisfy that in general. –  user141267 Apr 8 at 19:37
Or just consider $1\times1$ matrices. –  Christoph Apr 8 at 19:37
That works only for certain cases, anti-commutative matrices. –  Macavity Apr 8 at 19:43
Why did you think that $AB+BA=AB-AB$? This is quite not true! You can see this by picking at random two 2-by-2 matrices $A$ and $B$ and computing both sides of the equation. –  Mariano Suárez-Alvarez Apr 8 at 19:47
I'm not sure why did I think AB+BA=AB−AB :) I must have confused it with something else but I'm not sure what –  ergo_proxy Apr 8 at 19:57

$$(A+B)^2 = (A+B)(A+B) = A^2 + AB + BA + B^2 \neq A^2 + B^2$$

$(A+B)^2 = A^2 + B^2$ if and only if $AB + BA = 0 \iff AB = -BA$, but this is not true in general.

-
Moreover, you proved OP's statement is true iff $AB = -BA$. –  gt6989b Apr 8 at 19:40
@gt6989b I'm going to specify that, even though it should be clear. Thanks for the input! :-) –  Ant Apr 8 at 19:44

Consider the $1\times 1$ matrices. What do we know from algebra?

In fact this is called the "Freshman's Dream" and it appears that Kaj_H is trying to generalize this result for matrices (larger than $1\times 1$).

So in general if the characteristic of the field is $p$ (a prime) and the matrices are commutative then

$$(A+B)^{p^n} = A^{p^n} + p*Stuff + B^{p^n}$$

but then $p*Stuff=0$ because the characteristic of the field is $p$, so $$(A+B)^{p^n} = A^{p^n} + B^{p^n}$$

But this is a general group structure statement, we just need conditions on the field for which matrices are defined over. This is particularly simple to see if the matrices $A,B$ are diagonal, it reduces to the $1\times 1$ case for each (diagonal) entry.

-
I was about to post "Have you thought about $1 \times 1$-matrices??". –  Martin Brandenburg Apr 9 at 0:20

No this is not true. Consider $$\left[\pmatrix{1 & 0 \\ 0 & 1}+ \pmatrix{1 & 0 \\ 0 & 1}\right]^2 \neq \pmatrix{1 & 0 \\ 0 & 1}^2 + \pmatrix{1 & 0 \\ 0 & 1}^2$$ Note also that it is not in general true that $AB = -BA$. Consider the case where $A = B$.

-

In general, this is not the case. However, you can make it work with certain prior stipulations. For example, $(A+B)^2 = A^2 + B^2$ if both of the following properties hold:

1. $A, B \in M(2, \mathbb{Z_2})$
2. $A, B$ are both diagonal matrices or both matrices with zeros everywhere except in the top right corner.
-
(2) seems wrong; see Thomas' answer ($I$ is diagonal...) –  Mario Carneiro Apr 8 at 19:54
Note that I am working in $\mathbb{Z_2}$. Stipulation 1 is coupled with stipulation 2. Edited for clarity. –  Kaj Hansen Apr 8 at 19:57
Also, $A$ and $B$ don't have to be diagonal; they just need to anticommute, which in $\Bbb Z_2$ is the same as commuting. Thus only one needs to be diagonal. –  Mario Carneiro Apr 8 at 20:04
Sure. I admit that my properties are perhaps more restrictive than they necessarily need to be. I was simply trying to provide a concrete example that OP could study. –  Kaj Hansen Apr 8 at 20:06