Is a monoid commutative if $(ab)^2=a^2b^2$? Let M be a monoid. Suppose that:
$(ab)^2=a^2b^2$
for any elements a,b in M. Is M commutative? The result is obviously true for groups, but I can't find a counterexample for monoids. And without cancellation law, I can't seem to show that it's true either.
 A: Let $M=\{0,1,2\}$ and
$$a*b=\begin{cases}a&b=0\\b&\text{otherwise}\end{cases} $$
A: Here's a less ad hoc way of getting a counterexample.  Consider the free monoid $F$ on $x$ and $y$.  Every element of $F$ is a word in $x$ and $y$.  Let $S\subset F$ be the set of words of length greater than $2$, and let $M$ be the quotient of $F$ by the equivalence relation that identifies all elements of $S$ together (it is easy to see this is a congruence relation).  Then $(ab)^2=a^2b^2$ for all $a,b\in M$, since any instance of this with $a,b\neq 1$ must have both sides be words of length greater than $2$.  However, it is not commutative because $xy\neq yx$.  Explicitly $M=\{1,x,y,xy,yx,\infty\}$ where any product that would give a word of length greater than $2$ is $\infty$.
The motivating idea here is that if there is any counterexample, then the universal example would be a counterexample.  That is, in $F$ modulo the congruence relation that identifies $(ab)^2$ and $a^2b^2$ for all $a,b\in F$, we would need $x$ and $y$ to commute.  Now, this equivalence relation is complicated and hard to think about, but we can notice that it only ever identifies words that have length at least $4$ (except in the trivial cases where $a$ or $b$ is $1$).  So we see we can use a larger equivalence relation that is easily verified to be a congruence, but which still does not identify $xy$ and $yx$.
A: This question can be answered by systematic search, but also by a simple example. If $\, x*y = x \,$ for all $\, x\,$ then $\, * \,$ is associative but not commutative.
Start with $\, M = \{0,1\} \,$ and extend with an identity element $\, e. \,$  Thus, let $\, M=\{0,1,e\}, \,$
where $\, e*x = x*e = x\,$ for all $\, x \in M \,$ and $\, x*y = x \,$ for all $\, x,y \in \{0,1\} .\,$ 
Now, $\, a^2 = a \,$ for all $\, a \in M \,$ and
$\, (a*b)^2 = a*b = a^2*b^2 \,$ for all $\, a,b \in M. \,$
This is the smallest example since any monoid with less than three elements is commutative. For three elements it is unique up to isomorphism and reversing the order of the binary operation.
