I took algebra 30 years ago, but I can’t remember the distinction between the commutative and associative properties. Can you sum it up in a word or two?
A binary operation is commutative if you can swap or commute the operands as in:
a + b = b + a
a * b = b * a
A Binary operation is associative if you can re-associate the operands in an expression with three or more as in:
a + (b + c) = (a + b) +c
a * (b * c) = (a * b) * c
So addition and multiplication are associatve and commutative. If you swap the operands of division or subtraction the result is, in general, not equal. If you re-associate the operands of subtraction or division the result generally changes. So division and subtraction are not commutative or associative.
Just to amplify the good Dr’s post:
When he said “binary”, he wasn’t refering to base-2 numbers. In this context, that means that you put two numbers (or other objects) in, and get one out, so addition, subtraction, multiplication, division, and exponentiation are all binary operations.
An example of an operation that is assosciative but not commutative is permutation (rearranging the elements of a list). For instance, suppose I start with the list A B C. If I swap the first two, and then swap the last two, I get B C A. On the other hand, if I swap the last two, and then the first two, I get C A B, which is different. I can’t think of any examples offhand of something that is communative but not associative, but I know that there’s a few. They’re just not usually as useful as assosciative operations.
As a tangent, ‘associativeness’ loses its meaning somewhat when you deal with prefix or suffix notation (prefix or Polish Notation = +ab adds a and b, suffix or Reverse Polish Notation (the RPN of Hewlett-Packard fame) = ab+ adds a and b) since there are no parenthesis like in infix, or algebraic, notation (infix or algebraic = a+b adds a and b). With RPN, you can form a ‘stack’ of numbers and then apply operations to them in a LIFO (Last In, First Out, like a stack of plates) order. For example, a + (b + c) in infix notation becomes a b c + + in RPN. This means that you pop off the first two numbers, add them, push the result onto the stack, then pop the result and the third number, add them, and push the result of that onto the stack and read it. Simple if you can visualize the stack (I can), maddeningly hard if you can’t. ‘Push’ and ‘pop’ are valid terms when dealing with RPN stacks, BTW. Of course, associativity still holds in some ways. For example, a - (b + c) becomes a b c + - in RPN and not a b c - +. Logical, really, if you think about it in terms of the stack. You can forget a lot of the algebraic rules in RPN, like order of operation and the use of parenthesis. In fact, all calculators use RPN at their most basic level. They just show you algebraic because that’s what most of us know.