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

Dimension of the null space or nullity

Dimension of the Null Space or Nullity. Created by Sal Khan.

Want to join the conversation?

  • blobby green style avatar for user udayanmaurya
    If we can have exercises for these concepts as well it will be great. As these concepts are difficult to master.
    (48 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user kyriakosp2210
    why x2 is a free variable ? isnt x2 pivot as well ?
    (17 votes)
    Default Khan Academy avatar avatar for user
    • blobby green style avatar for user Jeff B
      When you're looking at free variables, pay attention to the pivot columns. The first and third columns hold a pivot. That leaves the second, fourth, and fifth as free variables.

      Realistically, you could treat x2 as a non-free, but to do so would mean you'd have to make x1 free in order to satisfy the first row of the matrix. The general practice, though, is to treat the pivot, x1, as the non-free and x2 as the free.

      When you solve an augmented matrix, it's solving a system of equations. If you were to place a vector of values into the matrix Sal used in an attempt to solve for values, you would still have to CHOOSE random values for x2, x4, and x5 to be able to solve for x1 and x3. That's where the notion of a "free" variable comes from. The math gives you the freedom to choose any value for those 3 variables and still come up with an answer for the pivots.
      (23 votes)
  • leaf blue style avatar for user George G
    I am confused. In a previous video ("null space and column space") we learned that the "basis" are the column vectors that correspond to the pivot entries in the rref(B). Which for our case would be the column vectors [1,1] and [2,3]. These TWO vectors should be the basis of the column space of B, which is clearly in R^2. How can the THREE vectors in this video be also a "basis"! (and these are in R^5?!). Or is it that a "basis of a column space" is different than a "basis of the null space", for the same matrix?
    (15 votes)
    Default Khan Academy avatar avatar for user
    • male robot donald style avatar for user John-Paul Meyer
      In short, you are correct to say that 'a "basis of a column space" is different than a "basis of the null space", for the same matrix."

      A basis is a a set of vectors related to a particular mathematical 'space' (specifically, to what is known as a vector space). A basis must:
      1. be linearly independent and
      2. span the space.
      The 'space' could be, for example: R^2, R^3, R^4, ... , the column space of a matrix, the null space of a matrix, a subspace of any of these, and so on (there are many more examples; vector spaces appear everywhere in mathematics). When someone gives you a basis, you need to ask: "A basis of what space?"

      In general, if I give you two different spaces, A and B, then a basis for A will be different to a basis for B.

      Now, in general, the column space of a given matrix does not equal the null space of that matrix. Therefore, in general, a basis for the column space of the matrix will be different to a basis for the null space of that matrix.
      (24 votes)
  • blobby green style avatar for user Firdaus Ibrahim
    Hi sal i just wanna ask question about reducing echelon form,how to know if that matrix is been reduce completely???
    (7 votes)
    Default Khan Academy avatar avatar for user
    • leaf blue style avatar for user Ryan Hennessee
      There are three conditions for a matrix to be in RREF
      1) The first non-zero entry of a row must be a 1; this entry is called a pivot
      2) The pivot for each row must to the right of all the pivots in any rows above.
      3) Any columns that contain pivots must have zeros for all other entries except the pivot.

      As a result of 2 and 3, any rows that contain all zeros must be at the bottom of the matrix.

      Hope that helps.
      (26 votes)
  • blobby green style avatar for user Evadora de Zhengia
    Didn't Sal say that if Nul B is not the zero vector, the B is linearly dependent?
    Why are we proving that B is linearly INDEPENDENT so that it can form the basis for the null space?
    (8 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user George
    I've seen an example of a subspace in R^3 only have a dimension of 2. How is this visually possible? Doesn't a vector in R^3 mean it's in the third dimension?
    (1 vote)
    Default Khan Academy avatar avatar for user
    • primosaur ultimate style avatar for user Derek M.
      The dimension only means the number of elements in the basis for the subspace. Think of a plane in ℝ³ that passes through the origin, how many vectors/elements does it take at minimum, such that when you take their span, you get a plane? Well, 2. And that tells us that the basis for a plane has 2 vectors in it. If the dimension is again, the number of elements/vectors in the basis, then the dimension of a plane is 2.
      So even though the subspace of ℝ³ has dimension 2, the vectors that create that subspace still have 3 entries, in other words, they still live in ℝ³.
      (9 votes)
  • blobby green style avatar for user Patrik Andersson
    What would the dimension of the nullspace be if the the only sloution to Ax = 0 is x = 0? Can you consider the null vector as a basis?
    (4 votes)
    Default Khan Academy avatar avatar for user
    • leaf green style avatar for user Anant Sogani
      Since the null space of A is the set of vectors x that satisfy Ax = 0, and you say that the only such x is the zero vector 0, so symbolically, N(A) = {0}.
      The next part is to find the basis for N(A). This will be the set S of linearly-independent vector(s) that span N(A). If you think about it, only the null vector 0 can be in that set, as any non-null vector will span beyond N(A). Thus S = {0}.
      The dimension of a null space is the number of elements in its basis. Since here the basis set S has one element, dim(N(A)) = 1. So, yes, you're right - the null vector 0 is the basis of the null space here.
      (2 votes)
  • blobby green style avatar for user Liam Barkley
    Is the null space the same thing as a solution space?
    (1 vote)
    Default Khan Academy avatar avatar for user
  • hopper jumping style avatar for user Zexi Wang
    At the end of the video, I think the non-pivot column may not represent a free variable. If a non-pivot column of a matrix only contains zero, it can't represent a free variable. Is it right?
    (2 votes)
    Default Khan Academy avatar avatar for user
  • leaf blue style avatar for user ruth
    If the basis for a solution space is the zero vector, will the dimension for the solution space also be zero?
    (4 votes)
    Default Khan Academy avatar avatar for user

Video transcript

Let's say I have this matrix B, here, and I want to know what the null space of B is. And we've done this multiple times but just as a review, the null space of B is just all of the x's that are a member. It's all the vector x's that are member of what? 1, 2, 3, 4, 5 that are members of r to the fifth, where B, my matrix B, times any of these vector x's, is equal to 0. That's the definition of the null space. I'm just trying to find the solution set to this equation right here. And we've seen before, that the null set of the reduced row echelon form of B is equal to the null set of B. So what's the reduced row echelon form of B? And this is actually almost trivially easy. Let me just take a couple of steps right here-- to get a 0 here, let's just replace row 2 with row 2 minus row 1 So what do we get? Row 2 minus row 1. Row 1 doesn't change, it's just 1, 1, 2, 3, 2. And then row 2 minus row 1. 1 minus 1 is 0. 1 minus 1 is 0. 3 minus 2 is 1. 1 minus 3 is minus 2. 4 minus is 2 is 2. We're almost there. Let's see, so this is a free variable right here. This is a pivot variable right here. We have a 1. So let me get rid of that guy right there. And I can get rid of that guy right there, by replacing row 1 with row 1 minus 2 times row 2. So now row 2 is going to be the same. 0, 0, 1 minus 2, 2. And let me replace row 1 with row 1 minus 2 times row 2. So 1 minus 2 times 0 is 1. 1 minus 2 times 0 is 1. 2 minus 2 times 1 is 0. 3 minus 2 times minus 2. So that's 3 plus 4 is 7, right? 2 times this is minus 4 and we're subtracting it. And then 2 minus 2 times 2-- that's 2 minus 4-- it's minus 2. So this is the reduced row echelon form of B is equal to that right there. And then if I wanted to figure out its null space, I have x1, x2, x3, x4, and x5 equaling-- I'm going to have two 0's right here. Now I can just write this as just a set of or a system of equations. So let me do that. I get x1. I'm going to write my pivot variables in a green color. x1 plus 1 times x2, so plus x2, plus 0 times x3. Plus 7 times x4. Minus 2 times x5 is equal to that 0 right there. And then I get my-- this is x3, right? 0 times x1 plus 0 times x2 plus 1 times x3. So I get x3 minus 2 times x4 plus 2 times x5 is equal to that 0 right there. And then if we solve for our pivot variables, right? These are our free variables. We can set them equal to anything. If we solve for our pivot variables what do we get? We get x1 is equal to-- I should do that in green. The color coding helps. I get x1 is equal to minus x2 minus 7x4 plus 2x5, just subtracted these from both sides of the equation. And I get x3 is equal to-- we've done this multiple times-- 2x4 minus 2x5. And so if I wanted to write the solution set in vector form, I could write my solution set or my null space, really, is-- or all the possible x's. x1, x2, x3, x4, x5. This is my vector x, that's in r5. It is equal to a linear combination of these. So let me write it out. The free variables are x2 times some vector right there. Plus x-- is x3, no x3 is not a free variable. Plus x4, that's my next free variable, times some factor. Plus x5 times some vector. I've run out of space. Plus x5 times some vector. And what are those vectors? Let's see. I don't want to make this too dirty, so let me see if I can maybe move-- nope that's not what I wanted to do. Let me just rewrite this. I haven't mastered this pen tool yet, so let me rewrite this here. So x3 is equal to 2x4 minus 2x5. Let me delete this right over here so I get some extra space. Cross that out. I think that's good enough. So I can go back to what I was doing before. x5 times some vector right here. And now what are those vectors? We just have to look at these formulas. x1 is equal to minus 1 times x2. So minus 1 times x2. Minus 7 times x4. Plus 2 times x5. Fair enough. And what is x3 equal to? x3 is equal to 2x4. 2x4, right? It had nothing to do with x2 right here, so it's equal to 2x4 minus 2x5. And then 0 times x2, right? Because it had no x2 term right here. And then what is x2 equal to? Well x2 is just equal to 1 times x2. And so all of these terms are 0 right there. And I want you to pay attention to that. I'll write it right here. x2 is a free variable, so it's just equal to itself, right? 1 and you write a 0 and a 0. x4 is a free variable. And this is the important point of this exercise. So it's just equal to 1 times itself. You don't have to throw in any of the other free variables. And x5 is a free variable. So it just equals 1 times itself and none of the other free variables. So right here we now say that all of the solutions of our equation Bx equals 0, or the reduced row echelon form of B times x is equal to 0, will take this form. Or they are linear combinations of these vectors. Let's call this v1, v2, and v3. These are just random real numbers. I can pick any combination here to create this solution set, or to create our null space. So the null space of A, which is of course equal to the null space of the reduced row echelon form of A, is equal to all the possible linear combinations of these 3 vectors, is equal to the span of my vector v1, v2, and v3. Just like that. Now, the whole reason I went through this exercise-- because we've done this multiple times already-- is to think about whether these guys form a linear independent set. So my question is are these guys linearly independent? And the reason why I care is because if they are linearly independent then they form a basis for the null space, right? That we know that they span the null space, but if they're linearly independent, then that's the 2 constraints for a basis. You have to span the subspace, and you have to be linearly independent. So let's just inspect these guys right here. This v1, he has a 1 right here. He has a 1 in the second term because he corresponds to the free variable x2, which is the second entry, so we just throw a 1 here. And we have a 0 everywhere else in all of the other vectors in our spanning set. And that's because for the other free variables we always wanted to multiply them times a 0, right? And this is going to be true of any null space problem we do. For any free variable, if this free variable represents a second entry, we're going to have a 1 in the second entry here. And then a 0 for the second entry for all of the other vectors associated with the other free variables. So can this guy ever be represented as a linear combination of this guy and that guy? Well there's nothing that I can multiply this 0 by and add to something that I multiply this 0 by to get a 1 here. It's just going to get 0's. So this guy can't be representated as a linear combination of these guys. Likewise, this vector right here has a 1 in the fourth position. Why is it a fourth position? Because the fourth position corresponds to its corresponding free variable, x4. So this guy's a 1 here. These other guys will definitely always have a 0 here. So you can't take any linear combination of them to get this guy. So this guy can't be represented as a linear combination of those guys. And last, this x5 guy, right here, has a 1 here. And these guys have 0's here. So no linear combination of these 0's can equal this 1. So all of these guys are linearly independent. You can't construct any of these vectors with some combination of the other. So they are linearly independent. So v1, the set v1, v2, and v3 is actually a basis for the null space, for the null space of-- Oh, you know what, I have to be very careful. For the null space of B. Just for variety, I defined my initial matrix as matrix B, so let me be very careful here. So the null space of B was equal to the null space of the reduced row echelon form of B. It's good to switch things up every once in a while, you start thinking that every matrix is named A if you don't. And that's equal to the span of these vectors. So these vectors, and we just said that they're linearly independent. We just showed that because there's no way to get that one from these guys, that one from these guys, or that one from these guys. These guys form a basis for the null space of B. Now this raises an interesting question. In the last video, I defined what dimensionality is. And maybe you missed it because that video was kind of proofy. But the dimensionality, the dimension, of a subspace-- I'll redefine it here-- is the number of elements in a basis for the subspace. And in the last video I took great pains to show that all bases for any given subspace will have the same number of elements. So this is well defined. So my question to you now is: what is the dimension of my null space of B? What is that the dimension of my null space of B? Well, the dimension is just the number of vectors in a basis set for B. Well this is a basis set for B right there. And how many vectors do I have in it? I have 1, 2 3 vectors. So the dimension of the null space of B is 3. Or another way to think about it-- or another name for the dimension of the null space of B-- is the nullity, the nullity of B. And that is also equal to 3. And let's think about it, you know I went through all this exercise. But what is the nullity of any matrix going to be equal to? It's the dimension of the null space. Well the dimension of the null space-- you're always going to have as many factors here as you have free variables. So in general, the nullity of any matrix of any matrix-- let's say matrix A-- is equal to the number of I guess you could call it free variable columns or the number free variables in, well, I guess we call it in the reduced row echelon form, or I guess we could say the number of non-pivot columns. The number of non-pivot columns in the reduced row echelon form of A. Because that's essentially the number of free variables-- all of those free variables have an associated, linearly independent vector with each of them, right? So the number of variables is the number of vectors you're going to have in your basis for your null space. And the number of free variables is essentially the number of non-pivot columns in your reduced row echelon form, right? This was a non-pivot column, that's a non-pivot column, that's a non-pivot column. And they're associated with the free variables x2, x4, and x5. So the nullity of a matrix is essentially the number of non-pivot columns in the reduced row echelon form of that matrix. Anyway, hopefully you found that vaguely useful.