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

Intro to matrices

Take the red pill and enter the Matrix! Created by Sal Khan.

Want to join the conversation?

  • mr pink red style avatar for user Christian
    Can a matrix have an expression or an equation? What about variables and complex numbers, can it have those too?
    (170 votes)
    Default Khan Academy avatar avatar for user
    • blobby green style avatar for user Dorus Rolvink
      Basically, a matrix is just a type of table. You can put in the cells whatever you like, but to preserve all the functionality of a matrix, it should be possible to multiply and add up each cell with any other.
      For example, it would make little sense to multiply "y=x+1" with "j=3r".
      (172 votes)
  • leaf grey style avatar for user Michœl
    Is there a difference between the Scalar "1" and the Matrix [ 1 ] ?
    (91 votes)
    Default Khan Academy avatar avatar for user
  • aqualine ultimate style avatar for user Shamarr Voskuil
    Is it okay to have decimal numbers in matrices because every video you have has shown whole numbers inside of the matrices
    (30 votes)
    Default Khan Academy avatar avatar for user
    • hopper cool style avatar for user Chuck Towle
      The examples use integers (whole numbers) because the math is less complicated so it makes it easier to explain without getting lost in more difficult calculations.
      Yes, you can have decimals or fractions in a matrix. When you find the inverse of a matrix, you almost always have fractions (or decimals) in the resulting matrix.
      (44 votes)
  • blobby green style avatar for user Jason Brown
    Hopefully this is the right place to ask this question. What are the elements of a matrix and how is it found?
    (26 votes)
    Default Khan Academy avatar avatar for user
  • leaf grey style avatar for user Nikki
    Didn't Sal spell the word " columns" wrong at ?
    (0 votes)
    Default Khan Academy avatar avatar for user
    • hopper cool style avatar for user Chuck Towle
      Nikki,
      Yes, at he misspelled "columns" carelessly omitting the "n". Sal makes mistakes just like you or I do. None of us are perfect, even Sal. But at Khan Academy, we can keep trying to get closer to perfect. My careless math mistakes dropped substantially when I was forced to get 10 questions in a row correct to be proficient in a skill at Khan Academy.
      (61 votes)
  • leaf yellow style avatar for user ♦SamuelM♦
    What is an "array"?
    (12 votes)
    Default Khan Academy avatar avatar for user
  • mr pink red style avatar for user Hugie8212
    In a Matrix can there be varibles like x so 4 0
    x 7 or not ?
    (7 votes)
    Default Khan Academy avatar avatar for user
    • piceratops ultimate style avatar for user Magistra H
      Yes, and in some fields of mathematics, they are used often. Linear equations can be expressed as matrices:
      4x + 2y = 3
      2x -- y = 4
      would be the matrix equation
      | 4 2 | * | x | = | 3 |
      | 2 -1 | | y | | 4 |

      (I hope the formatting turns out on this. I'm a novice to commenting and am not sure how to display a matrix in-thread. If not, it's a 2x2 of 4, 2, 2, -1 times a 2x1 of x, y set equal to a 2x2 of 3, 4.)
      (17 votes)
  • male robot donald style avatar for user Luis.Vasquez.GBA
    can you use pie or 3.14 in the matrix
    (5 votes)
    Default Khan Academy avatar avatar for user
    • hopper cool style avatar for user Chuck Towle
      Luis,
      You can use pi (π) in a matrix. In the first matrix in this video, Sal used π as the value in the second row, first column.
      You can also use decimals such as 3.14.

      3.14 is only an approximate value of π so if you used 3.14 when π was the exact value, you would be using a approximate value and not the exact value.

      I hope that helps.
      (17 votes)
  • male robot donald style avatar for user Kenny Krempl
    My sister is a Math Major in college and she says that she has never used a Matrix before. Is a Matrix just helpufll but not required?
    (4 votes)
    Default Khan Academy avatar avatar for user
    • piceratops ultimate style avatar for user Just Keith
      Matrix math is, amongst other things, a means of compacting, streamlining and making more efficient, repetitive operations commonly encountered in applied math. You can probably get by without them, but I wouldn't recommend doing so.
      (6 votes)
  • male robot hal style avatar for user nithanth9
    Can matrices also have imaginary numbers, or is it only for real numbers?
    (5 votes)
    Default Khan Academy avatar avatar for user

Video transcript

What I want to do in this video is explore the notion of a matrix outside of the context of a surprisingly good movie that involves Keanu Reeves. And it's actually the first of three. I guess we could call the three movies combined The Matrices. And there is a relationship between the movie, which is about a virtual reality constructed by super-smart computers, and the notion of what a matrix is when you study it in mathematics, or when you study it in computer science. And the connection really is that matrices are used a lot when you are simulating things or when you're constructing things in computer science, especially in, frankly, computer graphics. So the super-intelligent robots that made the matrix in the movie Matrix were probably using matrices in order to do it, if they actually did exist. Now, what is a matrix then? Well, that's a fairly simple answer. It's just a rectangular array of numbers. So for example, this right over here. If I have 1, 0, negative 7, pi, 5, and-- I don't know-- 11, this is a matrix. This is a matrix where 1, 0, negative 7, pi-- each of those are an entry in the matrix. This matrix right over here has two rows. And it has three columns. And because it has two rows and three columns, people will often say that this is a 2 by 3 matrix. Whenever they say it's something by something matrix, they're telling you that it has two rows-- so you see the two rows right over there. And they are telling you that it has three columns. You see the three columns right over there. I could give you other examples of a matrix. So I could have a 1 by 1 matrix. So I could have the matrix 1. This right over here is a 1 by 1 matrix. It has one row, one column. I could have a matrix like this-- 3, 7, and 17. What is this? Well, this has one row. This is the one row that we see here. And it has three columns. This is a 1 by 3 matrix. I could have a matrix-- and I think you see where all of this is going. Figuring out the dimensions of a matrix are not too difficult. I could have a matrix that looks like this, where it's 3, 5, 0, 0, negative 1, negative 7. This right over here has three rows. So it's three rows, and it has two columns. So we would call this a 3 by 2. Let me do that in that same color. We would call it a 3 by 2 matrix, three rows and two columns. So fair enough. You know that a matrix is just a rectangular array of numbers. You can say what its dimensions are. You know that each of these numbers that take one of these positions-- we just call those entries. But what are matrices good for? I still might not be clear what the connection is between this and this right over here. And at the most fundamental level, this is just a compact representation of a bunch of numbers. It's a way of representing information. They become very valuable in computer graphics because these numbers could represent the color intensity at a certain point. They could represent whether an object is there at a certain point. And as we develop an algebra around matrices, and when we talk about developing an algebra around matrices, we're going to talk about operations that we're going to perform on matrices that we would normally perform with numbers. So we're going to essentially define how to multiply matrices, how to add matrices. We'll learn about taking an inverse of a matrix. And by coming up with an algebra of how we manipulate these things, it'll become very useful in the future when you're trying to write a computer graphics program or you're trying to do an economic simulation or a probability simulation, to say, oh, I have this matrix that represents where different particles are in space. Or I have this matrix that represents the state of some type of a game. And I know the algebra of matrices. And I know ways of doing it very efficiently so that I can multiply a bunch of them. Or I could come run a simulation, and I can actually come up with useful results. So that's all matrices are. But as you'll see through this, we can define operations on them. And then later on, when you take a linear algebra course in college, you'll learn a lot more of the depth of how they can be applied and what you can use them to represent.