Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

5.3: Subspaces, bases, dimension, and rank

As we’ve seen in Chapter 5.1 and Chapter 5.2, the outputs of a matrix AA form a set of vectors called its column space, colsp⁡(A)\operatorname{colsp}(A).

We’ve seen that the column space of a matrix with 2 rows might be a line or all of R2\mathbb R^2, and that the column space of a matrix with 3 rows might be a line, a plane, or all of R3\mathbb R^3. But how do we describe the column space of a matrix with more than 3 rows?


Subspaces

Lines and planes are both “flat” objects that extend infinitely, without edges, in their directions. A line, whether it is in R2\mathbb R^2, R3\mathbb R^3, or R17\mathbb R^{17} for that matter, is 1-dimensional in some sense and can be thought of as a “slice” of space. Similarly, a plane in R3\mathbb R^3 is a 2-dimensional “slice.”

The general notion of a “flat slice” through the origin is more precisely referred to as a subspace.

Imagine a subspace as a gated community of vectors, where linear combinations cannot escape the community. These conditions must hold for every vector in the set and every real scalar. One counterexample is enough to show that a set is not a subspace.

<IPython.core.display.Image object>

Examples and non-examples

Below, we’ve shown 4 examples of subsets of R2\mathbb R^2 in blue. Orange vectors belong to the set, while pink vectors (for the sets that are not subspaces) show a violation of one of the subspace properties. The pink cross marks the missing zero vector.

<IPython.core.display.Image object>
  • The line y=2xy=2x is a subspace. Its vectors have the form [a2a]\begin{bmatrix}a\\2a\end{bmatrix}. It contains 0⃗\vec0, and

    [a2a]+[b2b]=[a+b2(a+b)],c[a2a]=[ca2ca]\begin{bmatrix}a\\2a\end{bmatrix}+\begin{bmatrix}b\\2b\end{bmatrix}=\begin{bmatrix}a+b\\2(a+b)\end{bmatrix},\qquad c\begin{bmatrix}a\\2a\end{bmatrix}=\begin{bmatrix}ca\\2ca\end{bmatrix}

    are still on the line.

  • The first quadrant, where x≥0x\ge0 and y≥0y\ge0, is not a subspace. It contains [23]\begin{bmatrix}2\\3\end{bmatrix} but not −[23]=[−2−3]-\begin{bmatrix}2\\3\end{bmatrix}=\begin{bmatrix}-2\\-3\end{bmatrix}. It fails closure under scalar multiplication.

  • The line y=3x−4y=3x-4 is not a subspace. It misses the origin: 0≠3(0)−40\ne3(0)-4. It is an affine subspace—a shifted subspace. Being flat is not enough.

  • The parabola y=x2y=x^2, written in set-builder notation as

    S={[xy]∈R2:y=x2},S=\left\{\begin{bmatrix}x\\y\end{bmatrix}\in\mathbb R^2:y=x^2\right\},

    is not a subspace. It contains [11]\begin{bmatrix}1\\1\end{bmatrix}, but doubling this vector gives [22]\begin{bmatrix}2\\2\end{bmatrix}, which is not on the parabola. This fails closure under both scalar multiplication and addition. Passing through the origin is not enough either.

The possible subspaces in R2\mathbb R^2 and R3\mathbb R^3 are:

SpaceAll possible types of subspaces
R2\mathbb R^2{0⃗}\{\vec0\}, lines through the origin, all of R2\mathbb R^2
R3\mathbb R^3{0⃗}\{\vec0\}, lines through the origin, planes through the origin, all of R3\mathbb R^3

Spans and column spaces

Subspaces generalize lines and planes through the origin, which we already know how to describe as spans of one or two vectors. Here’s the key connection: Every span of vectors in Rn\mathbb R^n is a subspace of Rn\mathbb R^n. In particular, colsp⁡(A)\operatorname{colsp}(A) for an n×dn\times d matrix AA is a subspace of Rn\mathbb R^n.

For example, revisit the matrices from Chapter 5.1:

  • For A=[101101]A=\begin{bmatrix}1&0\\1&1\\0&1\end{bmatrix}, colsp⁡(A)\operatorname{colsp}(A) is a subspace of R3\mathbb R^3: the plane x−y+z=0x-y+z=0.

  • Adding the redundant column in BB leaves that plane unchanged, so colsp⁡(B)\operatorname{colsp}(B) is the same subspace.

  • The three independent columns of CC span all of R3\mathbb R^3, which is itself a subspace of R3\mathbb R^3.


Bases

Consider the 4×34\times3 matrix

A=[∣∣∣a⃗1a⃗2a⃗3∣∣∣]=[1012−1501−3−13−10].A=\begin{bmatrix}|&|&|\\\vec a_1&\vec a_2&\vec a_3\\|&|&|\end{bmatrix} =\begin{bmatrix}1&0&1\\2&-1&5\\0&1&-3\\-1&3&-10\end{bmatrix}.

Its column space is a subspace of R4\mathbb R^4, since its columns have four entries. But we don’t need all three columns to describe colsp⁡(A)\operatorname{colsp}(A), because its third column is redundant:

a⃗3=a⃗1−3a⃗2.\vec a_3=\vec a_1-3\vec a_2.

Removing a⃗3\vec a_3 leaves the column space unchanged. Indeed,

A[pqr]=(p+r)a⃗1+(q−3r)a⃗2,A\begin{bmatrix}p\\q\\r\end{bmatrix}=(p+r)\vec a_1+(q-3r)\vec a_2,

and every combination of a⃗1,a⃗2\vec a_1,\vec a_2 is an output by choosing r=0r=0. These two columns span the column space and are independent, since neither is a scalar multiple of the other.

We say {a⃗1,a⃗2}\{\vec a_1,\vec a_2\} form a basis for colsp⁡(A)\operatorname{colsp}(A).

The plural of basis is bases. Every nonzero subspace has infinitely many bases. Here are some examples and non-examples of bases for colsp⁡(A)\operatorname{colsp}(A), where

A=[1012−1501−3−13−10].A=\begin{bmatrix}1&0&1\\2&-1&5\\0&1&-3\\-1&3&-10\end{bmatrix}.
CollectionIs it a basis of colsp⁡(A)\operatorname{colsp}(A)?
{a⃗1}\{\vec a_1\}No: independent, but spans only a line.
{a⃗1,a⃗2}\{\vec a_1,\vec a_2\}Yes: independent and spans the whole column space.
{a⃗1,7a⃗1}\{\vec a_1,7\vec a_1\}No: dependent and spans only a line.
{a⃗2,a⃗3}\{\vec a_2,\vec a_3\}Yes: independent, and a⃗1=a⃗3+3a⃗2\vec a_1=\vec a_3+3\vec a_2 recovers the remaining column.
{a⃗1,a⃗2,a⃗3}\{\vec a_1,\vec a_2,\vec a_3\}No: spans the column space, but is dependent.
{a⃗1,a⃗1+a⃗2}\{\vec a_1,\vec a_1+\vec a_2\}Yes: independent, and subtracting its first vector from its second recovers a⃗2\vec a_2.

The last collection shows that a basis need not use the original matrix’s columns.


Dimension

Different bases of a subspace can use different vectors, but they always contain the same number of vectors.

For our 4×34\times3 matrix

A=[1012−1501−3−13−10],A=\begin{bmatrix}1&0&1\\2&-1&5\\0&1&-3\\-1&3&-10\end{bmatrix},

the basis {a⃗1,a⃗2}\{\vec a_1,\vec a_2\} contains two vectors. Thus dim⁡(colsp⁡(A))=2\dim(\operatorname{colsp}(A))=2: its column space is a plane through the origin in R4\mathbb R^4.

These are three different counts: 4 rows tell us that outputs have four entries; 3 columns tell us that inputs have three entries; dimension 2 tells us how many vectors a basis contains.

A line has dimension 1, regardless of how many entries its vectors have. For example,

{t[2−1031]:t∈R}\left\{t\begin{bmatrix}2\\-1\\0\\3\\1\end{bmatrix}:t\in\mathbb R\right\}

is a line in R5\mathbb R^5, with the displayed nonzero vector as a basis.

The columns of InI_n form the standard basis of Rn\mathbb R^n: they are independent, and any vector is their linear combination with its entries as coefficients. Hence dim⁡(Rn)=n\dim(\mathbb R^n)=n. By convention, the empty collection is a basis of {0⃗}\{\vec0\}, which has dimension zero.

For example, 3 linearly independent vectors in R3\mathbb R^3 must form a basis of R3\mathbb R^3 and span all of R3\mathbb R^3. Since R3\mathbb R^3 has dimension 3, an independent collection of 3 vectors already has as many vectors as a basis; it cannot span a smaller subspace.

Example: A basis from equations

Consider the set

S={[x1x2x3x4]∈R4:x1+x2=0, x3=2x4}.S=\left\{\begin{bmatrix}x_1\\x_2\\x_3\\x_4\end{bmatrix}\in\mathbb R^4:x_1+x_2=0,\ x_3=2x_4\right\}.

What does this set look like? The equations force x2=−x1x_2=-x_1 and x3=2x4x_3=2x_4. Choose x1=sx_1=s and x4=tx_4=t. Then

[x1x2x3x4]=[s−s2tt]=s[1−100]+t[0021].\begin{bmatrix}x_1\\x_2\\x_3\\x_4\end{bmatrix} =\begin{bmatrix}s\\-s\\2t\\t\end{bmatrix} =s\begin{bmatrix}1\\-1\\0\\0\end{bmatrix}+t\begin{bmatrix}0\\0\\2\\1\end{bmatrix}.

Every vector in SS has this form, and every choice of s,ts,t satisfies both equations. Thus SS is the span of the two displayed vectors, so it is a subspace. Neither vector is a scalar multiple of the other, so they form a basis. Therefore dim⁡(S)=2\dim(S)=2: it is a plane through the origin in R4\mathbb R^4.


Rank and solvability

Equivalently, rank is the maximum number of linearly independent columns. Our 4×34\times3 matrix AA has rank 2.

Here are several examples of matrices and their ranks; we have already seen many of these matrices in this chapter.

MatrixRankExplanation
[1012−1501−3−13−10]\begin{bmatrix}1&0&1\\2&-1&5\\0&1&-3\\-1&3&-10\end{bmatrix}2The first two columns are independent; the third is the first minus three times the second.
[101101]\begin{bmatrix}1&0\\1&1\\0&1\end{bmatrix}2Its two columns are independent.
[10211101−1]\begin{bmatrix}1&0&2\\1&1&1\\0&1&-1\end{bmatrix}2The third column is twice the first minus the second; the first two are independent.
[102114013]\begin{bmatrix}1&0&2\\1&1&4\\0&1&3\end{bmatrix}3The first two columns span x−y+z=0x-y+z=0; the third lies outside that plane.
[102011400131]\begin{bmatrix}1&0&2&0\\1&1&4&0\\0&1&3&1\end{bmatrix}3Its first three columns already span R3\mathbb R^3; the fourth cannot enlarge that span.
[0200−300000040050]\begin{bmatrix}0&2&0&0\\-3&0&0&0\\0&0&0&4\\0&0&5&0\end{bmatrix}4Its columns point along four different coordinate directions.
[20100−34000000005]\begin{bmatrix}2&0&1&0\\0&-3&4&0\\0&0&0&0\\0&0&0&5\end{bmatrix}3Columns 1, 2, and 4 are independent; column 3 is a combination of columns 1 and 2.
[2−4−12003−61−2]\begin{bmatrix}2&-4\\-1&2\\0&0\\3&-6\\1&-2\end{bmatrix}1The first column is nonzero and the second is -2 times the first.

As a thought experiment, consider a 7×107\times10 matrix. Its smallest possible rank is 0, achieved by the zero matrix. The largest is 7: its column space is a subspace of R7\mathbb R^7, so it cannot have dimension larger than 7.

More generally, a basis chosen from the columns of an n×dn\times d matrix cannot contain more than dd vectors, and a subspace of Rn\mathbb R^n cannot have dimension larger than nn. Therefore,

0≤rank⁡(A)≤min⁡(n,d).\boxed{0\leq\operatorname{rank}(A)\leq\min(n,d).}

Invertibility

An n×nn\times n matrix is invertible exactly when its nn columns are independent, or equivalently, when its rank is nn. Those columns then form a basis of Rn\mathbb R^n.

Solvability

The equation Ax⃗=b⃗A\vec x=\vec b has a solution exactly when b⃗∈colsp⁡(A)\vec b\in\operatorname{colsp}(A). If we want a solution for every b⃗∈Rn\vec b\in\mathbb R^n, the column space must be all of Rn\mathbb R^n:

Ax⃗=b⃗ is solvable for every b⃗∈Rn⟺rank⁡(A)=n.\boxed{A\vec x=\vec b\text{ is solvable for every }\vec b\in\mathbb R^n \quad\Longleftrightarrow\quad\operatorname{rank}(A)=n.}

We compare rank to the number of rows when asking whether every output is possible. A rectangular matrix can produce every output without being invertible: for example, [100010]\begin{bmatrix}1&0&0\\0&1&0\end{bmatrix} has rank 2, but its third input entry can be anything.

As another example, consider

F=[101−101131122].F=\begin{bmatrix}1&0&1&-1\\0&1&1&3\\1&1&2&2\end{bmatrix}.

The first two columns are independent. The third is their sum, and the fourth is three times the second minus the first. Thus the first two columns form a basis of colsp⁡(F)\operatorname{colsp}(F), and rank⁡(F)=2\operatorname{rank}(F)=2.

A general combination of the basis vectors is

s[101]+t[011]=[sts+t].s\begin{bmatrix}1\\0\\1\end{bmatrix}+t\begin{bmatrix}0\\1\\1\end{bmatrix}=\begin{bmatrix}s\\t\\s+t\end{bmatrix}.

So colsp⁡(F)\operatorname{colsp}(F) is the plane z=x+yz=x+y. This tells us exactly which outputs are possible. For instance,

F[2300]=F[1210]=[235],F\begin{bmatrix}2\\3\\0\\0\end{bmatrix} =F\begin{bmatrix}1\\2\\1\\0\end{bmatrix} =\begin{bmatrix}2\\3\\5\end{bmatrix},

but [236]\begin{bmatrix}2\\3\\6\end{bmatrix} is impossible. The columns are dependent, so every possible output has infinitely many inputs. Rank 2 describes the dimension of the output set; the plane equation tells us whether a particular vector belongs to it.