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

Multiplying a matrix by a column vector

Created by Sal Khan.

Want to join the conversation?

  • orange juice squid orange style avatar for user Abraham George
    Do vectors in physics have anything to do with vectors in matrices?
    (14 votes)
    Default Khan Academy avatar avatar for user
    • leaf red style avatar for user Michael Tiberio
      Yes. They are different representations of the same data. A vector in physics, what I will call "unit vector notation", may look like the following: 2i+3j. And in "matrix notation": [ 2 3 0 ] (though this is typically column vector, which is difficult to represent here). If I have another vector 4i+5j or [ 4 5 0 ] and we look at some of the operations you will start to notice the similarities.

      Unit Vector Notation ¦¦ Matrix Notation
      a = 2i+3j ¦¦ a = [ 2 3 0 ]
      b = 4i+5j ¦¦ b = [ 4 5 0 ]
      a+b = 6i+8j ¦¦ a+b = [ 6 8 0 ]
      a-b = -2i-2j ¦¦ a-b = [ -2 -2 0 ]
      ab = 23 ¦¦ ab = 23 <= dot product
      a x b = -2k ¦¦ a x b = [ 0 0 -2 ] <= cross product
      b x a = 2k ¦¦ b x a = [ 0 0 2 ] <= cross product

      Where:
      i, j, and k are Cartesian unit vectors in the x, y, and z dimensions, respectively.
      (It butchered my formatting, the ¦¦ in each row serves as a column divider.)

      In the unit vector notation the i term represents the x component, the j term represents the y component, and the k term represents the z component. In matrix notation the first term represents the x component, the second term represents the y component, and the third term represents the z component.

      You can see from the examples above that the matrix notation and the unit vector notation yield the same results for the same operations. Either notation is correct, however one notation may be more convenient depending on the tools at hand.
      (17 votes)
  • male robot donald style avatar for user Jake Sebastian-Jones
    What phenomena or state in real life is represented by this operation? Why was this operation necessary in the first place?
    (5 votes)
    Default Khan Academy avatar avatar for user
    • blobby green style avatar for user kiran916.vanam
      For ex, we need to solve two equations
      2x + 3y = 5;
      x + y = 2;
      I can represent this as product of Matrix A{A is a 2x2 matrix with following rows(2,3) , (1,1)} and column vector w( w is a 2x1 matrix with rows (x),(y)), the resulting matrix is equal to Column Matrix B (B is matrix with rows (5),(1)). By performing certain row and col operations(you'll come to know, if you dont know right now) u can solve for x and y.

      You may find using matrix in this scenario is way more complicated than to solve by method of substitution, but matrices reduces the complexity if we have to solve 'n' equations in 'n' dimensions. Hope this helps
      (3 votes)
  • piceratops ultimate style avatar for user L. A. Wilson
    Briefly (please), how do vectors differ from n-by-1 matrices? Vectors imply direction in one dimension, but thus far we have only seen examples of vectors displayed as single columns. Are vectors ever displayed as rows instead of columns? I'm not asking about differing notation, but could changing a vector's direction change its application?
    (3 votes)
    Default Khan Academy avatar avatar for user
    • purple pi teal style avatar for user PrincessGLG
      I had a similar question a while ago about how vectors differ from matrices and Molly kindly gave me this answer:

      "Vectors are used in geometry to simplify three-dimensional problems, and many quantities in physics are vector quantities. A vector has the ability to simultaneously represent magnitude and direction. A matrix, on the other hand, is a rectangular array of numbers which is a key tool in linear algebra. It is used to represent linear transformations and keep track of coefficients in linear equations. Matrices can be made up of row vectors or column vectors. Basically, vectors can be within matrices but not vice versa. Here is a source if you'd like more examples: http://www.differencebetween.net/science/difference-between-vector-and-matrix/"

      Hopefully this helps you as it did me!
      (3 votes)
  • leaf grey style avatar for user Duc M. Tran
    What is a vector? I don't quite get how he'd multiply two matrices of different dimensions. Please help, am I missing something here?
    (4 votes)
    Default Khan Academy avatar avatar for user
  • mr pants teal style avatar for user Richard
    I thought w was a matrix...why is it called a vector?
    (3 votes)
    Default Khan Academy avatar avatar for user
  • leaf green style avatar for user Nadim
    Isn't " w " a 3 x 1 matrix? Why is Sal saying it's a vector?
    (2 votes)
    Default Khan Academy avatar avatar for user
  • male robot johnny style avatar for user ansh
    cant we multiply w *A
    w is 3*1 and A is 2*3 so the column of w is not equal to the row of a so we shouldnt be able to
    (2 votes)
    Default Khan Academy avatar avatar for user
  • piceratops ultimate style avatar for user Tom Brannan
    In what sense is this really a vector, though? I recall Sal talking about vectors in the Linear Algebra playlist, and I thought that they could be written in either column or row form without changing the meaning. In the case of adding a vector to a matrix, the way it's written (nx1 or 1xn) is very important. So isn't it more correct to say you're smushing a vector into an nx1 matrix, then doing matrix multiplication, rather than multiplying a vector times a matrix?
    (1 vote)
    Default Khan Academy avatar avatar for user
    • spunky sam blue style avatar for user Jay Smith
      Think about what a 3-D vector really is. It's just an ordered set of 3 numbers, the x-, y-, and z- components. the vector 3i+4j-5z could just as easily be written as [ 3 4 -5]. It's not squished into a 1x3 matrix, it IS a 1x3 matrix.Turn it on end and it's a 3x1.
      (3 votes)
  • female robot grace style avatar for user Sierra
    I thought vectors were only supposed to be 2X1 matrices are a 1X2 matrix, like points on a graph. How is it that the problem in the beginning is a 3X1?
    (2 votes)
    Default Khan Academy avatar avatar for user
  • orange juice squid orange style avatar for user Ramana
    Does this mean that you cannot multiply same dimension matrices?
    (1 vote)
    Default Khan Academy avatar avatar for user

Video transcript

So we're multiplying matrix A here by vector w. And they ask us what is A times w? So let me get my scratch pad out. And let's think about this. So we have matrix A times vector w. So just as a reminder, Aw-- and I'll write it in bold right over here-- Aw. And I could write it either as a vector like that, or I could bold that as well. Aw. It's lowercase for a vector, uppercase for a matrix. This is the same thing as matrix A times vector w-- let me do that same color-- which is the same thing. This is matrix A. So it's, A is 0, 3, 5, 5, 5, 2 times vector w. W is the vector 3, 4, 3. So we have a matrix with two rows and three columns, so it is a 2 by 3 matrix, times a vector. And this is a column vector. It is three rows in one column. So you could view this as a 3 by 1 matrix. And so, deciding whether this is even a valid operation, it's just like multiplying two matrices. You can view this column vector is really just a 3 by 1 matrix. And the only way that matrix multiplication is defined is if the columns in this matrix is equal to the rows in this matrix. And we see that is the case, this vector. This matrix, matrix A, has three columns: 1, 2, 3. And this and vector w has exactly three rows. So matrix multiplication, or matrix times vector multiplication, is defined here. And the way that we're going to do it, we're going to end up with a 2 by 1. You could call it a 2 by 1 matrix. It's going to have two rows in one column. Or you could view it as a column vector, when you have two rows and one column. But either way, let's actually think about how we would compute it. So it's going to have two rows and one column. Then I'm going give a lot of space so that we can actually do the calculation. So the top entry right over here, we're going to get the row information from our first matrix, and then the column information. There's only one column here. But we're going to get that from this matrix or this vector, whatever you want to call it. So we're going to have 0 times 3, plus 3 times 4, plus 5 times 3. Now the second entry right over here is going to be the second row here. Essentially, the dot product of that with this vector. And if you don't know what the dot product is, I'm essentially about to do that. It's going to be-- you take each corresponding term, take their product, and then add up everything together. So you have 5 times 3, plus 5 times 4, plus 2 times 3. And this is going to simplify to-- This top term, this is a 0. This is 12 plus 15, which is 27. And then the second term, this is 15 plus 20 plus 6. So this is 35 plus 6 is 41. So it's a column vector, two rows, 27 and 41. Now let's input that, 27 and 41. So we get 27. And here we can put 41, and check our answer, and we got it right.