Showing posts with label commute. Show all posts
Showing posts with label commute. 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.

Saturday, April 11, 2009

Put on your shoes and socks: commutation

"Put on your shoes and socks - but not in that order", I say to my daughter, who sighs at my frequently repeated joke. The order you put your clothes on matters. Putting on your shoes then your socks is quite different from putting on your socks first and then your shoes.

On the other hand, it doesn't matter which sock you put on first, your left or your right.

In mathematics, when the order you do something is not important we say that operation is commutative. It commutes. The actions 'putting on your left sock' and 'putting on your right sock' commute. It doesn't matter which you do first, you get the same result. However, whether you put on your shoes or your socks first does matter. These tasks do not commute.

So because is some cases the order is important, the operation "putting on" is not commutative. However, if we restrict this and only deal with the operation of "putting on a sock", then this operation does commute, because it doesn't matter which foot you put your sock on first.*

In mathematics some operations commute and others do not.

Addition commutes, meaning that:

a + b = b + a

For example:

3 + 2 = 5
2 + 3 = 5

We get the same answer, no matter the order.

Multiplication also commutes:

ab = ba

3 X 2 = 6
2 X 3 = 6

So what does not commute? For some reason mathematicians seem to like jumping to more exotic examples like matrices, rotations or quaternions. But how about subtraction? Subtraction does not commute.

a - b ≠ b - a

For example:

3 - 2 = 1
2 - 3 = -1

Division does not commute either.

a / b ≠ b / a

For example:

3 / 2 = 1.5
2 / 3 = 0.666...

And 'raising to the power of' does not commute also:

ab ≠ ba

32 = 9
23 = 8

In future posts I'll look at other properties of these simple operations.

---------

*I am assuming that you do not put more than one sock on each foot - then the order would matter (if you can tell your socks apart) as it would effect which sock was underneath and which sock on top.