< Return to Video

Is matrix multiplication commutative

  • 0:00 - 0:02
    Voiceover:We know that the multiplication
  • 0:02 - 0:04
    of scalar quantities is commutative.
  • 0:04 - 0:12
    For example, 5 times 7 is
    the same thing as 7 times 5,
  • 0:12 - 0:13
    and that's obviously just
    a particular example.
  • 0:13 - 0:15
    I could give many, many more.
  • 0:15 - 0:22
    3 times negative 11 is the same
    thing as negative 11 times 3
  • 0:22 - 0:24
    and the whole point of commutativity ...
  • 0:24 - 0:25
    I could never say it ...
  • 0:25 - 0:27
    is that it doesn't matter what order
  • 0:27 - 0:28
    that I'm multiplying in.
  • 0:28 - 0:32
    This is the same thing
    as negative 11 times 3.
  • 0:32 - 0:34
    Or if we wanted to speak in general terms,
  • 0:34 - 0:39
    if I have the scalar a and I
    multiply it times the scalar b,
  • 0:39 - 0:40
    that's going to be the same thing
  • 0:40 - 0:46
    as multiplying the scalar
    b times the scalar a.
  • 0:46 - 0:48
    Now what I want to do in
    this video is think about
  • 0:48 - 0:51
    whether this property of commutativity,
  • 0:51 - 0:53
    whether the commutative property
  • 0:53 - 0:54
    of multiplication of scalars,
  • 0:54 - 0:56
    whether there is a similar property
  • 0:56 - 0:59
    for the multiplication of matrices,
  • 0:59 - 1:02
    whether it's the case that
    if I had two matrices,
  • 1:02 - 1:08
    let's say matrix capital
    A and matrix capital B,
  • 1:08 - 1:11
    whether it's always the
    case that that product,
  • 1:11 - 1:14
    the resulting matrix here is the same
  • 1:14 - 1:18
    as the product of matrix B and matrix A,
  • 1:18 - 1:20
    just swapping the order.
  • 1:20 - 1:23
    I encourage you ... so
    is this always true?
  • 1:23 - 1:24
    It might be sometimes true,
  • 1:24 - 1:28
    but in order for us to say
    that matrix multiplication
  • 1:28 - 1:30
    is commutative, that it
    doesn't matter what order
  • 1:30 - 1:32
    we are multiplying it,
  • 1:32 - 1:37
    we have to figure out is
    this always going to be true?
  • 1:37 - 1:38
    I encourage you to pause this video
  • 1:38 - 1:40
    and think about that for a little bit.
  • 1:41 - 1:43
    Let's just think through a few things.
  • 1:43 - 1:45
    First of all, let's just
    think about matrices
  • 1:45 - 1:47
    of different dimensions.
  • 1:47 - 1:50
    Let's say I have a matrix here.
  • 1:50 - 1:55
    Let's say that matrix
    A is a, I don't know,
  • 1:55 - 1:59
    let's say it is a 5 by 2 matrix,
  • 1:59 - 2:01
    5 by 2 matrix,
  • 2:01 - 2:09
    and matrix B is a 2 by 3 matrix.
  • 2:09 - 2:14
    The product AB is going
    to have what dimensions?
  • 2:14 - 2:18
    If I multiply these two, you're
    going to get a third matrix.
  • 2:18 - 2:21
    Let's just call that C for now.
  • 2:21 - 2:23
    You're going to get a third matrix C.
  • 2:23 - 2:25
    What are going to be the dimensions of C?
  • 2:26 - 2:31
    We know, first of all, that
    this product is defined
  • 2:31 - 2:33
    under our convention of
    matrix multiplication
  • 2:33 - 2:35
    because the number of columns that A has
  • 2:35 - 2:38
    is the same as the number of rows B has,
  • 2:38 - 2:41
    and the resulting rows and column
  • 2:41 - 2:44
    are going to be the rows
    of A and the columns of B.
  • 2:44 - 2:48
    So C is going to be a 5 by 3 matrix,
  • 2:49 - 2:50
    a 5 by 3 matrix.
  • 2:51 - 2:52
    Now what about the other way around?
  • 2:52 - 2:54
    What would B times A be?
  • 2:54 - 2:56
    Once again, I encourage
    you to pause the video.
  • 2:58 - 3:00
    If you were to take B,
  • 3:00 - 3:03
    let me copy and paste that,
  • 3:04 - 3:06
    and multiply that times A,
  • 3:06 - 3:09
    so I'm really just switching
    the order of the multiplication
  • 3:09 - 3:12
    so copy and paste.
  • 3:13 - 3:16
    If we take that product right over there,
  • 3:16 - 3:18
    what is that going to be equal to?
  • 3:18 - 3:20
    What is this?
  • 3:20 - 3:23
    What is this right over
    here going to be equal to?
  • 3:25 - 3:29
    The first question is, is matrix
    multiplication even defined
  • 3:29 - 3:31
    for these two matrices?
  • 3:31 - 3:35
    When you look at the number
    of columns that B has
  • 3:35 - 3:38
    and the number of rows that A has,
  • 3:38 - 3:40
    you see that it actually is not defined,
  • 3:40 - 3:42
    that we have a different
    number of columns for B
  • 3:42 - 3:44
    and a different number of rows for A.
  • 3:44 - 3:47
    Here, the product is not defined,
  • 3:47 - 3:49
    is not defined,
  • 3:50 - 3:52
    so this immediately is a pretty big clue
  • 3:52 - 3:54
    that this isn't always going to be true.
  • 3:54 - 3:58
    Here, AB, the product AB is defined,
  • 3:58 - 4:00
    and you'll end up with a 5 by 3 matrix.
  • 4:00 - 4:04
    The product here, BA, isn't even defined.
  • 4:04 - 4:06
    This is already ...
  • 4:06 - 4:10
    We're already seeing that
    this is not the case,
  • 4:10 - 4:13
    that order matters when
    you are multiplying,
  • 4:13 - 4:15
    when you are multiplying matrices.
  • 4:15 - 4:17
    To make things a little bit more concrete,
  • 4:17 - 4:18
    let's actually look at a matrix.
  • 4:18 - 4:20
    You might be saying, oh,
    maybe this doesn't work
  • 4:20 - 4:21
    only when it's not defined,
  • 4:21 - 4:23
    but hey, maybe it works
    if we're always to do
  • 4:23 - 4:26
    square matrices or matrices
    where both products
  • 4:26 - 4:28
    are always defined in some way,
  • 4:28 - 4:30
    or maybe some other case.
  • 4:30 - 4:32
    Let's look at a case where we're dealing
  • 4:32 - 4:37
    with 2 by 2 matrices and
    see whether order matters.
  • 4:37 - 4:39
    Let's say I have the matrix.
  • 4:39 - 4:47
    Let's say I have the matrix
    1, 2, negative 3, negative 4,
  • 4:47 - 4:51
    and I want to multiply that by the matrix,
  • 4:51 - 4:56
    by the matrix negative
    2, 0, 0, negative 3.
  • 4:56 - 4:58
    What's that product going to be?
  • 4:58 - 5:00
    Once again, I encourage
    you to pause the video
  • 5:00 - 5:01
    and think about that.
  • 5:03 - 5:06
    Let's think it through, and
    we've done this many times now.
  • 5:07 - 5:09
    This first entry here is going to be,
  • 5:09 - 5:13
    we're essentially going to look
    at this row and this column,
  • 5:13 - 5:15
    so it's 1 times negative
    2, which is negative 2,
  • 5:15 - 5:16
    plus 2 times 0.
  • 5:16 - 5:18
    This is going to be negative 2.
  • 5:18 - 5:21
    Now, for this entry,
  • 5:21 - 5:21
    for this entry over here,
  • 5:21 - 5:25
    we'll look at this row and this column,
  • 5:25 - 5:28
    1 times 0, which is 0,
    plus 2 times negative 3,
  • 5:28 - 5:30
    which is negative 6.
  • 5:30 - 5:35
    Then for this entry, we
    would look at this row
  • 5:35 - 5:38
    and this column.
  • 5:38 - 5:40
    Negative 3 times negative 2 is positive 6
  • 5:40 - 5:43
    plus negative 4 times 0,
    which is just positive 6.
  • 5:43 - 5:45
    We're going to have positive 6.
  • 5:45 - 5:47
    Then finally, for this entry,
  • 5:47 - 5:49
    it's going to be the second
    row times the second column.
  • 5:49 - 5:51
    Negative 3 times 0 is 0.
  • 5:51 - 5:55
    Negative 4 times negative
    3 is positive 12,
  • 5:55 - 5:56
    so fair enough.
  • 5:56 - 5:58
    Now what if we did it
    the other way around?
  • 5:58 - 6:06
    What if we were to multiply
    negative 2, 0, 0, negative 3
  • 6:06 - 6:14
    times 1, 2, negative 3, negative 4?
  • 6:14 - 6:16
    What's this going to be equal to?
  • 6:16 - 6:18
    As always, it's a good
    idea to try to pause it
  • 6:18 - 6:20
    and work through it on your own.
  • 6:20 - 6:22
    Let's think about this.
  • 6:22 - 6:30
    Negative 2 times 1 is negative
    2, plus 0 times negative 3,
  • 6:30 - 6:32
    so that's going to be negative 2.
  • 6:32 - 6:34
    So far, it's looking pretty good.
  • 6:34 - 6:39
    Then if you have negative
    2 times 2 is negative 4,
  • 6:39 - 6:43
    plus 0 times negative 4 is negative 4.
  • 6:43 - 6:45
    We already see that these two things
  • 6:45 - 6:47
    aren't going to be equal,
    but let's just finish it,
  • 6:47 - 6:50
    just so that we have a
    feeling of completion.
  • 6:50 - 6:51
    This entry right over here is going to be
  • 6:51 - 6:53
    the second row, first column,
  • 6:53 - 6:57
    0 times 1 plus negative 3
    times negative 3 is positive 9.
  • 6:57 - 6:58
    Once again, it doesn't match up.
  • 6:58 - 7:02
    Then finally, 0 times 2 is 0
  • 7:02 - 7:06
    plus negative 3 times
    negative 4 is positive 12.
  • 7:06 - 7:08
    That one actually did match up,
  • 7:08 - 7:11
    but clearly, these two products
    are not the same thing.
  • 7:11 - 7:14
    The order with which even those defined,
  • 7:15 - 7:16
    it doesn't matter whether you take
  • 7:16 - 7:17
    the yellow one times the purple one
  • 7:17 - 7:19
    or the purple one times the yellow one.
  • 7:19 - 7:21
    Both of those result in a defined product,
  • 7:21 - 7:24
    but we see it's not the same product.
  • 7:24 - 7:26
    Once again, another case showing
  • 7:26 - 7:31
    that multiplication of
    matrices is not commutative.
Title:
Is matrix multiplication commutative
Description:

more » « less
Video Language:
English
Team:
Khan Academy
Duration:
07:32

English subtitles

Revisions