next home previous contents

3. Multiplication of Matrices

We have three recipes for breakfast foods. Each recipe feeds three people. The ingredients are as follows:

Pancakes: 2 cups baking mix, 2 eggs, and 1 cup milk.
Biscuits: number cups baking mix and number cups milk.
Waffles: 2 cups baking mix, 1 egg, matrix cups milk, and 2 tablespoons vegetable oil.
Let's write this in the form of a labeled matrix so that it is easier to read.


If we want to feed 6 people instead of 3, what do we need to do? We double each recipe. That means we need twice as much of each ingredient, so we multiply every element of the matrix by the number 2.

matrix

When we multiply a matrix by a real number, we call the real number a Scalar and call the operation scalar multiplication. Scalar multiplication consists of multiplying each element of a matrix by a given scalar. We use the terms scalar and scalar multiplication because, in abstract algebra, we often have the need to consider more general scalars than real numbers. However, in this book, we restrict our attention to scalars that are real numbers.

Definition 3.1 If c is a real number and A is a matrix whose (i,j)th element is aij, then the scalar product cA is the matrix whose (i,j)th element is caij.
For example, if matrix, then matrix The result is a matrix of the same dimensions as the original matrix. Notice that scalar multiplication is consistent with what you know about real numbers. For example, you learned that x + x = 2x. It is also true that

matrix

Now we know how much of each ingredient we need to serve pancakes, biscuits, and waffles to 6 people. (Remember that each recipe serves 3 people).

If we want to feed 3 people pancakes, 12 people biscuits, and 9 people waffles, how much baking mix will we need? We need to make one batch of pancakes, 4 batches of biscuits, and 3 batches of waffles. Let's represent this with the row vector

matrix

We could have written this as a column vector instead of a row vector, but a row vector will be useful in later problems. The vector describing how much baking mix we need is the first column of R. We will call it a. Therefore,

matrix

We need  matrix cups of baking mix. The process by which we found the number of cups of baking mix needed is called finding the inner product of two vectors.

Definition 3.2 The inner product of n-vectors x and y, denoted by  matrix where n is the dimension of the vectors.
Notice that the definition of inner product requires the vectors to have the same dimension. The inner product of two vectors is a scalar. Therefore,  matrix
Remark 7 Some people refer to the inner product as the dot product and denote it x·y.
What would we do if we wanted to know how much of each ingredient we need for 1 batch of pancakes, 4 batches of biscuits, and 3 batches of waffles? We would take the inner product of s and a particular column of R to find out how much of that particular ingredient we need. This procedure motivates our definition of matrix multiplication which will be described in detail later in this chapter.

Now let's multiply our row vector, s, by our recipe matrix, R.

matrix


We need 17 cups of baking mix, 5 eggs, 8 cups of milk, and 6 tablespoons of oil.

There are several interesting things to notice about matrix multiplication. We multiplied a 1 by 3 matrix by a 3 by 4 matrix and got a 1 by 4 matrix. This pattern will always hold when we multiply. The middle numbers must be the same (like the threes were in this case), when we multiply matrices. The resulting matrix will always have the dimensions of the outside numbers (1 by 4 in this case) when multiplication is defined. The following picture expresses the requirements on the dimensions:

matrix

Even though the labels are not a formal part of the matrix, and are not always attached to a matrix, this also happens with the labels. The labels of the inside dimensions must agree if we want a meaningful product.

matrix

The label, total by ingredients, is meaningful because foods was the label for the inside dimensions of both matrices that we multiplied.

Let's also look closely at how we multiply the matrices because we will multiply matrices with larger dimensions later. This is a hands on activity. Take your left pointer finger and place it at the beginning of the first row of the first matrix (the only row we have in this case). Take your right pointer finger and place it on the first number of the first column of the second matrix. Multiply the two numbers to which you are pointing. Each time you move, your left hand will go across the row, and your right hand will go down the column. When you reach the end of the row and column, add the numbers you have obtained from the multiplications. This number goes in the first row and first column of your product matrix. This is the same as taking the inner product of the first row of the first matrix and the first column of the second matrix. Now you can move to the first row, second column doing the same thing. This number will go in the first row, second column of your product matrix. In short, position ij of your product matrix consists of the inner product of the ith row of your first matrix and the jth column of the second matrix. This is a lot easier to do than it is to describe! Your left hand will move across and your right hand will move down. Do this for every row and column combination to get your product matrix. No, you are not too old to do this. A lot of college students multiply matrices this way. After you do this enough times, your hands will not let you do it incorrectly ever again. This picture depicts the motions necessary to find a product:

matrix

Definition 3.3 Consider the m by p matrix A and the p by n matrix B. By the matrix product A times B, we mean the m by n matrix whose (i,j)th element is the inner product of the ith row of A with the jth column of B.
Since many of us watch our money closely, let's look at another example. How much does it cost to make each of these foods? First, we need to know how much each ingredient costs. We can find that information when we go to the grocery store. Baking mix costs 17 cents per cup; eggs are 8 cents each; milk costs 13 cents per cup; and oil is 4 cents per tablespoon.

Look at the dimensions of our matrices and the labels we have put on them. THINK about what dimensions and labels should be on our product matrix. This will tell you how we should organize the data about the cost of each food. Write down your product matrix before you read further. Also write down each step of the multiplication and addition that you do to find the product matrix. Compare that to the matrix products that follow. Look carefully at where each number that you used appears in the matrix.

Let's call our cost matrix C. Remember that since the dimensions of C are 4 by 1, C could also be considered to be a column vector of dimension 4.

martrix


Now let's multiply to find out how much the ingredients of each recipe cost.

matrix


This gives us the cost of the ingredients needed for each food to feed three people. Biscuits are cheaper than pancakes which are slightly cheaper than waffles.

Remember to use your fingers the way we discussed earlier to remember which numbers to multiply. Let's look at the dimensions and labels for this example. The dimensions of matrix R are 3 by 4 and the dimensions of C are 4 by 1, so R*C is 3 by 1. The labels also tell us that we set up the product correctly. We have food by ingredients multiplied by ingredients by cents to get food by cents. This is what we want!

What if we also want to know the calorie content of each recipe? If we know the calorie content of each ingredient, we can find the number of calories in each recipe. There are 510 calories per cup of baking mix, 70 calories in each egg, 90 calories in a cup of milk, and 120 calories in a tablespoon of oil. Look at the labels for matrix R and for the product matrix to decide how to organize this information. We will put this in a 4 by 1 matrix (also called a column vector of dimension 4) and name it K. To find out how many calories are in each recipe, we multiply R*K.

matrix


matrix


Now we know that there are 1250 calories in a recipe of pancakes, 1215 calories in a recipe of biscuits, and 1450 calories in a recipe of waffles for three people. Therefore, biscuits have the fewest calories, pancakes are in the middle, and waffles have the most.

What would we do if we want to know both the cost of each food and the number of calories? We could use matrix multiplication twice like we did above, but we also have the ability to set up only one matrix multiplication to find both pieces of information. We can append K to C to form a single matrix. Let's call it F.


matrix


Now let's multiply R*F to find the information we want.

matrix


Notice that with only one matrix multiplication, we are able to find the same products that we found in the previous two matrix multiplications. The power to combine information is one of the assets of matrix multiplication. Although the same number of operations are needed whether we use one matrix multiplication or two, it is easier to keep track of all of our information when we use one matrix multiplication.

Would we have been able to multiply F*R? No, the dimensions are wrong because matrix multiplication is defined only if the "inside dimensions" agree. What happens when you try to multiply these matrices? You run out of numbers in the row and column at different times. This should alert you to the fact that something is wrong.

Remark 8 A shortened way of writing R*F is RF. When there is no sign between two matrices or two sets of parentheses, it is implied that you should multiply.
We learned in the last chapter that there is a matrix version of the addition property of zero. There is also a matrix version of the multiplication property of one. The real number version tells us that if a is a real number, then a*1 = 1*a = a. The matrix version of this property states that if A is a square matrix, then A*I = I*A = A, where I is the identity matrix of the same dimensions as A. If A is not square, then A*I = A and I*A = A where I in each case is the identity matrix with dimensions such that the multiplication would be a defined operation.
Definition 3.4 An identity matrix is a square matrix with ones along the main diagonal and zeros elsewhere.
The symbol I is used to represent an identity matrix when its dimensions are not necessary and when the dimensions can be determined from the context. The symbol In represents the identity matrix of dimension n by n. The matrix

matrix and matrix

Notice that if A is m by p, then A*Ip = A and Im*A = A. The identity matrix gets its name because I is the multiplicative identity for matrices just as the number 1 is the multiplicative identity for real numbers.

next up previous go to the top contents

Send comments on material to Tamara Carter

These pages are maintained by Hilena Vargas (hvargas@rice.edu)
Updated: August 15, 2000

 Copyright ©1995 - 2000 Tamara Lynn Anthony