Are all algebraic commutative operations always associative?

Two counterexamples have already been given, but here's another that seems a bit simpler and that comes up "naturally". Consider the set of all points on a line (or a plane, or 3-dimensional space --- it won't matter for the example) and let the operation send each pair $(P,Q)$ of points to the midpoint of the segment $PQ$.


Consider the set $M_n(\mathbb{R})$ and the binary operation $A * B = \frac{1}{2}(AB+BA)$

This isn't associative as

$A * (B * C) = A * \frac{1}{2}(BC + CB) = \frac{1}{4}(ABC + ACB + BCA + CBA)$

Yet

$(A * B) * C = \frac{1}{4}(ABC + BAC + CAB + CBA)$

and $BAC + CAB \neq ACB + BCA$ for all $A,B,C \in M_n(\mathbb{R})$

However, $A * B = \frac{1}{2}(AB+BA) = \frac{1}{2}(BA+AB) = B * A$

So it is commutative.


Nice question. First of all, it's important to note that commutativity does not imply associativity, i.e. one can construct a counterexample. Wikipedia has one, but - even simpler - consider $\mathbb R$ with the operation

$$ a \circ b := ab - (a+b). $$

Clearly $\circ$ is commutative, however e.g. $$1\circ (2\circ 3) = -1 \neq -5 = (1\circ 2)\circ 3.$$

Another question is whether such structures do arise naturally somewhere in mathematics. For most parts, associativity is a very fundamental property and we usually require commutativity on top of that (groups -> abelian groups, commutative rings ...)