Commutativity vs Associativity

  • Thread starter kenewbie
  • Start date
  • #1
239
0
Commutativity: a + b = b + a

Associativity: (a + b) + c = a + (b + c)

To me these two say the exact same thing: Order does not matter.

How are they different? Surly it is more than the number of values being added, otherwise we would need a new rule for 4 elements, yet another for 5 and so on.

k
 

Answers and Replies

  • #2
They also say that ab=ba and (ab)c = a(bc) infact. The first one says that you can reverse the order of operations and receive the same result. The second says that you can switch around items in the parenthesis and return the same result.

A laymen's explanation as to why this is important is that you can deal with things such as operators where if you define operators A, B, and C, associativity and commutativity may not hold. In fact, with operators, AB in general does NOT equal BA. You can also deal with things called Grassmann numbers which don't commute. Someone else can probably give you a more thorough explanation.
 
  • #3
They also say that ab=ba and (ab)c = a(bc) infact.

Sure, but let us stick to addition. The laws are used all over the place, but it is easier to just discuss one specific case.

The first one says that you can reverse the order of operations and receive the same result. The second says that you can switch around items in the parenthesis and return the same result.

But "switching around items in the parenthesis" is the same as altering the order.

a + (b + c) = b + c + a = a + b + c

k
 
  • #4
Yes, both commutativity and associativity tell you that the order does not matter in a sense, but there is a difference.

The statement (a + b) + c = a + (b + c) implicitly says that we can first add a and b, then add c (giving us the left hand side) or alternatively, we can first add b and c, then add a (the right hand side). Either way, the resulting expressions are equal, so we might as well remove parentheses altogether and just denote the sum a + b + c. So again, associativity of addition tells us that no matter how we group the different possible ways of summing 3 or more numbers using parentheses (grouped in a way as to indicate which two numbers should be added first), we get the same sum, so we can just do without the parentheses.

Commutativity is more of a direct statement about the placement of the numbers. It doesn't matter which of the two numbers are added first, what matters is that if we have a + b, then reversing the order of these two numbers gives b + a, and these two expressions are equal.

So while associativity tells us that instead of (a + b) + c, we could have added b + c first, commutativity tells us that if we switch the order of (a + b) + c, we get c + (a + b), and these last two expressions are equal.
 
  • #5
But "switching around items in the parenthesis" is the same as altering the order.

a + (b + c) = b + c + a = a + b + c
Actually it's not... take matrix multiplication as an example:

[tex]\left(\begin{matrix}2 & 1 \\ 1 & 0\end{matrix}\right) \left(\begin{matrix}-2 & -1 \\ 1 & 0\end{matrix}\right) = \left(\begin{matrix}-5 & -2 \\ 2 & 1\end{matrix}\right)[/tex]
[tex]\left(\begin{matrix}-2 & -1 \\ 1 & 0\end{matrix}\right) \left(\begin{matrix}2 & 1 \\ 1 & 0\end{matrix}\right) = \left(\begin{matrix}-3 & -2 \\ -2 & -1\end{matrix}\right)[/tex]
So multiplication of matrices is not commutative. But:
[tex]\left(\begin{matrix}2 & 1 \\ 1 & 0\end{matrix}\right) \left(\left(\begin{matrix}-2 & -1 \\ 1 & 0\end{matrix}\right) \left(\begin{matrix}1 & 1 \\ 1 & -1\end{matrix}\right)\right) = \left(\begin{matrix}-3 & -7 \\ -1 & -3\end{matrix}\right)[/tex]
[tex]\left(\left(\begin{matrix}2 & 1 \\ 1 & 0\end{matrix}\right) \left(\begin{matrix}-2 & -1 \\ 1 & 0\end{matrix}\right)\right) \left(\begin{matrix}1 & 1 \\ 1 & -1\end{matrix}\right) = \left(\begin{matrix}-3 & -7 \\ -1 & -3\end{matrix}\right)[/tex]
Thus matrix multiplication is associative. (Of course, just because this particular product is associative doesn't mean matrix multiplication is always associative, but it's possible to prove that it is in general.) This should at least show you that commutativity is not the same thing as associativity; if it were, then the fact that matrix multiplication is associative would automatically mean that it would be commutative as well.

Note that the operation of addition (on numbers, matrices, vectors) happens to be commutative and associative. So if you say "let's stick to addition" you'll never be able to convince yourself that commutativity and associativity are not the same thing.
 
  • #6
So again, associativity of addition tells us that no matter how we group the different possible ways of summing 3 or more numbers using parentheses (grouped in a way as to indicate which two numbers should be added first), we get the same sum, so we can just do without the parentheses.

But doesn't this come from commutativity? If the order in which you add values does not matter, then parentheses have no meaning.

I'm sorry I'm so slow, I just can't see why associativity is needed :/ (or how it is different from commutativity for that matter).

k
 
  • #7
No, you're not being slow, my explanation wasn't clear enough. Rather, I danced around the usage of the word order. Note that associativity is a statement about the order of operations. Yes, in the end, we might as well denote a + b + c as the 6 different possible ways of writing the sum of three numbers. But these are axioms, so we are really working with obvious statements, but ensuring that the conceivable difficulties are taken care of.

So for associativity, we are worried about how the terms are grouped together. Which numbers should be added first? The answer is that the order of OPERATIONS does not matter as long as the order of the operands are not changed (think about what this means for a minute). Keeping my previous explanation in mind, we simply place parentheses around the terms that we indicate should be added first. The problem is that if we add b and c first, and then a, then this sum is conceivably different from adding a and b first and then c. Of course, our axiom tells us that the sum is the same. So that adding b and c first then adding a is a + (b + c) and this is the same as adding a and b first, then c. Notice that we write this as a + (b + c) = (a + b) + c, so we are simply placing parentheses around the terms in which we think should be added first, but we are NOT changing the sequence of the actual operands. We are not saying that a + (b+c) = (b+c) + a because this is reversing the order (or changing the sequence) of the operands a and (b + c). Associativity only allows us to place parentheses around terms in which we think should be added first, and tells us that it doesn't matter where we place the parentheses as long as the sequence of the operands is not changed. In other words, it justifies a change in the order of operations, provided that the order of the operands is not changed.

On the other hand, commutativity is concerned with the conceivable problem that reversing the sequence of operands in a sum might give us a different number, but this is not true. Hence, adding a pair of numbers does not depend on the order in which we add them. We are no longer talking about the order of operations, but rather the order of the operands. In the above case for commutativity, we can't really say anything about the order of operations, since we only have two numbers (for instance, it doesn't make sense to say "add a first and then b"). But we can talk about the sequence of the operands, specifically, if we reverse the order of the two numbers, our sum will not change, i.e. a + b, where a comes before b in the sequence of operands, is equal to b + a, where the sequence of operands has been reversed (b now comes before a).
 
Last edited:
  • #8
Note that the operation of addition (on numbers, matrices, vectors) happens to be commutative and associative. So if you say "let's stick to addition" you'll never be able to convince yourself that commutativity and associativity are not the same thing.

Aha. That's a good point, thank you.

I appreciate the example with the matrices, even though I do not know how to operate on those yet.

Do you happen to have a more basic example where one holds and the other does not?

From Wikipedia:

"The associative property is closely related to the commutative property. The associative property states that the order in which operations are performed does not affect the final result as long as the order of terms is not changed. In contrast, the commutative property states that the order of the terms does not affect the final result."

I think I am perhaps starting to see the difference. Associativity = the order of the operators. Commutativity = the order of the values. When you alter the parentheses of an expression, you are changing the order in which the operators are executed.

So, let me test myself and please let me know if I am wrong.

a + b = b + a .. by commutativity
a + b + c = c + b + a .. by commutativity
(a + b) + c = c + (a + b) .. by commutativity
c + (a + b) = (c + a) + b .. by associativity
c + (a + b) = c + a + b = a + b + c .. by associativity, then by commutativity
(a + b) + (c + d) = a + b + c + d = a + d + b + c = (a + d) + (b + c) .. by associativity, then by commutativity, then by associativity again.


k
 
  • #9
The answer is that the order of OPERATIONS does not matter as long as the order of the operands are not changed (think about what this means for a minute)

Yep, that was the part I never got. I appreciate the help, your explanation added a lot and the difference between the two finally sunk in :)

Thanks again,

k
 

Suggested for: Commutativity vs Associativity

Replies
9
Views
735
Replies
53
Views
3K
Replies
13
Views
1K
Replies
12
Views
3K
Replies
4
Views
1K
Replies
3
Views
1K
Replies
9
Views
1K
Replies
2
Views
3K
Replies
9
Views
2K
Back
Top