If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Using matrices to manipulate data: Pet store

In other videos, we saw how we can use matrices to represent real-world situations. Once we do that, we can also manipulate the matrices (using common matrix operations like addition, subtraction, and scalar multiplication) to reveal more information about the context. Here, we manipulate matrices that represent the inventory of dog food in a pet store chain. Created by Sal Khan.

Want to join the conversation?

  • aqualine ultimate style avatar for user Joey.v.beast
    At , Sal said matrix C is how many more (or less,) bags. Wouldn't the more or less statement make this an absolute value problem? With the wording used, I see matrix C as:
    3 1
    7 3
    5 6
    (2 votes)
    Default Khan Academy avatar avatar for user
  • duskpin ultimate style avatar for user NatanPi
    Is there a simple way to figure out if we subtract or add?
    (1 vote)
    Default Khan Academy avatar avatar for user
    • duskpin ultimate style avatar for user TotallyNotAFurryÒwÓ
      Yes, to calculate matrix C, you need to subtract the corresponding entries of matrix B from matrix A. If you want to know how many more bags of each type and size there are in location A relative to location B, you need to subtract the number of bags in location B from the number of bags in location A. If the result is positive, then there are more bags in location A, and if it is negative, then there are fewer bags in location A. So, to summarize, you subtract when you want to find the difference between two values, and you add when you want to find the sum of two values.
      (2 votes)
  • stelly orange style avatar for user Matthew Barnett
    If anyone's curious, matrix D would look like this:

    |13 13|
    |13 21|
    |15 24|
    (1 vote)
    Default Khan Academy avatar avatar for user

Video transcript

- [Instructor] We're told a certain pet store chain has three types of dog food and each comes in bags of two different sizes. Matrix A represents the store's inventory at location A, where rows are food types and columns are bag sizes. So let's see, it's store A. That's what matrix A is telling us. They're telling us we have three different types of food, three different types of dog food, and then they each come in two different sizes. So for example, type 1 dog food in size 1, they have five bags of that while type 2 dog food in size 2, they have nine bags of that. All right. That's fair enough. Matrix B represents the store's inventory at location B. All right, same thing for store B. Matrix C represents how many more, or less, bags of each type and size there are in location A relative to location B. Complete matrix C. So pause this video and see if you can have a go at that. So we need to fill in the entries here of matrix C. All right, now let's do this together. So let me just review what it just told us. Matrix C represents how many more bags of each type and size there are in location A relative to location B. So for example, this first entry right over here, we wanna know how many more bags of type 1, size 1 there are in location A than there are in location B? Well, I would take the number that there are in location A and then from that subtract how many there are in location B. That would tell me how many more I have in location A. So if I take five minus eight, what am I going to get? Well, I'm going to get negative three right over here, and you might already be recognizing what's happening. For every corresponding entry, I'm gonna subtract the entry from matrix B from the entry in matrix A, or another way to think about it is, if I take matrix A and I subtract matrix B, I am going to get matrix C. I'm just gonna subtract all of the corresponding entries. So if I do seven minus six, and that is going to be one, I'm just gonna color code this. If I do three minus 10, that's going to be negative seven. If I do, I'm running out of colors. If I do nine minus 12, that is also going to be negative three. And then if I do this brown color, 10 minus five, that is going to be positive five. And then if I do 15 minus nine, that is positive six. So we can see that, for example, type 1, size 2, we have one more in store A than we have in store B. But if we think about type 2, size 1, it shows us that store A has actually seven fewer of that than store B does. Now we have one last question here that is below the screen, but let me scroll down here. So they tell us that matrix D is defined as follows, or is defines as follows. (chuckles) Make a little grammatical. Is defined as follows: D is equal to A plus B. What does matrix D represent? So they're not asking us to calculate A plus B. Not asking us to add the matrices, but you know how to do it. You would add the corresponding entries. But what does D represent? Well, if you add the corresponding entries, remember, this is the inventory of store A, this is the inventory of store B. So if you were to add them, the matrix D would tell you the combined inventories of A and B, for each of the types and sizes.