Return to Video

https:/.../matrixmultiplicationf61mb-aspect.mp4

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

English subtitles

Revisions