One of the most important operations we can do with
matrices is to learn how to multiply them together. That's
what we're going to do now. And when we multiply matrices
together, we find that we combine the elements in the two
matrices in rather a strange way, and the easiest way to
explain that is by example, so let's have a look.
Suppose we've got a row of a matrix 37.
And we want to combine it or multiply it with a column of
another matrix 29.
And what we do is we combine these numbers in a rather
strange way. What we do is we pair off the elements in the row
of the first matrix with the column with the column in the
Second matrix, and we pair them off and we multiply the
corresponding elements together. So we pair off the three with
the two. The seven with the 9.
And we multiply the paired elements together so we
have 3 * 2.
I mean multiply the seven with the 9.
And we add the results together.
So we have 3 * 2 which is 6 and 7 * 9, which is 63
and we add them together and we get the answer 69.
So we have this rather strange way in which we have combined
the elements in the row of the first matrix with the column
in the Second matrix.
Let's have a look at another example. Suppose we have a row
which is 425.
And we're going to learn how to multiply it with a column 368.
And again, what we do is we pair the elements off elements in the
row of the first matrix with the column of the Second matrix. We
have 4 * 3.
2 * 6.
5 * 8.
And we add these products together, so with 4 * 3 which is
12 two times 6 which is 12 and 5 * 8 which is 40. And if we add
these up will get 12 and 12 is
24. And 40 which is 64.
So this is a rather strange way in which we've combined the
elements in the first matrix with the elements in the second
matrix, but it's the basis of matrix multiplication, as we'll
see shortly Now, suppose we have to general matrices A&B, say.
And we want to find the product of these two
matrices. In other words, we want to multiply A&B
together.
Now suppose that this matrix A. The first matrix has P,
rossion, Q columns, so it's a P by Q matrix.
And the second matrix be. Let's suppose that Scott
are rows and S columns, so it's an arby S matrix.
Now it turns out that we can only form this product. We can
only multiply the two matrices
together. If the number of columns in the first matrix,
which is Q is the same as the number of rows in the second
matrix, these two numbers have got to be the same. Q Must equal
R and the reason for that will become apparent when we start to
do the calculation. But you've got to be able to pair up the
elements in the first matrix with the elements in the Second
matrix and will only be able to do that if the number of columns
in the first is the same as the number of rows in the second.
When that's the case, we can actually find the product AB and
the answer is another matrix. And let's suppose this answer is
matrix C and the size of matrix. See, we can determine in advance
from the sizes of matrix A&B, the size of matrix C will be P
by S. So it's got the same number of rows as the first
matrix and columns as the second matrix, so this will be an R.
This will be a P by S matrix.
Let's have a look at a specific example. Suppose we want to
multiply the matrix 37.
45
by the Matrix 29.
And the first question we should ask ourselves is, do these
matrices have the right size so that we can actually multiply
them together? Well, this matrix is a two row two column matrix.
And the second matrix is 2 rows one column.
And we note that the number of columns here in the first matrix
is the same as the number of rows in the second matrix. So
these two numbers are the same, so we can do this multiplication
and the size of the answer. The size of the result that will get
is obtained by the number of rows in the 1st and columns in
the second. So the size of the answer that we're looking for is
a 2 by 1 matrix. So you see right at the beginning we can
tell how many. Elements are going to be in our answer.
There's going to be a number there, and a number there so
that we have a 2 by 1 matrix.
Now to determine these numbers, we use the same
operations as we've just seen. We take the first row
here and we pair the elements with those in the first
column.
We multiply the paired elements together and add the result. So
we want 3 * 2, which is 6.
We want 7 * 9 which is 63 and we add the results together. 6
and 63 is 69, so the element that goes in the first position
in our answer is 69. That's 3 * 2 at 7 * 9.
The element that's going in this position here is obtained by
working with the 2nd row and this first column here.
Again, we pair the elements up 4
* 2. Which is 8th.
5 * 9 which is 45, and we add the results together. 45
+ 8 is.
53
So the result is 6953, so the result of multiplying these two
matrices together is another matrix which is a 2 by 1 matrix
and the elements are obtained in the way I've just shown you.
Let's have a look at another
example. This time I'm going to try to multiply together the two
matrices A&B where a is this two by two Matrix 2453 and B. Is
this two by two Matrix three 6 -- 1 nine?
And again, the first question we should ask ourselves is, do
these matrices have the right size so that we can actually
multiply them together? Well, matrix a this matrix A is a two
row two column matrix. So that's two by two.
Matrix B is 2 rows and two columns, so that's also
two by two.
And you can see that these two numbers are the same. That is,
the number of columns in the first is the same as the
number of rows in the second. So we can perform the matrix
multiplication.
The size of the answer we can determine right at the start.
The size of the matrix that we get is determined by the number
here and the number there two by two. So what we can decide
before we do any calculation at all is that this answer matrix
is a two by two matrix.
Be 2 rows and two columns, so we're looking for four
numbers to pop in there.
Let's try and figure out how we work out, what the answer is.
When we want to find the element that goes in here, observe that
this is the first row first column of the answer.
And the number in the first row first column comes from
looking at the first row and 1st Column here.
If we pair off the elements in the first row and 1st Column
will have 2 * 3 which is 6.
4 * -- 1, which is minus four, and we add them together.
When we come to this element here, this element is in the
first row, second column.
So we use the first row, second column in the original matrices.
2 * 6 which is 12 and 4 * 9 Four nines of 36. And
we add those paired products together.
When we want the element that's in the 2nd row first column, we
use the 2nd row in the first matrix and 1st column in the
Second Matrix. Again, pairing the elements off 5 * 3 is 15.
3 * -- 1 is minus three. When we add the paired
elements together.
Finally. The element that's in the 2nd row, second column of
the answer is obtained by using the elements in the 2nd row of
the first matrix, second column of the Second matrix.
5 * 6 which is 30 and 3 * 9, which is 27, and we add the
paired elements together.
So finally, just to tidy it up, we've got 6 subtract 4
which is 2.
12 + 36, which is 48.
15 subtract 3 which is 12 and 30 + 27 which is 57, so we can find
the matrix product AB in this case and the result is a two by
two matrix. Let's have a look at another example. Suppose
we're asked to find the product of these two matrices.
And again, we should ask all these matrices of the
appropriate size. The first matrix here has two rows, one
column, it's a 2 by 1 matrix.
And the second matrix has two rows and two columns, so it's a
two by two matrix. Now in this case, you'll see that the
number of columns in the first matrix is not the same as the
number of rows in the second matrix. Those two numbers are
not equal, so we cannot multiply these matrices
together. We say the product of these matrices doesn't exist,
so we stop there. We can't calculate that.
Let's have another example. Suppose we want to try to
find the product of the matrices 3214.
With the matrix XY. Now this is the first example we've
looked at where we've had symbols rather than numbers in
our matrix, but the operation the process is, the
calculations are just the same.
First of all, we should ask can we multiply these together? Are
they of the right size?
This is a two row two column matrix.
And this is a two row one column matrix.
And these numbers are the same in here the number of columns in
the first is the same as the number of rows in the second. So
we can actually perform the matrix multiplication and the
answer we get will be a 2 by 1 matrix, so we know the shape of
the answer. It's a two row one column matrix, so it looks the
same shape as this one. This one
here. Two rows, one column.
Let's actually work out what the elements in the answers are.
As before, we take the first row and pair the elements with the
first column. So it's 3 multiplied by X 2 * y and we add
the resulting products, so we get three X + 2 Y.
The element that's down here, which is in the 2nd row, first
column of our answer, is obtained by using the 2nd row in
the first matrix and the first
column here. Multiply the pad elements together and add so
it's 1 * X which is X 4 * y, which is 4 Y and we add the
products together and we get X + 4 Y. So the result we found is a
two row one column matrix.
In this case, the answers got symbols in as well, but that's
the result of finding the product of these two matrices.
Now we can go on and look at more examples and trying to
find products of matrices of different sizes and shapes,
and we'll do some more of that in the next video.