Sunday, April 12, 2009

Would you eat chocolate milk powder? (associativity)

"Yuk! Why are you eating Milo* straight?", I ask my daughter. "Isn't it better mixed in milk?" "I've already drunk the milk", she replies, "so now I'm eating the Milo."

Is drinking milk and then eating Milo, the same as first mixing the Milo in the milk and then drinking the result? Maybe your stomach doesn't notice, but it certainly tastes different.

To write this another way, are these things the same:

Milo is put into (milk is put into your mouth)

(Milo is put into milk) is put into your mouth

They are the same except for the location of the parentheses, but that can make a big difference.

This example raises the question of associativity. When the position of the parentheses makes no difference, the operation is called "associative".

Addition is associative:

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

for example:

(2 + 3) + 4 = 6 + 4 = 9
2 + (3 + 4) = 2 + 7 = 9

Multiplication is associative:

(a × b) × c = a × (b × c)

for example:

(2 × 3) × 4 = 6 × 4 = 24
2 × (3 × 4) = 2 × 12 = 24

However addition and multiplication together are not associative:

(a + b) × c ≠ a + (b × c)

(2 + 3) × 4 = 6 × 4 = 20
2 + (3 × 4) = 2 + 12 = 14

Subtraction, division and 'to the power of' (exponentiation) each are not associative.

(a - b) - c ≠ a - (b - c)
(a / b) / c ≠ a / (b / c)
(ab)c ≠ a(bc)

Every operation mentioned above that is associative is also commutative, and everything mentioned above that is not associative is not commutative.

associativecommutative
additionyesyes
mutiplicationyesyes
subtractionnono
divisionnono
exponentiationnono
So is there anything that is associative but not commutative?

I'll have a look in my next post.

------

*Milo or Nesquik or Ovaltine or Horlicks: Chocolate flavoured powder that is added to milk and not usually consumed directly.

No comments:

Post a Comment