Vector spaces and subspaces, visually
A vector space is a collection you cannot leave by adding or stretching. Drag two points on a line and see whether their sum and their double stay on the line.
Short answer. A vector space is a collection where adding two members, or multiplying one by a number, always gives another member. A smaller collection inside it with the same property is a subspace. You check three things: 0 is in it, sums stay in, and multiples stay in. That is why a line in the plane is a subspace only when it goes through the origin.
u = (, )
v = (, )
Drag the circles at green u and blue v, or type numbers (−3 to 3). The purple line W goes through u and v. When 0, u+v and 2u are on the line they are black, and when they are off it they are orange. Their labels also say "on the line" or "off the line".
Definitions
The page below explains with lines in the plane, but the definitions are the same in every vector space. Scalars are real numbers.
- vector space
- Let V be a set with an addition and a scalar multiplication. V is a vector space if it has a zero vector 0 ∈ V, each u ∈ V has a −u ∈ V, and the axioms below hold for all u, v, w ∈ V and c, d ∈ ℝ. The members of V are called vectors.
- subspace
- A subset W of a vector space V is a subspace of V if W is itself a vector space under the addition and scalar multiplication of V. W is a subspace if and only if the three conditions below hold.
- span
- The set of all linear combinations of vectors v₁, …, vₖ in V. It is a subspace of V.
- column space
- The subspace of ℝᵐ spanned by the columns a₁, …, aₙ of an m×n matrix A.
- null space
- For an m×n matrix A, the subspace of ℝⁿ made of all solutions of Ax = 0.
1. Vector space: a collection you cannot leave by adding or stretching
So far we have seen vectors as arrows or lists of numbers (vectors, n-dimensional vectors). A vector space asks a different question. Not "what is a vector?" but "what can you do with it?" It needs two things: you can add two members, you can multiply a member by a number, and the result is again in the collection. A few obvious rules come with it, such as "the order of adding does not matter" and "adding 0 changes nothing".
So things that are not arrows can form a vector space too.
- Polynomials. Take polynomials of degree 2 or less.
1 + 2xplus3 − x²is4 + 2x − x², and 3 times1 + 2xis3 + 6x. Both are still degree 2 or less. - Functions. Functions that take a real number and return a real number add and scale point by point:
(f + g)(x) = f(x) + g(x)and(c·f)(x) = c·f(x). The result is again such a function. - Matrices. Add two 2×2 matrices entry by entry, or multiply every entry by a number, and you get a 2×2 matrix again.
On the other hand, polynomials of degree exactly 2 do not form a vector space. x² plus −x² is 0, which is not degree 2. With this definition, what you learned for arrows in the plane (linear combinations, basis, dimension) works the same way for polynomials, functions and matrices.
2. Subspace: only three checks
Take part of a vector space, a collection W. If W is a vector space on its own, it is a subspace. You do not need to recheck every rule. Rules like the order of adding already hold in the big space, so the only question left is "can you leave W?"
Is W a subspace?
① Is 0 in W? 0 ∈ W
② For u, v in W, is u + v in W? u + v ∈ W
③ For u in W and any number c, is c·u in W? c·u ∈ W
Yes to all three: subspace. No to any one: not a subspace.
W: a collection taken from inside a vector space, the one you are checking.u,v: vectors in W.c: any number.0: the zero vector (the origin).∈: "is in".0 ∈ Wreads "0 is in W".
Checks ② and ③ must hold for every u, v and c in W. One example that works is not enough. But one example that fails is enough to say no.
| Property | What it means |
|---|---|
| Always contains 0 | Every subspace goes through the origin. A line or plane that misses the origin is not a subspace |
| Smallest and largest | The collection holding only 0, {0}, and the whole space are both subspaces |
| Three kinds in the plane | {0}, a line through the origin, the whole plane |
| The overlap is a subspace | Where two subspaces overlap is also a subspace. Joining them usually is not: put the x-axis and y-axis together and (1, 0) + (0, 1) = (1, 1) is on neither axis |
| Closed under linear combinations | It is closed under adding and scaling, so a·u + b·v is always in it |
3. A line through the origin works, a line that misses it does not
Every point on a line through the origin is some multiple of one arrow d: t·d. Add two points and you get s·d + t·d = (s + t)·d. Multiply by c and you get (c·t)·d. Both are again multiples of d, so they stay on the line. A plane through the origin is a subspace for the same reason. In 3D space the subspaces are {0}, lines through the origin, planes through the origin, and the whole space.
A line that misses the origin is a line through the origin pushed sideways by some p, so its points look like p + t·d. Add two of them and you get 2p + (s + t)·d. Now p is in there twice, so the point is off the line that was pushed only once.
Try this. ① The starting line goes through u = (1, 2) and v = (3, 1) and misses the origin by 2.24. u+v = (4, 3) and 2u = (2, 4) are both off the line by 2.24, the same distance as the origin. ② Move v to (−0.5, −1). The line now goes through the origin, u+v = (0.5, 1) and 2u = (2, 4) stay on the line, and the readout says "This line is a subspace." ③ Put v on top of u at (1, 2) and the two points no longer fix one line.
4. How the checks are built: where does a line that misses the origin fail?
We try the three checks one by one on the starting line. It goes through u = (1, 2) and v = (3, 1), and its equation is x + 2y = 5. To see if a point is on the line, put it into x + 2y and see if you get 5. In the formula, W is the set of points on the line, ∈ means "is in", and ⇔ means "exactly when".
Press "Next" to go one step at a time. A check is added to the formula above (the orange background marks the new piece), the point for that check appears in the picture, and its label shows what you get when you put it into x + 2y.
Written only as formulas, the steps above are these.
In short. On a line a·x + b·y = k, adding two points gives the value k + k, and multiplying by c gives c×k. For these to stay k every time, you need k = 0, and that is the same as saying the origin (0, 0) is on the line.
5. Worked example: is y = 2x a subspace?
Let W be the points (x, y) with y = 2x. This is the line from "Try this" ②.
- Is 0 in it? Put in (0, 0):
0 = 2×0. Yes. - Do sums stay in? Points in W look like
(a, 2a).(a, 2a) + (b, 2b) = (a + b, 2(a + b)), so the second number is still twice the first. With numbers:(1, 2) + (−0.5, −1) = (0.5, 1), and1 = 2×0.5. - Do multiples stay in?
c·(a, 2a) = (c·a, 2·c·a). Still twice. With numbers:2·(1, 2) = (2, 4), and4 = 2×2.
The same work written as formulas:
All three hold, so it is a subspace. On the other hand, for y = 2x + 1, putting (0, 0) into check ① gives 0 = 1, so it fails right away.
6. Span, and the subspaces a matrix makes
Pick a few vectors and collect every linear combination you can make from them. The result is always a subspace. It is called the space those vectors span. See linear combinations for more. The smallest set of vectors that builds a subspace with nothing extra is a basis, and how many vectors it has is the dimension.
A matrix A comes with four subspaces. Here are two of them.
- Column space. The space the columns of A span, which is every place
A·xcan reach.A·x = bhas an answer exactly when b is in the column space. - Null space. Every x with
A·x = 0. IfA·x = 0andA·y = 0, thenA·(x + y) = 0andA·(c·x) = c·0 = 0, so it is a subspace.
The other two, and how their sizes relate, are on the rank page.
Where it is used
- Systems of equations. The answers to
A·x = 0form the null space, a line or plane through the origin. The answers toA·x = bwith b ≠ 0 are that shape pushed sideways, so they are not a subspace. If there is an answer at all, adding null space points to one answer gives every answer (systems of linear equations). - Least squares fitting. When you fit a line to data, the predicted values always lie in the column space of the data matrix. Least squares picks the point in the column space closest to the real values.
- Reducing dimensions. PCA first subtracts the mean to move the data to the origin, then looks for the line or plane through the origin (a subspace) that holds the data best.
Common questions
How is a subspace different from a vector space?
A subspace is a vector space too. We call it a subspace when it sits inside another vector space. So when you check one, it inherits the rules of the big space, and you only check three things: is 0 in it, and is it closed under adding and scaling.
Why is a line that misses the origin not a subspace?
A subspace must contain 0, and that line does not contain the origin. On top of that, adding two points on the line or doubling one takes you off the line.
Why check for 0 separately?
If the collection is closed under scaling, multiplying by c = 0 gives 0, so for a collection that is not empty, check ③ already covers check ①. Checking 0 first is still the fastest way to rule out a collection that misses the origin, and it also rules out the empty collection.
Words
| Plain words used here | Textbook term |
|---|---|
| a collection you cannot leave by adding or stretching | vector space, linear space |
| a smaller collection inside it | subspace |
| you cannot leave it | closed under addition and scalar multiplication |
| multiplying by a number | scalar multiplication |
| the origin, 0 | zero vector |
| everything you can make | span |
| where A·x can reach | column space |
| every answer to A·x = 0 | null space, kernel |
| a line or plane that misses the origin | affine subspace |