Example for associative, commutative operations

3.7k Views Asked by At

I need examples of binary operations for real numbers that are

  1. associative and commutative
  2. associative but not commutative

The examples are for a programming class and need to be rather simple. Thus the operations have to work on real numbers and not on sets or matrices (which I would have to explain to the audience). The Fibonacci numbers would be a good counterexample.

The obvious choice for 1. would be multiplication and addition, but I would like to have another example to improve understanding.

Important is also that I need to be able to chain the operations. So the associative and commutative property should not only hold (or not hold) to a OPERATION b but also to a OPERATION b OPERATION c OPERATION d .... For example $a\ MEAN\ b := \frac{a + b}{2}$ is associative and commutative for only $a$ and $b $, but not for $a\ MEAN\ b\ MEAN\ c\ MEAN\ d$.

3

There are 3 best solutions below

2
On

Matrix multiplication is associative, but not commutative.

A different operation that is associative and commutative... addition and multiplication are really the canonical examples because if a binary operation "looks" like addition (or multiplication), we usually name it that. For example, the composition of two elements in a group, we call it multiplication in some situations since many times it behaves like the multiplication of two real numbers. If it does not, the word composition is used to describe the operation. So depending on what class of objects you are dealing with (i.e. real numbers, rigid motions of a regular polyhedron, infinitesimal rotations, etc.), there exists many examples of commutative associative binary operations that look and smell like multiplication, but are not exactly "multiplication of real numbers".

In short, it helps to know what exactly you are operating on - real numbers I'd assume. If that is the case, addition and multiplication are your best examples due to the real numbers being a mathematical structure called a "field".

0
On

(1) associative and commutative. Beyond ordinary addition and multiplication you could take a binary operation $x*y$ defined by:

$x*y=x+y+1$ (or any other constant eg $x*y=x+y+2$). Similarly, you could take $x*y=2xy$ or $x*y=3xy$ or $x*y=-xy$ etc.

Another idea would be $x*y=\max(x,y)$ or $x*y=\min(x,y)$.

(2) associative but not commutative. You could define a binary operation $x*y$ as:

$x*y=y$ or $x*y=x$ or $x*y=y+1$ or $x*y=x-2$ etc.

A more complicated example is $x*y$ has the integer part of $x$ and the fractional part of $y$, eg $2.331*3.156=2.156$ or $-3.256*1.235=-3.235$

Any examples for (2) are inevitably going to be artificial. I cannot think of any operations on the reals in common use which are associative but not commutative.

0
On

associative but not commutative

String concatenation:

"This is my interesting sentence."
= "This" + "is my" + "interesting" + "sentence."
= ( "This" + "is my" ) + ("interesting" + "sentence.")

but not

"This" + "interesting" + "sentence." + "is my"
= "This interesting sentence. is my"