Saturday, May 06, 2006

Does order matter?

It’s time to return to those mathy things that I know you all hold your breath in anticipation of. In the comments to this post, Teresa asked if the order mattered since multiplication is commutative. The idea that multiplication is commutative follows fairly naturally when you think of multiplication as a sister to addition. Multiplying 3 by 2 is the same as adding 3 two times - 2 x 3 = 3 + 3 = 6. By the same process, 3 x 2 = 2 + 2 + 2 = 6. So she’s right that in the case of the set of integers (and I've used integers in these examples), multiplication is commutative and order doesn't matter. But multiplication is not always commutative.

A matrix, as opposed to the matrix of movie fame, is an array of numbers. You will often see a matrix referred to as an (m x n) matrix where m and n denote the number of rows and columns, respectively. Matrix multiplication is not commutative.


Here's your math lesson for the day.


In order to multiply 2 matrices, the number of columns in the first matrix must equal the number of rows in the second matrix. If you have an (m x n) matrix multiplying an (r x s) matrix, you must have n = r. The funny thing is that if you switch the order so that you're multiplying the same (r x s) matrix by the same (m x n) matrix, then you need s = m.

Here's an example: if matrix A is a (3 x 3) matrix and matrix B is a (3 x 1) matrix, you can multiply A by B – a (3 x 3) multiplying a (3 x 1), where n and r both equal 3. But you can’t commute the two matrices. Multiplying B by A is undefined since you have a (3 x 1) multiplying a (3 x 3) and n = 1 while r = 3.

But what if you have two matrices with the same number of rows and columns? Shouldn't they be commutative? First, you need to know how matrix multiplication is performed. The simple (text book) definition looks like this:


For a matrix A = (aij) and a matrix B = (bij), the product AB is defined as

In math speak that makes very little sense. It looks something like this.

Nasty! Let’s try an example with numbers. I’m going to use (2 x 2) matrices A and B where


and


When you multiply AB, you get

And when you multiply BA, you get


So, for this example, you can see that AB is not equal to BA. There are occasional instances where AB will equal BA, but this is not generally true.

Just to briefly return to the Fundamental Theorem of Arithmetic where this started. The theorem orders the prime factors. This is important within the proof - order matters - but I think we’ll get to that tomorrow.

Reference: Johnson, L.W., Riess, R.D. & Arnold, J.T. (2002). Introduction to Linear Algebra (5th ed.). Boston, MA: Addison-Wesley.




4 comments:

vw bug said...

Run, Run for your life!!! I remember doing those things. Yuck. Here is a question I bet you can answer... why when you add 2 even numbers you get an even number, 2 odd numbers you get an even number but an odd and an even gives you an odd number... so why are there not more even numbers? GRIN Bet you weren't expected that huh?

Teresa said...

LOL - I was not thinking of matrices when I asked that question... just simple integers. And thus I have not done math in many years - as you can tell by my imprecise question. *grin*

I always like matrix multiplication, but I can never remember the order of it for longer than the chapters I studied while using it. Oh well...

MathCogIdiocy said...

vw - look for the answers to your questions either later tonight or tomorrow night. I'm going to take the time to present the proofs with "ordinary English translations" LOL

MathCogIdiocy said...

Teresa - if I'm not doing matrix multiplication, I have to look it up too. Although after creating the graphics for this post, I might remember it for a tad longer than usual. LOL

Most people only think of ordinary numbers (integers, rationals, reals) when they think of commutativity and associativity. The idea that there are other numbers that don't fit the rules we learned in school is ... well, strange.