Showing posts with label associativity. Show all posts
Showing posts with label associativity. Show all posts

Monday, April 13, 2009

Associative, but not commutative

Every operation mentioned in the previous post that is associative is also commutative, and everything mentioned that is not associative is not commutative.

associativecommutative
additionyesyes
mutiplicationyesyes
subtractionnono
divisionnono
exponentiationnono

So is there anything that is associative but not commutative?

Let's look at rotation.

Can we show that rotation is not commutative? In other words, does the order of rotations matter? If we do two rotations, do we get the same result if the do the second rotation first?

Start with a figure 1.



Rotate it by a quarter turn (90o) clockwise in the plane of the screen:



Then flip it upside down. (i.e. rotate it by a half turn (180o) about a line going from left to right through the middle of the 1.)



This is our result.

Now try doing the second rotation first, to see if the order matters.

Once again start with a figure 1.



This time, first flip it upside down (i.e. rotate it by a half turn (1800) about a line going from left to right through the middle of the 1.)



Then rotate it by a quarter turn (900) clockwise in the plane of the screen:



This (⥚) is different from our result above (⥟). So it matters which rotation is done first. Rotation does not commute.

So how about associativity? It turns out that rotations are associative. Giving examples can't prove that it works in every case, but let's look at one anyway.

Let's define a few things:

A = rotate it by a quarter turn (900) clockwise in the plane of the screen

B = flip it upside down (i.e. rotate it by a half turn (1800) about a line going from left to right through the middle of the 1.)

C = flip to back to front (i.e. rotate it by half a turn (1800) about a line going from top to bottom through the middle of the 1.)

We already know that AB ≠ BA (it does not commute). Now, are these rotations associative, does

(AB)C = A(BC)?

Let's do (AB)C:

Start with a figure 1.



From above we know that applying A then B gives:



Now apply C (flip back to front):



This is our result for (AB)C.

Now work out A(BC).

First we need to work out what BC means. So we start with 1 and see where BC gets us, to work out what sort of rotation or transformation BC actually is.

Start with a figure 1.



Apply B:



Apply C:



So BC takes us from ⥠ to ⥝. So BC means a rotation of half a turn (1800) in the plane of the screen.

Now we can work out what A(BC) means.

Start with a figure 1.



Apply A:



Apply BC (half a turn in the place of the screen):



This is the same result that we got for (AB)C.

So for this one example we have demonstrated that rotation is associative, that (AB)C = A(BC).

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.