Vector spaces and subspaces — theory with screen colours: linear combinations, bases, dimension and subspaces (and the grey you can always take out)

In quiz 3 on the Campus I got the very first question wrong: whether a vector was in the subspace spanned by four others, and I ticked “true”. Four vectors in a space of dimension 3 look like more than enough to reach anywhere. They weren’t: two of them were combinations of the other two, so there were really only two directions, and two directions span a plane, not the whole space. The vector was outside that plane.

That is what this topic is about: how many genuinely different directions there are in a bunch of vectors, which ones are enough to reach everything (a basis), how many you need (the dimension), and the “pieces” of the space that behave like a smaller space (subspaces). The example for the whole article is screen colours: every pixel mixes red, green and blue light, so every colour is a vector (r,g,b)(r, g, b) in R3\mathbb{R}^3. Everything rests on topic 2, because each question today ends up as a system of equations. After the theory you have the guided practice.

In a nutshell: a vector space is a set where you can add vectors and multiply them by numbers. A basis is a set of linearly independent vectors that span the whole space, and the number of vectors in it is the dimension. A subspace is a piece of the space that contains 0⃗\vec 0 and is closed under addition and scalar multiplication; it is described by a basis, by parametric equations or by implicit equations.

Before you start. For this topic you only need two things from the previous topics: row-reducing a matrix by Gaussian elimination and reading off its rank (topic 1), and knowing when a system has a solution, exactly one or infinitely many (topic 2, with Rouché-Frobenius). Nothing else. The topic has three big ideas, in this order: mixing vectors and seeing whether any of them is spare (linear combinations, dependence and rank); the smallest set of vectors that reaches everything, how many it has and the recipe of every vector in it (basis, dimension, coordinates and change of basis); and the pieces of the space that work like a smaller space, how to describe them and how to combine them (subspaces, equations, sum and intersection). If you get lost at any point, go back to the tiny lights on the screen: the whole topic can be told with them.

A colour is a vector

A screen has three tiny lights in every pixel: red, green and blue. A colour is how much you switch on each one, so I can write it as three numbers (r,g,b)(r, g, b). Pure red is (1,0,0)(1, 0, 0), green (0,1,0)(0, 1, 0), blue (0,0,1)(0, 0, 1), and when you mix light the intensities add up: red and green together give yellow, (1,1,0)(1, 1, 0); green and blue, cyan, (0,1,1)(0, 1, 1); red and blue, magenta, (1,0,1)(1, 0, 1); and all three, white, (1,1,1)(1, 1, 1).

Two operations on colours are the basis of the whole topic:

  • Adding two colours, component by component: (1,1,0)+(0,0,1)=(1,1,1)(1, 1, 0) + (0, 0, 1) = (1, 1, 1). Yellow plus blue gives white (with light, not with paint).
  • Multiplying by a number: 2⋅(0,1,1)=(0,2,2)2 \cdot (0, 1, 1) = (0, 2, 2), a cyan twice as bright.

A vector space is exactly that: a non-empty set VV of objects (the vectors) with an addition and a product by real numbers (the scalars) that satisfy ten rules. For all u⃗,v⃗,w⃗∈V\vec u, \vec v, \vec w \in V and λ,μ∈R\lambda, \mu \in \mathbb{R}:

RuleWhat it says
1u⃗+v⃗∈V\vec u + \vec v \in V: adding does not take you out of the set
2u⃗+v⃗=v⃗+u⃗\vec u + \vec v = \vec v + \vec u
3u⃗+(v⃗+w⃗)=(u⃗+v⃗)+w⃗\vec u + (\vec v + \vec w) = (\vec u + \vec v) + \vec w
4There is a 0⃗\vec 0 with u⃗+0⃗=u⃗\vec u + \vec 0 = \vec u
5Every u⃗\vec u has an opposite −u⃗-\vec u with u⃗+(−u⃗)=0⃗\vec u + (-\vec u) = \vec 0
6λu⃗∈V\lambda \vec u \in V: multiplying does not take you out of the set
7λ(μu⃗)=(λμ)u⃗\lambda (\mu \vec u) = (\lambda \mu) \vec u
8λ(u⃗+v⃗)=λu⃗+λv⃗\lambda (\vec u + \vec v) = \lambda \vec u + \lambda \vec v
9(λ+μ)u⃗=λu⃗+μu⃗(\lambda + \mu) \vec u = \lambda \vec u + \mu \vec u
101⋅u⃗=u⃗1 \cdot \vec u = \vec u

The example you will use almost always is Rn\mathbb{R}^n, the vectors with nn components and componentwise addition and product. R3\mathbb{R}^3 is the colours; the exam uses R4\mathbb{R}^4 a lot, which you could picture as colours with a fourth number for transparency. But vectors do not have to be arrows: 2×22 \times 2 matrices form a vector space (M2×2M_{2 \times 2}), and so do polynomials of degree at most 2 (P2(x)P_2(x)). They can be added and multiplied by numbers, and they satisfy the ten rules.

Colours as vectors in R³Axes r, g and b in perspective with the unit cube. Arrows from the origin to red (1,0,0), green (0,1,0), blue (0,0,1), yellow (1,1,0), cyan (0,1,1), magenta (1,0,1) and white (1,1,1), with a legend saying each secondary colour is the sum of two primaries.rgbR (1,0,0)G (0,1,0)B (0,0,1)Y (1,1,0)C (0,1,1)M (1,0,1)W (1,1,1)rgbR (1,0,0)G (0,1,0)B (0,0,1)Y (1,1,0)C (0,1,1)M (1,0,1)W (1,1,1)0RredGgreenBblueYyellow = R + GCcyan = G + BMmagenta = R + BWwhite = R + G + B
Mixing light is adding vectors: the corners of the cube are the basic colours.

Just for the curious. A real screen only accepts intensities from 0 to 255 in each channel, and a “negative green” does not exist. In algebra we let the components be any real number: the calculations stay clean and, when needed, you clip to the range the screen accepts. A colour with a negative component is not a calculation error; it is a colour the screen cannot light up.

Linear combinations: mixing lights

Before the definition, let’s do it in your head. Imagine you only have two lamps, a yellow one and a cyan one, each with its own dimmer. If you set the yellow one to intensity λ1 \lambda_1 and the cyan one to λ2 \lambda_2 , what colour comes out?

Yellow switches on red and green; cyan, green and blue. So red only comes from the yellow lamp, blue only comes from the cyan lamp, and green comes from both. The colour you get is (λ1, λ1+λ2, λ2) (\lambda_1,\ \lambda_1 + \lambda_2,\ \lambda_2) .

Look at what that expression says: with these two lamps, green is always as much as red and blue together. That already tells you, without solving any system, which colours you can make and which you cannot:

  • (2,3,1) (2, 3, 1) can be made: 3=2+1 3 = 2 + 1 .
  • Pure red (1,0,0) (1, 0, 0) cannot: it would need 0=1+0 0 = 1 + 0 .

What you have just done, putting a number in front of each vector and adding up, is called a linear combination. The numbers are the dimmers.

A linear combination of the vectors u⃗1,u⃗2,…,u⃗m\vec u_1, \vec u_2, \dots, \vec u_m is any vector of the form

λ1u⃗1+λ2u⃗2+⋯+λmu⃗m,λ1,…,λm∈R \lambda_1 \vec u_1 + \lambda_2 \vec u_2 + \dots + \lambda_m \vec u_m, \qquad \lambda_1, \dots, \lambda_m \in \mathbb{R}

With colours, it is a mixing recipe: “two of yellow and one of cyan” is

2 (1,1,0)+1 (0,1,1)=(2,2,0)+(0,1,1)=(2,3,1) 2 \, (1, 1, 0) + 1 \, (0, 1, 1) = (2, 2, 0) + (0, 1, 1) = (2, 3, 1)

And the reverse question is the one you will ask most: can you get a given colour by mixing some specific colours? For example, is (2,3,1)(2, 3, 1) a linear combination of yellow and cyan? You set up λ1(1,1,0)+λ2(0,1,1)=(2,3,1)\lambda_1 (1, 1, 0) + \lambda_2 (0, 1, 1) = (2, 3, 1), which component by component is a system:

λ1=2,λ1+λ2=3,λ2=1 \lambda_1 = 2, \qquad \lambda_1 + \lambda_2 = 3, \qquad \lambda_2 = 1

It has a solution (λ1=2\lambda_1 = 2, λ2=1\lambda_2 = 1), so yes. What about pure red (1,0,0)(1, 0, 0)? The first and third components would give λ1=1\lambda_1 = 1, λ2=0\lambda_2 = 0, but then the second says 1+0=01 + 0 = 0: inconsistent. With yellow and cyan there is no way to make pure red.

A linear combination of yellow and cyanArrows for yellow (1,1,0), twice yellow and cyan (0,1,1); the sum of 2 yellows and 1 cyan is the diagonal of the parallelogram and reaches (2,3,1).rgbY2YC2Y + C = (2, 3, 1)recipe2 · (1, 1, 0)+ 1 · (0, 1, 1)= (2, 3, 1)λ₁ = 2, λ₂ = 1
A linear combination is a recipe: how much of each vector, then add them up.

“Is v⃗\vec v a linear combination of these vectors?” always turns into “is this system consistent?”. The vectors are the columns of the coefficient matrix and v⃗\vec v is the column of constants. Rouché-Frobenius (topic 2) answers it: it is a linear combination if and only if the rank does not change when you add v⃗\vec v.

Linear dependence and independence

Again, first in your head. You have a red lamp and a green one. Someone offers you a third one, yellow. Does it add anything? No: anything you do with the yellow lamp you can do by switching on red and green at the same time. That lamp is spare. With a blue one it is the other way round: there is no way to make blue out of red and green, so blue does add something.

A vector being spare means it is a linear combination of the others. To check that literally you would have to test the vectors one by one against the rest: with four vectors, four systems. The formal definition packs it all into a single equation with a trick: move everything to one side. Saying (1,1,0)=(1,0,0)+(0,1,0) (1, 1, 0) = (1, 0, 0) + (0, 1, 0) is the same as saying (1,0,0)+(0,1,0)−(1,1,0)=(0,0,0) (1, 0, 0) + (0, 1, 0) – (1, 1, 0) = (0, 0, 0) : a mix that gives black without all the dimmers at 0. And the other way round, if you find a mix like that, you solve for any vector whose number is not 0 and there is your spare one.

Some vectors are linearly dependent if one of them can be obtained by mixing the others. The formal definition says it with a single equation: S={u⃗1,…,u⃗m}S = \{\vec u_1, \dots, \vec u_m\} is linearly dependent if there are scalars λ1,…,λm\lambda_1, \dots, \lambda_m, not all 0, with

λ1u⃗1+λ2u⃗2+⋯+λmu⃗m=0⃗ \lambda_1 \vec u_1 + \lambda_2 \vec u_2 + \dots + \lambda_m \vec u_m = \vec 0

And it is linearly independent if that equation only has the trivial solution λ1=⋯=λm=0\lambda_1 = \dots = \lambda_m = 0. Notice it is a homogeneous system: it always has the trivial solution (topic 2), and the question is whether it has more.

Red, green and yellow are dependent, because yellow is red plus green:

1⋅(1,0,0)+1⋅(0,1,0)−1⋅(1,1,0)=(0,0,0) 1 \cdot (1, 0, 0) + 1 \cdot (0, 1, 0) – 1 \cdot (1, 1, 0) = (0, 0, 0)

with λ=(1,1,−1)\lambda = (1, 1, -1), not all 0. Yellow, cyan and magenta, on the other hand, are independent. You set up λ1(1,1,0)+λ2(0,1,1)+λ3(1,0,1)=0⃗\lambda_1 (1, 1, 0) + \lambda_2 (0, 1, 1) + \lambda_3 (1, 0, 1) = \vec 0:

λ1+λ3=0,λ1+λ2=0,λ2+λ3=0 \lambda_1 + \lambda_3 = 0, \qquad \lambda_1 + \lambda_2 = 0, \qquad \lambda_2 + \lambda_3 = 0

Adding the three, 2(λ1+λ2+λ3)=02(\lambda_1 + \lambda_2 + \lambda_3) = 0; subtracting each equation from that gives λ1=λ2=λ3=0\lambda_1 = \lambda_2 = \lambda_3 = 0. Only the trivial one: independent. With three vectors of R3\mathbb{R}^3 there is a shortcut: the determinant of the matrix they form. If it is not 0, they are independent:

∣110011101∣=1+1+0−0−0−0=2≠0 \begin{vmatrix} 1 & 1 & 0 \\ 0 & 1 & 1 \\ 1 & 0 & 1 \end{vmatrix} = 1 + 1 + 0 – 0 – 0 – 0 = 2 \neq 0
Independent or dependentThree panels in perspective. Yellow and cyan: independent, they span a tilted plane. Red, green and yellow: dependent, all three lie on the floor b = 0 because yellow is red plus green. Yellow, cyan and magenta: independent, determinant 2, a basis of R³.rgbYC{Y, C}independentspan a planergbRGY{R, G, Y}dependentY = R + G: one is sparergbYCM{Y, C, M}independentdet = 2: basis of R³
If one vector can be mixed from the others, the set is dependent.

Three facts that save you calculations (and quiz questions):

  • A set containing 0⃗\vec 0 is always dependent: 1⋅0⃗=0⃗1 \cdot \vec 0 = \vec 0 with a non-zero scalar.
  • Two vectors are dependent if and only if one is a multiple of the other: (1,−2,6)(1, -2, 6) and (5,−10,30)(5, -10, 30) are.
  • A single non-zero vector is independent.

Yellow, cyan and magenta, without skipping anything

The calculation from above, with the reason for every step. The trick works because each λ \lambda appears in exactly two of the three equations:

StepCalculationWhy
1(λ1+λ3)+(λ1+λ2)+(λ2+λ3)=0 (\lambda_1 + \lambda_3) + (\lambda_1 + \lambda_2) + (\lambda_2 + \lambda_3) = 0 You add the three equations: the three right-hand sides are 0
22(λ1+λ2+λ3)=0 2(\lambda_1 + \lambda_2 + \lambda_3) = 0 , so λ1+λ2+λ3=0 \lambda_1 + \lambda_2 + \lambda_3 = 0 Each λ \lambda appears twice; you divide by 2
3λ2=0−0=0 \lambda_2 = 0 – 0 = 0 From the sum of the three you subtract the first, λ1+λ3=0 \lambda_1 + \lambda_3 = 0 : only λ2 \lambda_2 is left
4λ3=0 \lambda_3 = 0 You subtract the second, λ1+λ2=0 \lambda_1 + \lambda_2 = 0
5λ1=0 \lambda_1 = 0 You subtract the third, λ2+λ3=0 \lambda_2 + \lambda_3 = 0

The only way for the mix to give black is to switch everything off: none of the three is spare.

The determinant is the shortcut. Of the six products in Sarrus’ rule, with yellow, cyan and magenta as rows, the three that are added (the main diagonal and its two parallels) give 1, 1 and 0, and the three that are subtracted give 0 all three: each of them has a 0 in it. Total, 2. Why does a non-zero determinant mean independent? Because the homogeneous system above has that same matrix (transposed), and a square system with a non-zero determinant has a unique solution (topic 2): its only solution is the trivial one.

In the system the colours go in columns, and in the determinant I have put them in rows. It does not matter: a matrix and its transpose have the same determinant.

Check you’ve got it: are red, cyan and white independent?

No, they are dependent. The determinant with (1,0,0) (1, 0, 0) , (0,1,1) (0, 1, 1) and (1,1,1) (1, 1, 1) as rows is 0. Step by step, expanding along the first row, which only has one non-zero number: 1⋅(1⋅1−1⋅1)=0 1 \cdot (1 \cdot 1 – 1 \cdot 1) = 0 . And the reason with colours: white is red plus cyan, (1,0,0)+(0,1,1)=(1,1,1) (1, 0, 0) + (0, 1, 1) = (1, 1, 1) . Moving everything to one side, 1⋅(1,0,0)+1⋅(0,1,1)−1⋅(1,1,1)=0⃗ 1 \cdot (1, 0, 0) + 1 \cdot (0, 1, 1) – 1 \cdot (1, 1, 1) = \vec 0 , with λ=(1,1,−1) \lambda = (1, 1, -1) , which are not all 0.

The rank of a set of vectors

The rank of a set SS, rg(S)rg(S), is the largest number of linearly independent vectors in SS. It is computed as in topic 1: you write the vectors as rows (or columns) of a matrix, and rg(S)=rg(A)rg(S) = rg(A). For example, with yellow, cyan, magenta and white:

(110011101111)→f3→f3−f1(1100110−11111)→f4→f4−f1f3→f3+f2(110011002001)→f4→2f4−f3(110011002000) \begin{pmatrix} 1 & 1 & 0 \\ 0 & 1 & 1 \\ 1 & 0 & 1 \\ 1 & 1 & 1 \end{pmatrix} \xrightarrow{f_3 \to f_3 – f_1} \begin{pmatrix} 1 & 1 & 0 \\ 0 & 1 & 1 \\ 0 & -1 & 1 \\ 1 & 1 & 1 \end{pmatrix} \xrightarrow[f_4 \to f_4 – f_1]{f_3 \to f_3 + f_2} \begin{pmatrix} 1 & 1 & 0 \\ 0 & 1 & 1 \\ 0 & 0 & 2 \\ 0 & 0 & 1 \end{pmatrix} \xrightarrow{f_4 \to 2f_4 – f_3} \begin{pmatrix} 1 & 1 & 0 \\ 0 & 1 & 1 \\ 0 & 0 & 2 \\ 0 & 0 & 0 \end{pmatrix}

Three steps: rg(S)=3rg(S) = 3. There are four vectors but only three independent directions; white is spare, because (1,1,1)=12[(1,1,0)+(0,1,1)+(1,0,1)](1, 1, 1) = \tfrac12 \left[ (1, 1, 0) + (0, 1, 1) + (1, 0, 1) \right]. So: SS is independent if and only if rg(S)rg(S) equals the number of vectors.

Spanning sets

A set SS is a spanning set (or generating set) of VV if every vector of VV is a linear combination of those in SS. With colours: with those lights, can you get any colour?

Red, green and blue span R3\mathbb{R}^3, of course: (r,g,b)=r(1,0,0)+g(0,1,0)+b(0,0,1)(r, g, b) = r(1, 0, 0) + g(0, 1, 0) + b(0, 0, 1). Yellow, cyan and magenta also give any colour, even if it is not obvious. For any colour (r,g,b)(r, g, b), the system

λ1+λ3=r,λ1+λ2=g,λ2+λ3=b \lambda_1 + \lambda_3 = r, \qquad \lambda_1 + \lambda_2 = g, \qquad \lambda_2 + \lambda_3 = b

has determinant 2 (the one above), so it has a unique solution for any (r,g,b)(r, g, b): there is always a recipe, and only one. Yellow and cyan do not span R3\mathbb{R}^3: we saw that pure red cannot be made.

The rank decides again: SS spans Rn\mathbb{R}^n if and only if rg(S)=nrg(S) = n.

Basis and dimension

Before the names, five sets of lamps. For each one, two questions: is any lamp spare? and can you make any colour?

LampsAny spare?Any colour?Why
Red, green, blueNoYesEach one switches on a channel the others do not touch
Yellow, cyan, magentaNoYesThe determinant is 2: independent, and the system has a solution for any colour
Red, green, blue, whiteYesYesWhite is red plus green plus blue
Yellow, cyanNoNoPure red cannot be made (we saw it with linear combinations)
Red, green, yellowYesNoYellow is red plus green, and none of them gives blue

The two good sets, the ones with no extra lamp and no missing colour, have three lamps. With two, something is always missing; with four, one is always spare. It is not a coincidence: in R3 \mathbb{R}^3 there are exactly three independent directions, and any good set has to cover all three without repeating.

A set like that, with nothing extra and nothing missing, is called a basis, and its number of vectors is the dimension. That is what comes now, with the official names.

Check you’ve got it: are yellow, cyan and white a good set?

Yes, they are a basis of R3 \mathbb{R}^3 . Step by step: they are three vectors of R3 \mathbb{R}^3 , so it is enough to see that the determinant is not 0. With (1,1,0) (1, 1, 0) , (0,1,1) (0, 1, 1) and (1,1,1) (1, 1, 1) as rows, expanding along the first row: 1⋅(1⋅1−1⋅1)−1⋅(0⋅1−1⋅1)+0=0+1=1≠0 1 \cdot (1 \cdot 1 – 1 \cdot 1) – 1 \cdot (0 \cdot 1 – 1 \cdot 1) + 0 = 0 + 1 = 1 \neq 0 .

A basis of VV is a set BB of vectors that does both things at once:

  1. It is linearly independent (none is spare).
  2. It is a spanning set of VV (none is missing).

The standard basis of Rn\mathbb{R}^n is made of the vectors with a 1 and zeros elsewhere: with colours, {(1,0,0),(0,1,0),(0,0,1)}\{(1, 0, 0), (0, 1, 0), (0, 0, 1)\}, red, green and blue. But it is not the only one: yellow, cyan and magenta are also a basis of R3\mathbb{R}^3, because we have just seen they are independent and spanning. Red, green, blue and white span but are not a basis (one is spare); yellow and cyan are independent but are not a basis (one is missing).

What is the same in every basis of a space is the number of vectors. That number is the dimension, dim⁡V\dim V:

SpaceA basisDimension
R3\mathbb{R}^3 (colours)red, green, blue3
R4\mathbb{R}^4the 4 standard vectors4
M2×2M_{2 \times 2}the 4 matrices with a single 14
P2(x)P_2(x)1,x,x21, x, x^23

Knowing the dimension saves a lot of work. If dim⁡V=n\dim V = n and you have mm vectors:

  • If m>nm > n, they are certainly dependent (four colours can always be mixed from each other).
  • If m<nm < n, they cannot span VV (two colours never give them all).
  • If m=nm = n, you only need to check one of the two conditions: independent ⇔\Leftrightarrow spanning ⇔\Leftrightarrow basis. With nn vectors of Rn\mathbb{R}^n, that means a non-zero determinant.

Saying that two independent vectors of R3\mathbb{R}^3 are a basis of R3\mathbb{R}^3. They are independent, yes, but two vectors only span a plane. A basis of R3\mathbb{R}^3 has exactly 3 vectors: not one more, not one less.

Coordinates in a basis

You have already done this without a name. In spanning sets we saw that with yellow, cyan and magenta every colour has a recipe, and only one (the determinant was 2). That recipe, the list of how much of each lamp, is what we call the coordinates of the colour in that basis. Being unique matters: if the same colour had two recipes, “the coordinates of that colour” would mean nothing. That is why we only talk about coordinates in a basis: with a spanning set that has a spare vector, the same colour would have several recipes.

If B={e⃗1,…,e⃗n}B = \{\vec e_1, \dots, \vec e_n\} is a basis of VV, every vector u⃗\vec u can be written in exactly one way as u⃗=x1e⃗1+⋯+xne⃗n\vec u = x_1 \vec e_1 + \dots + x_n \vec e_n. The numbers x1,…,xnx_1, \dots, x_n are the coordinates of u⃗\vec u in BB. Uniqueness is exactly what independence gives you: if there were two recipes, subtracting them would give a zero combination with coefficients not all 0.

In the standard basis, the coordinates of the colour (3,5,4)(3, 5, 4) are 3,5,43, 5, 4: the components themselves. In the basis B′={Y,C,M}B' = \{Y, C, M\} of yellow, cyan and magenta they are different. You set up x1′(1,1,0)+x2′(0,1,1)+x3′(1,0,1)=(3,5,4)x'_1 (1, 1, 0) + x'_2 (0, 1, 1) + x'_3 (1, 0, 1) = (3, 5, 4):

x1′+x3′=3,x1′+x2′=5,x2′+x3′=4 x'_1 + x'_3 = 3, \qquad x'_1 + x'_2 = 5, \qquad x'_2 + x'_3 = 4

Adding the three equations, 2(x1′+x2′+x3′)=122(x'_1 + x'_2 + x'_3) = 12, so x1′+x2′+x3′=6x'_1 + x'_2 + x'_3 = 6. Subtracting each equation: x2′=6−3=3x'_2 = 6 – 3 = 3, x3′=6−5=1x'_3 = 6 – 5 = 1, x1′=6−4=2x'_1 = 6 – 4 = 2. The coordinates of (3,5,4)(3, 5, 4) in B′B' are (2,3,1)(2, 3, 1): two of yellow, three of cyan and one of magenta. Check: 2(1,1,0)+3(0,1,1)+(1,0,1)=(2+0+1,  2+3+0,  0+3+1)=(3,5,4)2(1, 1, 0) + 3(0, 1, 1) + (1, 0, 1) = (2 + 0 + 1, \; 2 + 3 + 0, \; 0 + 3 + 1) = (3, 5, 4).

One colour, two recipesThe colour (3,5,4) written in the standard basis, with coordinates 3, 5 and 4 of red, green and blue, and in the yellow, cyan and magenta basis, with coordinates 2, 3 and 1.(3, 5, 4)standard basis {R, G, B}base B' = {Y, C, M}3× R5× G4× B2× Y3× C1× Mcoordinates (3, 5, 4)coordinates (2, 3, 1)2·(1,1,0) + 3·(0,1,1) + 1·(1,0,1) = (3, 5, 4)
The vector is the same; the coordinates depend on the basis.

Same colour, two different lists of numbers. The coordinates are not the vector: they are the recipe in a particular basis, and they change if you change the basis.

Change of basis

Before the formula, think about what you do when you are given the recipe and asked for the colour. If the coordinates in B′={Y,C,M} B' = \{Y, C, M\} are (2,3,1) (2, 3, 1) , the colour is 2Y+3C+1M 2Y + 3C + 1M : each lamp times its number, and everything added up. Written component by component, that is exactly multiplying a matrix by the vector (2,3,1) (2, 3, 1) , if that matrix has Y Y , C C and M M as columns: when you multiply, the first column goes with the first number, the second with the second and the third with the third. That is why the basis vectors go in columns, not in rows.

That is what the general rule coming up says: column j j of the change-of-basis matrix is the recipe, in the target basis, of vector j j of the starting basis. When you see the inverse below, look at its first column: 12(1,−1,1) \tfrac12 (1, -1, 1) is the recipe for red with yellow, cyan and magenta. Check it: 12(1,1,0)−12(0,1,1)+12(1,0,1)=(1,0,0) \tfrac12 (1, 1, 0) – \tfrac12 (0, 1, 1) + \tfrac12 (1, 0, 1) = (1, 0, 0) .

Moving coordinates from one basis to another is multiplying by a matrix. If XX are the coordinates of u⃗\vec u in BB and X′X' in B′B', the change-of-basis matrix CB→B′C_{B \to B'} satisfies

CB→B′ X=X′ C_{B \to B'} \, X = X'

and each column of CB→B′C_{B \to B'} holds the coordinates of one vector of BB written in B′B'. In Rn\mathbb{R}^n, with BB the standard basis, three rules follow:

  1. From B′B' to the standard basis: CB′→BC_{B' \to B} has the vectors of B′B' as columns, as they are.
  2. From the standard basis to B′B': CB→B′=CB′→B−1C_{B \to B'} = C_{B' \to B}^{-1}, the inverse of the previous one.
  3. Between two non-standard bases B′B' and B′′B'': CB′→B′′=(columns of B′′)−1 (columns of B′)C_{B' \to B''} = (\text{columns of } B'')^{-1} \, (\text{columns of } B'). First you go from B′B' to the standard basis and then from the standard basis to B′′B''.

With colours, the matrix that takes B′={Y,C,M}B' = \{Y, C, M\} to the standard basis has yellow, cyan and magenta as columns:

CB′→B=(101110011),CB′→B(231)=(2+0+12+3+00+3+1)=(354) C_{B' \to B} = \begin{pmatrix} 1 & 0 & 1 \\ 1 & 1 & 0 \\ 0 & 1 & 1 \end{pmatrix}, \qquad C_{B' \to B} \begin{pmatrix} 2 \\ 3 \\ 1 \end{pmatrix} = \begin{pmatrix} 2 + 0 + 1 \\ 2 + 3 + 0 \\ 0 + 3 + 1 \end{pmatrix} = \begin{pmatrix} 3 \\ 5 \\ 4 \end{pmatrix}

And to go from the standard basis to B′B' without solving a system every time, the inverse (with the Gauss-Jordan method of topic 1):

CB→B′=CB′→B−1=12(11−1−1111−11),12(11−1−1111−11)(354)=12(462)=(231) C_{B \to B'} = C_{B' \to B}^{-1} = \frac12 \begin{pmatrix} 1 & 1 & -1 \\ -1 & 1 & 1 \\ 1 & -1 & 1 \end{pmatrix}, \qquad \frac12 \begin{pmatrix} 1 & 1 & -1 \\ -1 & 1 & 1 \\ 1 & -1 & 1 \end{pmatrix} \begin{pmatrix} 3 \\ 5 \\ 4 \end{pmatrix} = \frac12 \begin{pmatrix} 4 \\ 6 \\ 2 \end{pmatrix} = \begin{pmatrix} 2 \\ 3 \\ 1 \end{pmatrix}
The change-of-basis matrix and its inverseAt the top, the matrix with yellow, cyan and magenta as columns. On the left, the coordinates (2,3,1) in the yellow, cyan and magenta basis; on the right, (3,5,4) in the standard basis. A violet arrow goes left to right multiplying by that matrix; a coral one comes back with the inverse, one half times the matrix 1 1 −1, −1 1 1, 1 −1 1.C_B'→B: Y, C, M as columns101110011coordinates in B'X' = (2, 3, 1)Y, C, Mcoordinates in BX = (3, 5, 4)R, G, B× C_B'→B× C_B→B' = (C_B'→B)⁻¹(C_B'→B)⁻¹ = ½ · ( 1 1 −1 ; −1 1 1 ; 1 −1 1 )
There with the basis vectors as columns; back with the inverse.

Writing the basis vectors as rows of the change-of-basis matrix. They go as columns: column jj is vector jj of the starting basis written in the target one. If you put them as rows you have the transpose, and the coordinates come out wrong (except by coincidence).

Vector subspaces

Before the definition, keep only the colours with no blue, the ones with b=0 b = 0 . Inside that piece, can you do everything you did in the whole space without leaving it?

  • You mix two colours with no blue: the sum still has no blue, because 0+0=0 0 + 0 = 0 .
  • You turn up the intensity, or flip its sign: still no blue, because λ⋅0=0 \lambda \cdot 0 = 0 .
  • Black (0,0,0) (0, 0, 0) is inside, and it is the 0⃗ \vec 0 that rule 4 needs.

In other words, you never have to leave the piece to operate: the piece is a vector space in its own right, a smaller one (a plane). And the other seven rules, commutativity, associativity and the rest? Those already held for all colours, so they also hold for the colours in a piece. The only things that can go wrong when you keep just a piece are leaving it when you operate, or not having 0⃗ \vec 0 . That is why, in the definition coming up, three checks are enough. Before reading it, put them to the test:

Check you’ve got it: are the colours with r⋅g=0 r \cdot g = 0 (the ones with no red or no green) a subspace?

No. Step by step, with the three conditions: black is there, because 0⋅0=0 0 \cdot 0 = 0 . Multiplying by a number does not take you out either: (λr)(λg)=λ2 rg=0 (\lambda r)(\lambda g) = \lambda^2 \, r g = 0 . But the sum fails: red (1,0,0) (1, 0, 0) and green (0,1,0) (0, 1, 0) are both inside, and their sum, yellow (1,1,0) (1, 1, 0) , has 1⋅1=1≠0 1 \cdot 1 = 1 \neq 0 . Notice that the colours with no green are a subspace (a plane) and the colours with no red are another; what is not a subspace is putting them together.

A vector subspace of VV is a subset U⊆VU \subseteq V that, with the same operations, is a vector space itself. You do not need to check the ten rules: three are enough.

  1. 0⃗∈U\vec 0 \in U.
  2. If u⃗,v⃗∈U\vec u, \vec v \in U, then u⃗+v⃗∈U\vec u + \vec v \in U.
  3. If u⃗∈U\vec u \in U and λ∈R\lambda \in \mathbb{R}, then λu⃗∈U\lambda \vec u \in U.

Two collections of colours explain it better than the definition:

  • The greys, the colours with r=g=br = g = b. They contain black (0,0,0)(0, 0, 0); two greys added give a grey; a grey times a number is still grey. It is a subspace: the line from black to white, of dimension 1.
  • The colours with no blue, with b=0b = 0. They contain black, the sum of two colours with no blue has no blue and multiplying does not add any. It is another subspace: the plane of red-green mixes, of dimension 2.

Every space has two subspaces that add nothing, the trivial ones: VV itself and {0⃗}\{\vec 0\}, of dimension 0. And in R3\mathbb{R}^3 there are no other kinds: subspaces of dimension 1 are lines through the origin, and of dimension 2, planes through the origin.

Two subspaces of the coloursOn the left, the line of greys, through the origin and white. On the right, the plane b = 0 of colours with no blue, which contains red, green and yellow.rgbWgreys: r = g = bline through the origin · dim 1rgbno blue: b = 0plane through the origin · dim 2
The subspaces of R³ are lines and planes through the origin.

And what is not a subspace? The colours with r+g+b=1r + g + b = 1 are not, because black does not satisfy 0+0+0=10 + 0 + 0 = 1: the first condition fails. Nor are the colours a screen can really light up, with components between 0 and 255: yellow (1,1,0)(1, 1, 0) is there, but (−1)⋅(1,1,0)(-1) \cdot (1, 1, 0) is not. A line or a plane that does not pass through the origin is never a subspace.

To rule out a subspace, first check whether it contains 0⃗\vec 0. It is the fastest check and it knocks out almost every quiz example: any equation with a non-zero constant term, like x+y=1x + y = 1, leaves the origin out.

The subspace spanned by some vectors

Given S={u⃗1,…,u⃗m}S = \{\vec u_1, \dots, \vec u_m\}, the set of all its linear combinations is a subspace, the subspace spanned by SS:

U=L(S)={λ1u⃗1+⋯+λmu⃗m:λ1,…,λm∈R} U = L(S) = \{ \lambda_1 \vec u_1 + \dots + \lambda_m \vec u_m : \lambda_1, \dots, \lambda_m \in \mathbb{R} \}

It is everything you can get by mixing those vectors, and dim⁡L(S)=rg(S)\dim L(S) = rg(S). There are two methods to find a basis. You will need both, because they give different things. With S={(1,1,0),(1,0,1),(2,1,1),(0,1,−1)}S = \{(1, 1, 0),\allowbreak (1, 0, 1),\allowbreak (2, 1, 1),\allowbreak (0, 1, -1)\} (yellow, magenta and two mixes):

Method 1: vectors as rows and Gauss. Row operations mix vectors, so the non-zero rows of the echelon form still span the same thing:

(11010121101−1)→f3→f3−2f1f2→f2−f1(1100−110−1101−1)→f4→f4+f2f3→f3−f2(1100−11000000) \begin{pmatrix} 1 & 1 & 0 \\ 1 & 0 & 1 \\ 2 & 1 & 1 \\ 0 & 1 & -1 \end{pmatrix} \xrightarrow[f_3 \to f_3 – 2f_1]{f_2 \to f_2 – f_1} \begin{pmatrix} 1 & 1 & 0 \\ 0 & -1 & 1 \\ 0 & -1 & 1 \\ 0 & 1 & -1 \end{pmatrix} \xrightarrow[f_4 \to f_4 + f_2]{f_3 \to f_3 – f_2} \begin{pmatrix} 1 & 1 & 0 \\ 0 & -1 & 1 \\ 0 & 0 & 0 \\ 0 & 0 & 0 \end{pmatrix}

Basis: BU={(1,1,0),(0,−1,1)}B_U = \{(1, 1, 0), (0, -1, 1)\}, and dim⁡U=2\dim U = 2. It is a valid basis, but the second vector is no longer one of those in SS.

Method 2: vectors as columns and Gauss-Jordan. If the question asks for a basis made of vectors of SS (on the Campus: “with original vectors”), you put them as columns. Row operations do not change which columns are combinations of which, so the pivot columns point to the original vectors that form a basis:

(11201011011−1)⟶(1011011−10000) \begin{pmatrix} 1 & 1 & 2 & 0 \\ 1 & 0 & 1 & 1 \\ 0 & 1 & 1 & -1 \end{pmatrix} \longrightarrow \begin{pmatrix} 1 & 0 & 1 & 1 \\ 0 & 1 & 1 & -1 \\ 0 & 0 & 0 & 0 \end{pmatrix}

Pivots in columns 1 and 2, so the basis is the first and second vectors of SS: BU={(1,1,0),(1,0,1)}B_U = \{(1, 1, 0), (1, 0, 1)\}, yellow and magenta. And the reduced form also tells you how to write the others: column 3, (1,1,0)(1, 1, 0), means u⃗3=1⋅u⃗1+1⋅u⃗2\vec u_3 = 1 \cdot \vec u_1 + 1 \cdot \vec u_2, and column 4, (1,−1,0)(1, -1, 0), that u⃗4=u⃗1−u⃗2\vec u_4 = \vec u_1 – \vec u_2. Check: (1,1,0)−(1,0,1)=(0,1,−1)(1, 1, 0) – (1, 0, 1) = (0, 1, -1).

Two methods for a basis of L(S)On the left, the four vectors as rows in echelon form: two non-zero rows remain, (1,1,0) and (0,−1,1). On the right, the vectors as columns in reduced form, with pivots in columns 1 and 2, pointing to the original vectors u1 = (1,1,0) and u2 = (1,0,1).Method 1: as rows1100-11000000basis: (1,1,0), (0,−1,1)valid, but not the vectors of SMethod 2: as columns1011011-10000u₁u₂u₃u₄pivots in 1 and 2 → u₁, u₂ of Sbase: (1,1,0), (1,0,1)
With columns, the pivots choose original vectors; copy them from S, not from the reduced form.

Reading the pivots of the reduced form and giving the columns of the reduced form as the basis. The pivot columns tell you which positions to choose; the vectors you copy are those of the original matrix. It is the mistake that costs the most points in the MATLAB assignment, because rref shows you the reduced form and it is very tempting to copy it.

Parametric and implicit equations

A subspace can be described in three ways, and the exam asks you to go from one to another.

With a basis, as we have just seen: BU={(1,1,0),(1,0,1)}B_U = \{(1, 1, 0), (1, 0, 1)\}.

With parametric equations: you set a generic vector equal to the combination of the basis with parameters that take any real value.

(rgb)=α(110)+β(101)⟹U:  r=α+β,g=α,b=β,α,β∈R \begin{pmatrix} r \\ g \\ b \end{pmatrix} = \alpha \begin{pmatrix} 1 \\ 1 \\ 0 \end{pmatrix} + \beta \begin{pmatrix} 1 \\ 0 \\ 1 \end{pmatrix} \quad \Longrightarrow \quad U : \; r = \alpha + \beta, \quad g = \alpha, \quad b = \beta, \qquad \alpha, \beta \in \mathbb{R}

The number of (independent) parameters is the dimension: here, 2.

With implicit equations (or Cartesian equations): a homogeneous system satisfied by the coordinates of the vectors in UU and only by them. They are the conditions for belonging. Here, from g=αg = \alpha and b=βb = \beta you get r=g+br = g + b:

U:  r−g−b=0 U : \; r – g – b = 0

In words: the colours in UU have as much red as green and blue together. And the number of independent implicit equations is fixed:

no. of implicit equations=dim⁡V−dim⁡U \text{no. of implicit equations} = \dim V – \dim U

Here, 3−2=13 – 2 = 1. The greys, of dimension 1, need 3−1=23 – 1 = 2 equations: r−g=0r – g = 0 and g−b=0g – b = 0.

Three ways to describe a subspaceThree boxes: basis, parametric equations and implicit equations of the subspace r − g − b = 0. From basis to implicit, require the rank not to grow when (r, g, b) is added; from implicit to basis, solve the homogeneous system. Below: number of parameters equals the dimension and number of implicit equations equals dim V minus dim U.basis{(1,1,0), (1,0,1)}parametricr = α+β, g = α, b = βimplicitr − g − b = 0α, βeliminatesolve the homogeneous system (Gauss)rank of [basis; (r, g, b)] = dim Uno. of parameters = dim U no. of implicit equations = dim V − dim U
Basis, parametric and implicit: the same subspace in three portraits.

The two steps that come up in the exam:

From implicit equations to a basis. You solve the homogeneous system by Gaussian elimination (topic 2) and split by parameters. With the greys: r−g=0r – g = 0, g−b=0g – b = 0 gives b=αb = \alpha, g=αg = \alpha, r=αr = \alpha, that is, (r,g,b)=α(1,1,1)(r, g, b) = \alpha (1, 1, 1) and BU={(1,1,1)}B_U = \{(1, 1, 1)\}.

From a basis to implicit equations. A vector (r,g,b)(r, g, b) is in UU if and only if adding it to the basis does not raise the rank. You write the basis as rows, add a row (r,g,b)(r, g, b) and require the rank to stay dim⁡U\dim U:

rg(110101rgb)=2  ⟺  ∣110101rgb∣=0  ⟺  −g−b+r=0 rg \begin{pmatrix} 1 & 1 & 0 \\ 1 & 0 & 1 \\ r & g & b \end{pmatrix} = 2 \iff \begin{vmatrix} 1 & 1 & 0 \\ 1 & 0 & 1 \\ r & g & b \end{vmatrix} = 0 \iff -g – b + r = 0

Expanded along the third row: r(1⋅1−0⋅0)−g(1⋅1−0⋅1)+b(1⋅0−1⋅1)=r−g−br(1 \cdot 1 – 0 \cdot 0) – g(1 \cdot 1 – 0 \cdot 1) + b(1 \cdot 0 – 1 \cdot 1) = r – g – b. The same equation. When the matrix is not square (for example, two vectors in R4\mathbb{R}^4), you row-reduce with x,y,z,tx, y, z, t inside the last row and require the positions left without a pivot to be 0: each one is an implicit equation. We will do it in the practice.

Always check your implicit equations with the basis vectors: every basis vector must satisfy every equation. With (1,1,0)(1, 1, 0): 1−1−0=01 – 1 – 0 = 0; with (1,0,1)(1, 0, 1): 1−0−1=01 – 0 – 1 = 0. If one fails, there is a sign error.

Sum and intersection of subspaces

First in your head, with the two planes of colours you are about to use: U1 U_1 , the colours with no blue (b=0 b = 0 ), and U2 U_2 , the ones with as much red as green (r=g r = g ).

The first thing anyone thinks of to “put them together” is to keep the colours that are in one or the other. But that is not a subspace: red (1,0,0) (1, 0, 0) is in U1 U_1 , blue (0,0,1) (0, 0, 1) is in U2 U_2 (it has r=g=0 r = g = 0 ), and their sum, magenta (1,0,1) (1, 0, 1) , is in neither (it has blue, and it has red but no green). When you put two subspaces together like that, adding takes you outside.

What does work is keeping everything you can get by adding one colour from each: that is the sum. And what they have in common, the colours with no blue and with r=g r = g , is the intersection: the yellows (α,α,0) (\alpha, \alpha, 0) .

Confusing the sum of subspaces with the union. The union of two subspaces is almost never a subspace (only when one is inside the other); the sum is the smallest subspace that contains both.

Check you’ve got it: can two planes of R3 \mathbb{R}^3 through the origin meet only at the origin?

No, never. Step by step: you put the two bases together and you have four vectors in R3 \mathbb{R}^3 , so the sum has dimension at most 3. With the Grassmann formula, a few lines below, 2+2=dim⁡(U1+U2)+dim⁡(U1∩U2) 2 + 2 = \dim(U_1 + U_2) + \dim(U_1 \cap U_2) , and if dim⁡(U1+U2)≤3 \dim(U_1 + U_2) \le 3 , then dim⁡(U1∩U2)≥1 \dim(U_1 \cap U_2) \ge 1 : they share at least a line. With the colours, U1 U_1 and U2 U_2 share the line of the yellows.

With two subspaces U1U_1 and U2U_2 of VV you can build two more:

  • The sum U1+U2U_1 + U_2: all vectors of the form u⃗1+u⃗2\vec u_1 + \vec u_2 with u⃗1∈U1\vec u_1 \in U_1 and u⃗2∈U2\vec u_2 \in U_2. A spanning set comes from putting both bases together; a basis, from row-reducing and removing the spare ones.
  • The intersection U1∩U2U_1 \cap U_2: the vectors that are in both. A basis comes from putting the implicit equations of both together and solving the system.

With colours: U1U_1 = colours with no blue (b=0b = 0, basis {(1,0,0),(0,1,0)}\{(1, 0, 0), (0, 1, 0)\}) and U2U_2 = colours with as much red as green (r−g=0r – g = 0, basis {(1,1,0),(0,0,1)}\{(1, 1, 0), (0, 0, 1)\}).

Sum. The four rows (1,0,0),(0,1,0),(1,1,0),(0,0,1)(1, 0, 0),\allowbreak (0, 1, 0),\allowbreak (1, 1, 0),\allowbreak (0, 0, 1) have rank 3 (the third is the sum of the first two), so dim⁡(U1+U2)=3\dim (U_1 + U_2) = 3 and U1+U2=R3U_1 + U_2 = \mathbb{R}^3: adding a colour with no blue and one with r=gr = g you reach any colour. As it is the whole space, it has no implicit equations.

Intersection. You put together b=0b = 0 and r−g=0r – g = 0: r=g=αr = g = \alpha, b=0b = 0. U1∩U2=L{(1,1,0)}U_1 \cap U_2 = L\{(1, 1, 0)\}, the yellows, of dimension 1.

And the four dimensions are tied by the Grassmann formula:

dim⁡U1+dim⁡U2=dim⁡(U1+U2)+dim⁡(U1∩U2) \dim U_1 + \dim U_2 = \dim (U_1 + U_2) + \dim (U_1 \cap U_2)

Here 2+2=3+12 + 2 = 3 + 1. The intuition: when you merge the two bases, what they have in common is counted twice, and the intersection is exactly what is spare.

Grassmann formula with two planesTwo overlapping ovals: U1, the colours with no blue, dimension 2, and U2, the colours with red equal to green, dimension 2. The overlap is the intersection, the yellows L{(1,1,0)}, dimension 1. The sum is R³, dimension 3, and the formula 2 + 2 = 3 + 1.U₁: b = 0dim 2no blueU₂: r = gdim 2red = greenU₁ ∩ U₂L{(1,1,0)}dim 1dim U₁ + dim U₂ = dim(U₁ + U₂) + dim(U₁ ∩ U₂)2 + 2 = 3 + 1U₁ + U₂ = R³ (dim 3)
What the two share gets counted twice when you merge the bases.

Computing the dimension of the sum by adding the dimensions. dim⁡U1+dim⁡U2\dim U_1 + \dim U_2 is only dim⁡(U1+U2)\dim(U_1 + U_2) when the intersection is {0⃗}\{\vec 0\}. With the two planes above, 2+2=42 + 2 = 4 would be impossible in R3\mathbb{R}^3.

Direct sum and complementary subspaces

When U1∩U2={0⃗}U_1 \cap U_2 = \{\vec 0\}, the sum is called a direct sum and is written U1⊕U2U_1 \oplus U_2: each vector of the sum splits in exactly one way. And if, moreover, U1⊕U2=VU_1 \oplus U_2 = V, the subspaces are complementary (supplementary). The exam asks you to justify it: you have to check both things, U1+U2=VU_1 + U_2 = V and U1∩U2={0⃗}U_1 \cap U_2 = \{\vec 0\} (or, with Grassmann, one of them and that the dimensions add up to dim⁡V\dim V).

Here is the grey from the title. The colours with no blue (b=0b = 0, dimension 2) and the greys (r=g=br = g = b, dimension 1) only meet at black: a grey with no blue has b=0b = 0 and therefore r=g=0r = g = 0. The dimensions add up to 2+1=32 + 1 = 3, so they are complementary: every colour splits in exactly one way into a grey plus a colour with no blue. With (3,5,4)(3, 5, 4), the grey has to take all the blue, (4,4,4)(4, 4, 4), and what is left is

(3,5,4)=(4,4,4)+(−1,1,0) (3, 5, 4) = (4, 4, 4) + (-1, 1, 0)

The first term is the grey and the second, the colour with no blue, and there is no other way to split it.

A colour split into grey plus a colour with no blueThe plane b = 0 in coral and the line of greys in grey. The arrow to (3,5,4) splits into the grey arrow to (4,4,4) and a coral arrow (−1,1,0), parallel to the no-blue plane.rgb(4,4,4) grey(3,5,4)(−1,1,0)R³ = U₁ ⊕ U_greyU₁ ∩ U_grey = {0}2 + 1 = 3(3,5,4) = (4,4,4)+ (−1,1,0)
Complementary subspaces: every vector splits in exactly one way.

Just for the curious. This is not how a photo editor removes grey (it works in the 0-255 range and with other colour models), but the idea of splitting a vector into two pieces from complementary subspaces is the same one you will use in topic 4, when the “leftover” piece is perpendicular, and in topic 5, when the pieces are eigen-directions.

The same in MATLAB

Everything today is ranks, systems and matrices, so MATLAB does it with the commands of topics 1 and 2:

Y = [1 1 0]; C = [0 1 1]; M = [1 0 1]; W = [1 1 1];
rank([Y; C; M])          % 3: independent, and with three in R^3, a basis
rank([Y; C; M; W])       % still 3: white is spare
P = [Y' C' M']           % change from B' to the standard basis: vectors as columns

Output:

ans =

     3

ans =

     3

P =

     1     0     1
     1     1     0
     0     1     1

[Y; C; M] stacks the colours as rows; Y' is the transpose, yellow as a column. Now the coordinates of (3,5,4)(3, 5, 4) in B′B' and the matrix that goes from the standard basis to B′B':

format rat
coord = P \ [3; 5; 4]    % solves P * X' = X: the coordinates in B'
inv(P)                   % change from the standard basis to B'

Output:

coord =

       2       
       3       
       1       

ans =

       1/2            1/2           -1/2     
      -1/2            1/2            1/2     
       1/2           -1/2            1/2     

They match the ones on paper: (2,3,1)(2, 3, 1) and the inverse with the halves. And the two methods for the basis of L(S)L(S), plus implicit equations turned into a basis:

S = [1 1 0; 1 0 1; 2 1 1; 0 1 -1];   % the four vectors, as rows
rank(S)                              % dim L(S)
[R, piv] = rref(S')                  % as columns: piv says which original vectors form a basis
null([1 -1 -1], 'r')                 % basis of the subspace r - g - b = 0

Output:

ans =

       2       

R =

       1              0              1              1       
       0              1              1             -1       
       0              0              0              0       

piv =

       1              2       

ans =

       1              1       
       1              0       
       0              1       

piv is 1 2: vectors 1 and 2 of SS, yellow and magenta, as in method 2. And null(A, 'r') solves the homogeneous system AX=0A X = 0 and returns a basis of the subspace as columns, with “nice” numbers thanks to the 'r': yellow and magenta again. Note that null gives the basis as columns (in the assignment quiz you must write it correctly).

Try it in the MATLAB playground

In the website’s MATLAB playground you can play with the colours:

% Is it a basis of R^3? What coordinates does a colour have in it?
B1 = [1 1 0]; B2 = [0 1 1]; B3 = [1 0 1];   % yellow, cyan, magenta
P = [B1' B2' B3'];
if rank(P) == 3
    disp('It is a basis of R^3')
    format rat
    coordinates = P \ [3; 5; 4]
else
    disp('Not a basis')
end

Things to look at:

  • Swap magenta for white, B3 = [1 1 1], and check it is still a basis. With B3 = [1 2 1] (yellow plus cyan), it no longer is.
  • Change [3; 5; 4] to the grey [2; 2; 2]: the coordinates come out equal, (1,1,1)(1, 1, 1). Why?
  • Try null([0 0 1; 1 -1 0], 'r'): it is the intersection of “no blue” and “red equals green”, the yellows.
  • If you want to see each row operation with fractions, put the matrix of the four vectors into the Gauss-Jordan step-by-step simulator: it gives you the rank and marks the pivots.

Summary

ConceptWhat it isHow to compute it
Linear combinationλ1u⃗1+⋯+λmu⃗m\lambda_1 \vec u_1 + \dots + \lambda_m \vec u_mDoes it exist? Consistent system
Linearly independentOnly the trivial combination gives 0⃗\vec 0rg(S)rg(S) = no. of vectors
Spanning set of Rn\mathbb{R}^nEvery vector is a combination of themrg(S)=nrg(S) = n
BasisIndependent and spanningnn vectors with rg=nrg = n (or ∣A∣≠0\lvert A \rvert \neq 0)
DimensionNo. of vectors in any basisdim⁡L(S)=rg(S)\dim L(S) = rg(S)
CoordinatesThe recipe of the vector in a basisSolve a system, or CB→B′X=X′C_{B \to B'} X = X'
SubspaceContains 0⃗\vec 0, closed under addition and productThe three conditions
Implicit equationsConditions for belongingno. =dim⁡V−dim⁡U= \dim V – \dim U
SumU1+U2U_1 + U_2Merge bases and row-reduce
IntersectionU1∩U2U_1 \cap U_2Merge implicit equations and solve
Grassmanndim⁡U1+dim⁡U2=dim⁡(U1+U2)+dim⁡(U1∩U2)\dim U_1 + \dim U_2 = \dim(U_1 + U_2) + \dim(U_1 \cap U_2)Check both results

Three ideas to take away:

  • Almost everything is the rank: independence, spanning, basis, dimension and membership are decided by row-reducing a matrix with the vectors.
  • A subspace has three portraits (basis, parametric and implicit equations), and you go from one to another by solving a system or requiring the rank not to grow.
  • The sum is done with bases and the intersection with equations; Grassmann checks that both calculations agree.

Now it is your turn: in the vector spaces guided practice we solve five problems step by step, checked in MATLAB: independence with a parameter, a change between two non-standard bases, the basis with original vectors, the implicit equations of a subspace of R4\mathbb{R}^4 and the whole subspaces exercise from the exam. And to check you have got it, the vector spaces exercises go from easy to hard and come with commented solutions and a quiz like the Campus ones. Next comes topic 4, the Euclidean space, where these vectors get a rule to measure lengths and angles.

Next step: practiceVector spaces — guided practice with colours: independence, change of basis, original vectors and the exam’s subspaces exercise (and the basis that did not come out of rref)

Did this article help you? Here is how you can support SergioLearns →