< Return to Video

Matrix multiplication (part 1)

  • 0:00 - 0:01
  • 0:01 - 0:02
    Well, after the last video,
    hopefully, we're a little
  • 0:02 - 0:04
    familiar with how you
    add matrices.
  • 0:04 - 0:07
    So now let's learn how
    to multiply matrices.
  • 0:07 - 0:11
    And keep in mind, these are
    human-created definitions for
  • 0:11 - 0:13
    matrix multiplication.
  • 0:13 - 0:15
    We could have come up with
    completely different ways to
  • 0:15 - 0:15
    multiply it.
  • 0:15 - 0:19
    But I encourage you to learn
    this way because it'll help
  • 0:19 - 0:20
    you in math class.
  • 0:20 - 0:22
    And we will see later that
    there's actually a lot of
  • 0:22 - 0:25
    applications that come out
    of this type of matrix
  • 0:25 - 0:25
    multiplication.
  • 0:25 - 0:26
    So let me think of
    two matrices.
  • 0:26 - 0:30
    I will do two 2 by 2 matrices,
    and let's multiply them.
  • 0:30 - 0:34
    Let's say-- let me pick some
    random numbers: 2,
  • 0:34 - 0:41
    minus 3, 7, and 5.
  • 0:41 - 0:43
    And I'm going to multiply that
    matrix, or that table of
  • 0:43 - 0:56
    numbers, times 10, minus 8--
    let me pick a good number
  • 0:56 - 1:04
    here-- 12, and then minus 2.
  • 1:04 - 1:07
    So now there might be a strong
    temptation-- and you know in
  • 1:07 - 1:11
    some ways it's not even an
    illegitimate temptation-- to
  • 1:11 - 1:14
    do the same thing with
    multiplication that we did
  • 1:14 - 1:18
    with addition, to just multiply
    the corresponding
  • 1:18 - 1:21
    terms. So you might be tempted
    to say, well, the first term
  • 1:21 - 1:23
    right here, the 1, 1 term, or
    in the first row and first
  • 1:23 - 1:25
    column, is going to
    be 2 times 10.
  • 1:25 - 1:27
    And this term is going
    to be minus 3 times
  • 1:27 - 1:28
    minus 8 and so forth.
  • 1:28 - 1:30
    And that's how we added matrices
    so maybe it's a
  • 1:30 - 1:34
    natural extension to multiply
    matrices the same way.
  • 1:34 - 1:36
    And that is legitimate.
  • 1:36 - 1:39
    One could define it that way,
    but that's not the way it is
  • 1:39 - 1:39
    in the real world.
  • 1:39 - 1:40
    And the way in the real world,
  • 1:40 - 1:42
    unfortunately, is more complex.
  • 1:42 - 1:45
    But if you look at a
    bunch of examples I
  • 1:45 - 1:46
    think you'll get it.
  • 1:46 - 1:47
    And you'll learn that
    it's actually fairly
  • 1:47 - 1:48
    straightforward.
  • 1:48 - 1:49
    So how do we do it?
  • 1:49 - 1:53
    So this first term that's in
    the first row and its first
  • 1:53 - 1:58
    column, is equal to essentially
    this first row's
  • 1:58 - 2:01
    vector-- no, this first
    row vector--
  • 2:01 - 2:05
    times this column vector.
  • 2:05 - 2:08
    Now what do I mean
    by that, right?
  • 2:08 - 2:11
    So it's getting it's row
    information from the first
  • 2:11 - 2:14
    matrix's row, and it's getting
    it's column information from
  • 2:14 - 2:16
    the second matrix's column.
  • 2:16 - 2:17
    So how do I do that?
  • 2:17 - 2:19
    If you're familiar with dot
    product, it's essentially the
  • 2:19 - 2:21
    dot product of these
    two matrices.
  • 2:21 - 2:25
    Or without saying it that fancy,
    it's just this: it's 2
  • 2:25 - 2:32
    times 10, so 2-- I'm going to
    write small-- times 10, plus
  • 2:32 - 2:40
    minus 3 times 12.
  • 2:40 - 2:43
    I'm going to run out of space.
  • 2:43 - 2:46
    And so what's this second
    term over here?
  • 2:46 - 2:49
    Well, we're still on the first
    row of the product vector but
  • 2:49 - 2:50
    now we're on the
    second column.
  • 2:50 - 2:52
    We get our column information
    from here.
  • 2:52 - 2:59
    So let's pick a good color--
    this is a slightly different
  • 2:59 - 3:01
    shade of purple.
  • 3:01 - 3:04
    So now this is going to be--
    I'll do that in another
  • 3:04 - 3:11
    color-- 2 times minus 8-- let me
    just write out the number--
  • 3:11 - 3:19
    2 times minus 8 is minus 16,
    plus minus 3 times minus 2--
  • 3:19 - 3:21
    what's minus 3 times minus 2?
  • 3:21 - 3:26
    That is plus 6, right?
  • 3:26 - 3:29
    So that's in row 1 column 2.
  • 3:29 - 3:31
    It's minus 16 plus 6.
  • 3:31 - 3:32
    And then let's come down here.
  • 3:32 - 3:34
    So now we're in the
    second row.
  • 3:34 - 3:36
    So now we're going to use--
    we're getting our row
  • 3:36 - 3:38
    information from the first
    matrix-- I know this is
  • 3:38 - 3:41
    confusing and I feel bad for you
    right now, but we're going
  • 3:41 - 3:45
    to a bunch of examples and
    I think it'll make sense.
  • 3:45 - 3:49
    So this term-- the bottom left
    term-- is going to be this row
  • 3:49 - 3:50
    times this column.
  • 3:50 - 3:58
    So it's going to be 7 times
    10, so 70, plus 7 times 10
  • 3:58 - 4:06
    plus 5 times 12, plus 60.
  • 4:06 - 4:09
    And then the bottom right term
    is going to be 7 times minus
  • 4:09 - 4:20
    8, which is minus 56 plus
    5 times minus 2.
  • 4:20 - 4:23
    So that's minus 10.
  • 4:23 - 4:31
    So the final product is going to
    be 2 times 10 is 20, minus
  • 4:31 - 4:41
    36, so that's minus 16
    plus 6, that's 10.
  • 4:41 - 4:42
    90-- was that what I said?
  • 4:42 - 4:46
    No, it was-- 70, plus
    60, that's 130.
  • 4:46 - 4:56
    And then minus 56 minus
    10, so minus 66.
  • 4:56 - 4:56
    So there you have it.
  • 4:56 - 4:59
    We just multiplied this matrix
    times this matrix.
  • 4:59 - 5:00
    Let me do another example.
  • 5:00 - 5:03
    And I think I'll actually
    squeeze it on this side so
  • 5:03 - 5:06
    that we can write this side out
    a little bit more neatly.
  • 5:06 - 5:19
    So let's take the matrix and
    now 1, 2, 3, 4, times the
  • 5:19 - 5:28
    matrix 5, 6, 7, 8.
  • 5:28 - 5:30
    Now we have much more space to
    work with so this should come
  • 5:30 - 5:33
    out neater.
  • 5:33 - 5:37
    OK, but I'm going to do the
    same thing, so to get this
  • 5:37 - 5:40
    term right here-- the top left
    term-- we're going to take--
  • 5:40 - 5:43
    or the one that has row 1 column
    1-- we're going to take
  • 5:43 - 5:52
    the row 1 information from
    here, and the column 1
  • 5:52 - 5:54
    information from here.
  • 5:54 - 5:56
    So you can view it as
    this row vector
  • 5:56 - 5:57
    times this column vector.
  • 5:57 - 6:02
    So it results, 1 times
    5 plus 2 times 7.
  • 6:02 - 6:08
  • 6:08 - 6:08
    Right?
  • 6:08 - 6:10
    There you go.
  • 6:10 - 6:13
    And so this term, it'll be this
    row vector times this
  • 6:13 - 6:16
    column vector-- let me do that
    in a different color-- will be
  • 6:16 - 6:21
    1 times 6 plus 2 times 8.
  • 6:21 - 6:21
    Let me write that down.
  • 6:21 - 6:29
    So it's 1 times 6
    plus 2 times 8.
  • 6:29 - 6:33
  • 6:33 - 6:35
    Now we go down to
    the second row.
  • 6:35 - 6:38
    And we get our row information
    from the first vector-- let me
  • 6:38 - 6:44
    circle it with this color--
    and it is 3 times 5
  • 6:44 - 6:46
    plus 4 times 7.
  • 6:46 - 6:53
  • 6:53 - 6:55
    And then we are in the bottom
    right, so we're in the bottom
  • 6:55 - 6:57
    row and second column.
  • 6:57 - 6:59
    So we get our row information
    from here and our column
  • 6:59 - 7:01
    information from here.
  • 7:01 - 7:04
    So it's 3 times 6
    plus 4 times 8.
  • 7:04 - 7:10
  • 7:10 - 7:14
    And if we simplify,
    this is 5 plus--
  • 7:14 - 7:16
    Well actually, let me just
    remind you where all the
  • 7:16 - 7:17
    numbers came from.
  • 7:17 - 7:18
    So we have that green
    color, right?
  • 7:18 - 7:26
    This 1 and this 2, that's
    this 1 and this 2,
  • 7:26 - 7:29
    this 1 and this 2.
  • 7:29 - 7:29
    Right?
  • 7:29 - 7:30
    And notice, these were in the
    first row and they're in the
  • 7:30 - 7:32
    first row here.
  • 7:32 - 7:34
    And this 5 and this 7?
  • 7:34 - 7:40
    Well, that's this 5 and this
    7, and this 5 and this 7.
  • 7:40 - 7:43
    So, interesting.
  • 7:43 - 7:45
    This was in column 1 of the
    second matrix and this is in
  • 7:45 - 7:48
    column 1 in the product
    matrix.
  • 7:48 - 7:51
    And similarly, the
    6 and the 8.
  • 7:51 - 7:56
    That's this 6, this 8, and then
    it's used here, this 6
  • 7:56 - 7:58
    and this 8.
  • 7:58 - 8:00
    And then finally this 3 and the
    4 in the brown, so that's
  • 8:00 - 8:04
    this 3, this 4, and
    this 3 and this 4.
  • 8:04 - 8:05
    And we could of course
    simplify all of it.
  • 8:05 - 8:10
    This was 1 times 5 plus 2 times
    7, so that's 5 plus 14,
  • 8:10 - 8:15
    so this is 19.
  • 8:15 - 8:19
    This is 1 times 6 plus 2
    times 8, so it's 6 plus
  • 8:19 - 8:22
    16, so that's 22.
  • 8:22 - 8:26
    This is 3 times 5
    plus 4 times 7.
  • 8:26 - 8:33
    So 15 plus 28, 38, 43-- if my
    math is correct-- and then we
  • 8:33 - 8:36
    have 3 times 6 plus 4 times 8.
  • 8:36 - 8:44
    So that's 18 plus
    32, that's 50.
  • 8:44 - 8:46
    So now let me ask you-- just so
    you know that the product
  • 8:46 - 8:48
    matrix-- just write
    it neatly-- is
  • 8:48 - 8:54
    19, 22, 43, and 50.
  • 8:54 - 8:55
    So now let me ask
    you a question.
  • 8:55 - 8:59
    When we did matrix addition we
    learned that if I had two
  • 8:59 - 9:03
    matrices-- it didn't matter what
    order we added them in.
  • 9:03 - 9:07
    So if we said, A plus B-- and
    these are matrices; that's why
  • 9:07 - 9:09
    I'm making them all bold-- we
    said this is the same thing as
  • 9:09 - 9:12
    B plus A, based on how
    we define matrix
  • 9:12 - 9:16
    addition, B plus A.
  • 9:16 - 9:17
    So now let me ask
    you a question.
  • 9:17 - 9:23
    Is multiplying two matrices,
    is AB-- that's just means
  • 9:23 - 9:26
    we're multiplying A and B-- is
    that the same thing as BA?
  • 9:26 - 9:30
  • 9:30 - 9:31
    Does it matter?
  • 9:31 - 9:34
    Does the order of the matrix
    multiplication matter?
  • 9:34 - 9:36
    And so, I'll tell you right
    now, it actually matters a
  • 9:36 - 9:37
    tremendous amount.
  • 9:37 - 9:40
    And actually there are certain
    matrices that you can add in
  • 9:40 - 9:42
    one direction that you can't
    add in the other-- oh, that
  • 9:42 - 9:47
    you can multiply in one way but
    you can't multiply in the
  • 9:47 - 9:48
    other order.
  • 9:48 - 9:51
    And well, I'll show you that
    in an example-- but just to
  • 9:51 - 9:53
    show that this isn't even equal
    for most matrices, I
  • 9:53 - 9:57
    encourage you to multiply these
    two matrices in the
  • 9:57 - 9:57
    other order.
  • 9:57 - 9:59
    Actually let me do that.
  • 9:59 - 10:01
    Let me do that really
    fast just to prove
  • 10:01 - 10:01
    the point to you.
  • 10:01 - 10:03
    So let me delete all
    this top part.
  • 10:03 - 10:06
  • 10:06 - 10:14
    Let me delete all of it, and
    actually I can delete to this.
  • 10:14 - 10:16
    So hopefully, you know that when
    I multiply this matrix
  • 10:16 - 10:18
    times this matrix, I got this.
  • 10:18 - 10:20
    So let me switch the order--
    and I'll do it fairly fast
  • 10:20 - 10:23
    just so as to not bore you-- so
    let me switch the order of
  • 10:23 - 10:24
    the matrix multiplication.
  • 10:24 - 10:27
    This is good as this is another
    example-- so I'm going
  • 10:27 - 10:37
    to multiply this matrix: 5, 6,
    7, 8, times this matrix-- and
  • 10:37 - 10:40
    I just switched the order; and
    we're testing to see whether
  • 10:40 - 10:47
    order matters-- 1, 2, 3, 4.
  • 10:47 - 10:49
    Let's do it-- and I won't do all
    the colors and everything,
  • 10:49 - 10:50
    I'll just do it systematically.
  • 10:50 - 10:54
    I think you just have to see a
    lot of examples here-- So this
  • 10:54 - 10:56
    first term gets its row
    information from the first
  • 10:56 - 10:59
    matrix, column information
    from the second matrix.
  • 10:59 - 11:06
    So it's 5 times 1 plus 6 times
    3, so it's 5 times 1--
  • 11:06 - 11:09
    Let me just write,
    actually edit.
  • 11:09 - 11:18
    I'm going to skip a step here--
    OK so it's 5 times 1
  • 11:18 - 11:23
    plus 6 times 3, plus 18.
  • 11:23 - 11:25
    What's the second term here?
  • 11:25 - 11:30
    It's going to be 5 times
    2 plus 6 times 4.
  • 11:30 - 11:40
    So 5 times 2 is 10, plus
    6 times 4 is 24.
  • 11:40 - 11:42
    Right, now we just took
    this row times this
  • 11:42 - 11:45
    column right here.
  • 11:45 - 11:48
    OK now we're down here for the
    set-- so then we're doing this
  • 11:48 - 11:51
    row, this element right here at
    the bottom left is going to
  • 11:51 - 11:53
    use this row, and this column.
  • 11:53 - 12:00
    So it's 7 times 1
    plus 8 times 3.
  • 12:00 - 12:03
    8 times 3 is 24.
  • 12:03 - 12:05
    And then finally, to get this
    element we're essentially
  • 12:05 - 12:12
    multiplying this row times this
    column, so it's 7 times 2
  • 12:12 - 12:22
    is 14, plus 8 times
    4, plus 32.
  • 12:22 - 12:30
    So this is equal to 5
    plus 18 is 23, 34.
  • 12:30 - 12:31
    What's 7 plus 24?
  • 12:31 - 12:36
    That's 31, 46.
  • 12:36 - 12:44
    So notice, if we called
    this matrix A and this
  • 12:44 - 12:47
    is matrix B, right?
  • 12:47 - 12:58
    In the last example, we showed
    that A times B is equal to 19,
  • 12:58 - 13:03
    22, 43, 50.
  • 13:03 - 13:07
    And we just showed that, well,
    if you reverse the order, B
  • 13:07 - 13:10
    times A is actually this
    completely different matrix.
  • 13:10 - 13:12
    So the order in which
    you multiply
  • 13:12 - 13:15
    matrices completely matters.
  • 13:15 - 13:16
    So I'm actually running
    out of time.
  • 13:16 - 13:19
    In the next video I going talk
    a little bit more about the
  • 13:19 - 13:22
    types of matrix-- well, one, we
    know that order matters--
  • 13:22 - 13:25
    and in the next video I'll
    show that what type of
  • 13:25 - 13:27
    matrices can be multiplied
    by each other.
  • 13:27 - 13:30
    When we added or subtracted
    matrices, we just said, well
  • 13:30 - 13:32
    they have to have the same
    dimensions because you're
  • 13:32 - 13:34
    adding or subtracting
    corresponding terms. But
  • 13:34 - 13:37
    you'll see with multiplication
    it's a little bit different.
  • 13:37 - 13:38
    And we'll do that in
    the next video.
  • 13:38 - 13:40
    See you soon.
  • 13:40 - 13:40
Title:
Matrix multiplication (part 1)
Description:

Multiplying two 2x2 matrices.

more » « less
Video Language:
English
Duration:
13:40

English subtitles

Incomplete

Revisions