Does commutativity imply Associativity?

Does commutativity imply associativity? I’m asking this because I was trying to think of structures that are commutative but non-associative but couldn’t come up with any. Are there any such examples?

NOTE: I wasn’t sure how to tag this so feel free to retag it.

Solutions Collecting From Web of "Does commutativity imply Associativity?"

Consider the operation $(x,y) \mapsto xy+1$ on the integers.

A basic example is the “midpoint” binary operation: $a*b = \frac{a+b}{2}$

In general, if $P(u,v)$ is any polynomial in two variables with rational coefficients, then $x*y = P(x+y,xy)$ is rarely associative – I’d be curious under what conditions on $P$ this operation would be associative.

My example is $P(u,v)=\frac{u}{2}$ and Marlu’s example is $P(u,v)=1+v$.

The easiest Jordan algebra is symmetric square matrices with the operation
$$ A \ast B = (AB + BA)/2, $$
similar to a Lie algebra but with a plus sign.

Let $A = \{e,x,y\}$. Define $\cdot$ on $A$ to be $a\cdot e=a$ for all $a$, $e\cdot a= a$ for all a, and $a\cdot b=e$ for all $a$ and $b$ such that $a\neq e$ and $b\neq e$, (i.e. $a,b \in \{x,y\}$).

This operation is commutative, $e$ is the identity, (everything even has an inverse), but is not associative since $(x \cdot y) \cdot y = e \cdot y = y$ and $x \cdot (y \cdot y) = x \cdot e = x$.

Arguably the most important example of a commutative but non-associative structure is that of finite-precision floating point numbers under addition. (a + -a) + b is always equal to b but a + (-a + b) can differ from b since the sum -a + b can involve a loss of precision (this is especially true if a and b are nearly but not quite equal, -a + b could work out to 0 even though the corresponding real sum is nonzero). The lack of associativity of floating point arithmetic is a constant complicating factor in numerical analysis.

Consider the commutative operation $\texttt{vs}$ on the set $\{\textbf{rock}, \textbf{paper}, \textbf{scissors}\}$ abbreviated $\{r,p,s\}$ defined by
$$ \begin{array}{c|ccc}
\texttt{vs} & r&p&s\\ \hline
r & r & p & r \\
p & p & p & s \\
s & r & s & s
It is not associative since, for example, $$\textbf{paper} \texttt{ vs } (\textbf{scissors} \texttt{ vs } \textbf{rock}) = \textbf{paper}$$
$$(\textbf{paper} \texttt{ vs } \textbf{scissors}) \texttt{ vs } \textbf{rock} = \textbf{rock}.$$

The simplest examples of commutative but nonassociative operations are the NAND and NOR operations (joint denial and alternative denial) in propositional logic. To quote from my answer to another question:

Namely, the $2$-element structure $\{a,b\}$, where $aa=b$ and $ab=ba=bb=a$, is commutative but not associative. This is the unique (up to isomorphism) binary operation on a $2$-element set which is commutative but not associative; it can be interpreted as either of the truth-functions NOR or NAND.