Skip to main content

MATH 345: Linear Algebra and Optimization

Section 2.4 Independence, bases, and dimension

Subsection Linear independence

Activity 2.4.1. Comparing two spanning sets (U2-LO4).

In ActivityΒ 2.3.11 we showed that the set
\begin{equation*} W = \left\{ \begin{bmatrix} r \\ s \\ r + 2s \end{bmatrix} : r,s \in \R \right\} \end{equation*}
is a subspace. In ActivityΒ 2.3.21, we showed that the set
\begin{equation*} S = \left\{ \begin{bmatrix} 1 \\ 0 \\ 1 \end{bmatrix}, \begin{bmatrix} 0 \\ 1 \\ 2 \end{bmatrix} \right\} \end{equation*}
is a spanning set for \(W\text{.}\) The set
\begin{equation*} T = \left\{ \begin{bmatrix} 1 \\ 0 \\ 1 \end{bmatrix}, \begin{bmatrix} 2 \\ 0 \\ 2 \end{bmatrix}, \begin{bmatrix} 0 \\ 1 \\ 2 \end{bmatrix}, \begin{bmatrix} 1 \\ 1 \\ 3 \end{bmatrix} \right\} \end{equation*}
also spans \(W\text{.}\) But why is \(S\) β€˜better’?
Solution.
It uses fewer vectors to span the same space. Which vectors in \(T\) are redundant?
\begin{equation*} \begin{bmatrix} 2 \\ 0 \\ 2 \end{bmatrix} = 2\begin{bmatrix} 1 \\ 0 \\ 1 \end{bmatrix}, \qquad \begin{bmatrix} 1 \\ 1 \\ 3 \end{bmatrix} = \begin{bmatrix} 1 \\ 0 \\ 1 \end{bmatrix} + \begin{bmatrix} 0 \\ 1 \\ 2 \end{bmatrix}. \end{equation*}
So \(T\) spans \(W\text{,}\) but it contains repeated information.
For example, the sum of the first three vectors listed in \(T\) can be rewritten as
\begin{equation*} \begin{bmatrix} 1 \\ 0 \\ 1 \end{bmatrix} + \begin{bmatrix} 2 \\ 0 \\ 2 \end{bmatrix} + \begin{bmatrix} 0 \\ 1 \\ 2 \end{bmatrix} = 3\begin{bmatrix} 1 \\ 0 \\ 1 \end{bmatrix} + \begin{bmatrix} 0 \\ 1 \\ 2 \end{bmatrix}. \end{equation*}
The right-hand side is a linear combination of the two vectors in \(S\text{.}\)
A subspace \(U\) has many different spanning sets. We use the concept of linear independence to determine when sets of spanning vectors are the β€˜most efficient’. In data terms, independence asks whether one feature direction is already built from the others.

Definition 2.4.2. Linear Independence.

A set of vectors \(\{ \mathbf{x}_1, \dots, \mathbf{x}_k \}\) in \(\R^n\) is said to be linearly independent, or simply independent if the only solution to the equation \(t_1 \mathbf{x}_1 + \dots + t_k \mathbf{x}_k = \mathbf{0}\) is trivial, i.e., \(t_1 = \cdots = t_k = 0\text{.}\)
A set of vectors \(\{ \mathbf{x}_1, \dots, \mathbf{x}_k \}\) in \(\R^n\) is linearly dependent if it is not linearly independent, i.e., if there exists scalars \(t_1,\dots,t_k\text{,}\) not all zero, such that \(t_1 \mathbf{x}_1 + \cdots + t_k \mathbf{x}_k = \mathbf{0}\text{.}\)

Remark 2.4.3. An independent list cannot contain the zero vector.

Any list containing \(\mathbf{0}\) is linearly dependent. Give the zero vector coefficient \(1\) and every other vector coefficient \(0\text{:}\)
\begin{equation*} 1\cdot\mathbf{0}+0\mathbf{x}_2+\cdots+0\mathbf{x}_k=\mathbf{0}. \end{equation*}
This linear combination equals the zero vector, but its coefficients are not all zero.

Activity 2.4.4. Dependence of two vectors (U2-LO4).

Let \(\mathbf{u}\) and \(\mathbf{v}\) be two nonzero vectors in \(\R^n\text{.}\) Explain why \(\{\mathbf{u},\mathbf{v}\}\) is linearly dependent if and only if \(\mathbf{u}\) and \(\mathbf{v}\) are parallel, i.e., one vector is a scalar multiple of the other.
Solution.
If the vectors are parallel, say \(\mathbf{v}=c\mathbf{u}\text{,}\) then
\begin{equation*} c\mathbf{u}-\mathbf{v}=\mathbf{0}. \end{equation*}
The coefficients \(c\) and \(-1\) are not both zero, so the vectors are linearly dependent.
Conversely, suppose the vectors are linearly dependent. Then
\begin{equation*} s\mathbf{u}+t\mathbf{v}=\mathbf{0} \end{equation*}
for scalars \(s\) and \(t\) that are not both zero. We must have \(t\ne 0\text{:}\) otherwise \(s\mathbf{u}=\mathbf{0}\text{,}\) and since \(\mathbf{u}\ne\mathbf{0}\text{,}\) this would force \(s=0\) as well. Therefore
\begin{equation*} \mathbf{v}=-\frac{s}{t}\mathbf{u}, \end{equation*}
so one vector is a scalar multiple of the other, and the vectors are parallel.

Example 2.4.5. Testing independence in three dimensions (U2-LO4).

Determine whether the vectors
\begin{equation*} \mathbf{v}_1 = \begin{bmatrix} 3 \\ 2 \\ 2 \end{bmatrix} \quad \mathbf{v}_2 = \begin{bmatrix} 1 \\ 3 \\ 0 \end{bmatrix} \quad \mathbf{v}_3 = \begin{bmatrix} -1 \\ 4 \\ -2 \end{bmatrix} \end{equation*}
are linearly independent.

Solution.

We need to determine the solutions to the equation \(t_1 \mathbf{v}_1 + t_2 \mathbf{v}_2 + t_3 \mathbf{v}_3 = \mathbf{0}\text{.}\) Expanding out this equation gives the system
\begin{align*} 3t_1 + t_2 - t_3 \amp = 0\\ 2t_1 + 3t_2 + 4t_3 \amp = 0\\ 2t_1 + 0t_2 - 2t_3 \amp = 0\text{.} \end{align*}
Practice this system in The Elimination Scratchpad
 1 
The Elimination Scratchpad
We solve this homogeneous system of linear equations using the Gaussian elimination algorithm. First we create the augmented matrix
\begin{equation*} \left[\begin{array}{ccc|c} 3 \amp 1 \amp -1 \amp 0 \\ 2 \amp 3 \amp 4 \amp 0 \\ 2 \amp 0 \amp -2 \amp 0 \end{array}\right] \end{equation*}
We reduce the matrix to row echelon form, scaling each pivot row to obtain a leading one before eliminating entries below it:
\begin{align*} \amp \left[\begin{array}{ccc|c} 3 \amp 1 \amp -1 \amp 0 \\ 2 \amp 3 \amp 4 \amp 0 \\ 2 \amp 0 \amp -2 \amp 0 \end{array}\right]\\ \amp \xrightarrow{R_1\to \frac{1}{3}R_1} \left[\begin{array}{ccc|c} 1 \amp \frac{1}{3} \amp -\frac{1}{3} \amp 0 \\ 2 \amp 3 \amp 4 \amp 0 \\ 2 \amp 0 \amp -2 \amp 0 \end{array}\right]\\ \amp \xrightarrow{\substack{R_2\to R_2-2R_1\\R_3\to R_3-2R_1}} \left[\begin{array}{ccc|c} 1 \amp \frac{1}{3} \amp -\frac{1}{3} \amp 0 \\ 0 \amp \frac{7}{3} \amp \frac{14}{3} \amp 0 \\ 0 \amp -\frac{2}{3} \amp -\frac{4}{3} \amp 0 \end{array}\right]\\ \amp \xrightarrow{R_2\to \frac{3}{7}R_2} \left[\begin{array}{ccc|c} 1 \amp \frac{1}{3} \amp -\frac{1}{3} \amp 0 \\ 0 \amp 1 \amp 2 \amp 0 \\ 0 \amp -\frac{2}{3} \amp -\frac{4}{3} \amp 0 \end{array}\right]\\ \amp \xrightarrow{R_3\to R_3+\frac{2}{3}R_2} \left[\begin{array}{ccc|c} 1 \amp \frac{1}{3} \amp -\frac{1}{3} \amp 0 \\ 0 \amp 1 \amp 2 \amp 0 \\ 0 \amp 0 \amp 0 \amp 0 \end{array}\right] \end{align*}
There is one free variable corresponding to this matrix, which implies that there is one basic solution to the equation, and thus the system has a nontrivial solution. Thus the vectors are not linearly independent.

Activity 2.4.6. Testing independence of three nonparallel vectors (U2-LO4).

Use Gaussian elimination to determine whether the vectors
\begin{equation*} \mathbf{v}_1=\begin{bmatrix}1\\0\\1\end{bmatrix}, \qquad \mathbf{v}_2=\begin{bmatrix}0\\1\\1\end{bmatrix}, \qquad \mathbf{v}_3=\begin{bmatrix}1\\1\\2\end{bmatrix} \end{equation*}
are linearly independent. If they are dependent, give a nontrivial linear combination of them that equals \(\mathbf{0}\text{.}\)
Practice this activity in The Elimination Scratchpad
 2 
The Elimination Scratchpad
Solution.
We determine whether \(t_1\mathbf{v}_1+t_2\mathbf{v}_2+t_3\mathbf{v}_3=\mathbf{0}\) has a nontrivial solution. Comparing coordinates gives
\begin{align*} t_1+t_3\amp=0\\ t_2+t_3\amp=0\\ t_1+t_2+2t_3\amp=0. \end{align*}
The first two pivots are already \(1\text{,}\) so we only need to eliminate the entries below them:
\begin{align*} \amp\left[\begin{array}{ccc|c} 1\amp0\amp1\amp0\\ 0\amp1\amp1\amp0\\ 1\amp1\amp2\amp0 \end{array}\right]\\ \amp\xrightarrow{R_3\to R_3-R_1} \left[\begin{array}{ccc|c} 1\amp0\amp1\amp0\\ 0\amp1\amp1\amp0\\ 0\amp1\amp1\amp0 \end{array}\right]\\ \amp\xrightarrow{R_3\to R_3-R_2} \left[\begin{array}{ccc|c} 1\amp0\amp1\amp0\\ 0\amp1\amp1\amp0\\ 0\amp0\amp0\amp0 \end{array}\right]. \end{align*}
The variable \(t_3\) is free. Setting \(t_3=s\) gives \(t_1=-s\) and \(t_2=-s\text{.}\) In particular, choosing \(s=1\) gives the nontrivial relation
\begin{equation*} -\mathbf{v}_1-\mathbf{v}_2+\mathbf{v}_3=\mathbf{0}. \end{equation*}
Thus the three vectors are linearly dependent, and \(\mathbf{v}_3=\mathbf{v}_1+\mathbf{v}_2\text{.}\)

Warning 2.4.7. Nonparallel vectors can still be dependent.

In ActivityΒ 2.4.6, the third vector is not parallel to either of the first two: its second entry is \(1\text{,}\) while every scalar multiple of \(\mathbf{v}_1\) has second entry \(0\text{;}\) its first entry is \(1\text{,}\) while every scalar multiple of \(\mathbf{v}_2\) has first entry \(0\text{.}\) The first two vectors are also not parallel. Nevertheless, the three vectors are dependent because \(\mathbf{v}_3=\mathbf{v}_1+\mathbf{v}_2\text{.}\) For three or more vectors, checking that no pair is parallel is not enough to establish linear independence: a vector can be a linear combination of the others without being a scalar multiple of any one of them.
The preceding example and activity demonstrate an algorithm to verify whether a given set of vectors is linearly independent.
In matrix form: put the vectors \(\mathbf{x}_1,\dots,\mathbf{x}_k\) as the columns of a matrix \(M\text{.}\) Then \(\{ \mathbf{x}_1,\dots,\mathbf{x}_k \}\) is independent exactly when \(M\mathbf{c}=\mathbf{0}\) has only the trivial solution, equivalently when every column of \(M\) is a pivot column.

Why is this true?.

Let \(\mathbf{x}\) be an element of \(\spans \{ \mathbf{x}_1, \dots, \mathbf{x}_k \}\text{.}\) If the equation
\begin{equation*} \mathbf{x} = a_1 \mathbf{x}_1 + \cdots + a_k \mathbf{x}_k \end{equation*}
had another solution, i.e.,
\begin{equation*} \mathbf{x} = b_1 \mathbf{x}_1 + \cdots + b_k \mathbf{x}_k\text{,} \end{equation*}
then subtracting one equation from the other gives that
\begin{equation*} (a_1 - b_1) \mathbf{x}_1 + \cdots + (a_k - b_k) \mathbf{x}_k = 0 \text{.} \end{equation*}
Thus the coefficients \(a_1 - b_1, \dots, a_k - b_k\) give a solution to the equation
\begin{equation*} t_1 \mathbf{x}_1 + \cdots + t_k \mathbf{x}_k = 0\text{.} \end{equation*}
But the vectors \(\mathbf{x}_1,\dots,\mathbf{x}_k\) are linearly independent, and so this equation has only a trivial solution. Thus \(a_1 - b_1, \dots, a_k - b_k = 0\text{,}\) i.e., \(a_1 = b_1, \dots, a_k = b_k\text{,}\) proving that the representation of \(\mathbf{x}\) as a linear combination is unique.

Activity 2.4.10. Testing independence in four dimensions (U2-LO4).

Determine whether the vectors
\begin{equation*} \mathbf{v}_1 = \begin{bmatrix} 1 \\ 2 \\ 0 \\ 1 \end{bmatrix} \quad \mathbf{v}_2 = \begin{bmatrix} 1 \\ -2 \\ 0 \\ 0 \end{bmatrix}\quad \mathbf{v}_3 = \begin{bmatrix} 0 \\ -3 \\ -1 \\ -1 \end{bmatrix} \end{equation*}
are linearly independent.
Solution.
We must check if the equation
\begin{equation*} t_1 \mathbf{v}_1 + t_2 \mathbf{v}_2 + t_3 \mathbf{v}_3 = 0 \end{equation*}
has nontrivial solutions. Expanding out this equation gives the system
\begin{align*} t_1 + t_2 \amp = 0\\ 2t_1 - 2t_2 - 3t_3 \amp = 0\\ -t_3 \amp = 0\\ t_1 - t_3 \amp = 0 \end{align*}
Practice this system in The Elimination Scratchpad
 3 
The Elimination Scratchpad
We first apply the Gaussian elimination algorithm to the augmented matrix. The first pivot is already a leading one, so we eliminate below it, then scale row 2 and eliminate below its leading one:
\begin{align*} \amp \left[\begin{array}{ccc|c} 1 \amp 1 \amp 0 \amp 0 \\ 2 \amp -2 \amp -3 \amp 0 \\ 0 \amp 0 \amp -1 \amp 0 \\ 1 \amp 0 \amp -1 \amp 0 \end{array}\right]\\ \amp \xrightarrow{\substack{R_2\to R_2-2R_1\\R_4\to R_4-R_1}} \left[\begin{array}{ccc|c} 1 \amp 1 \amp 0 \amp 0 \\ 0 \amp -4 \amp -3 \amp 0 \\ 0 \amp 0 \amp -1 \amp 0 \\ 0 \amp -1 \amp -1 \amp 0 \end{array}\right]\\ \amp \xrightarrow{R_2\to -\frac{1}{4}R_2} \left[\begin{array}{ccc|c} 1 \amp 1 \amp 0 \amp 0 \\ 0 \amp 1 \amp \frac{3}{4} \amp 0 \\ 0 \amp 0 \amp -1 \amp 0 \\ 0 \amp -1 \amp -1 \amp 0 \end{array}\right]\\ \amp \xrightarrow{R_4\to R_4+R_2} \left[\begin{array}{ccc|c} 1 \amp 1 \amp 0 \amp 0 \\ 0 \amp 1 \amp \frac{3}{4} \amp 0 \\ 0 \amp 0 \amp -1 \amp 0 \\ 0 \amp 0 \amp -\frac{1}{4} \amp 0 \end{array}\right] \end{align*}
For the remaining rows, scale row 3 and eliminate the entry below its leading one:
\begin{align*} \amp \xrightarrow{R_3\to -R_3} \left[\begin{array}{ccc|c} 1 \amp 1 \amp 0 \amp 0 \\ 0 \amp 1 \amp \frac{3}{4} \amp 0 \\ 0 \amp 0 \amp 1 \amp 0 \\ 0 \amp 0 \amp -\frac{1}{4} \amp 0 \end{array}\right]\\ \amp \xrightarrow{R_4\to R_4+\frac{1}{4}R_3} \left[\begin{array}{ccc|c} 1 \amp 1 \amp 0 \amp 0 \\ 0 \amp 1 \amp \frac{3}{4} \amp 0 \\ 0 \amp 0 \amp 1 \amp 0 \\ 0 \amp 0 \amp 0 \amp 0 \end{array}\right]. \end{align*}
Back substitution gives \(t_3=0\text{,}\) then \(t_2=0\text{,}\) and finally \(t_1=0\text{.}\) Thus the only solution is the trivial solution, and the vectors are linearly independent.
We could have reached this conclusion faster by inspecting the original equations. The third equation immediately gives \(t_3=0\text{,}\) the fourth then gives \(t_1=0\text{,}\) and the first gives \(t_2=0\text{.}\)

Subsection Basis and dimension

In geometry, we often describe lines as being β€˜\(1\)-dimensional’, and planes as being β€˜\(2\)-dimensional’. We can describe the notion of dimension more precisely using linear algebra.

Activity 2.4.12. Four vectors in three dimensions (U2-LO4).

Is it possible to have \(4\) linearly independent vectors in \(\R^3\text{?}\)
Solution.
It is not possible. \(\R^3\) is spanned by \(3\) vectors (for example, the standard basis vectors), so by TheoremΒ 2.4.11, any linearly independent subset of \(\R^3\) must contain at most \(3\) vectors.

Definition 2.4.13. Bases of Vector Spaces.

If \(U\) is a subspace of \(\R^n\text{,}\) a set of vectors \(\{ \mathbf{x}_1, \dots, \mathbf{x}_m \}\) in \(U\) is called a basis of \(U\) if it satisfies the following two conditions:
  • \(\{ \mathbf{x}_1, \dots, \mathbf{x}_m \}\) is linearly independent.
  • \(U = \spans \{ \mathbf{x}_1, \dots, \mathbf{x}_m \}\text{.}\)
TheoremΒ 2.4.14 says that, even though a subspace has many different bases, all bases must have the same number of vectors.

Definition 2.4.15. Dimensions of Vector Spaces.

The dimension of a non-zero subspace \(U\) of \(\R^n\) is the number of vectors in a basis for \(U\text{.}\) We often write \(\dimens(U)\) for the dimension of \(U\text{,}\) and if \(\dimens(U) = d\text{,}\) we say \(U\) is \(d\)-dimensional. By convention, the dimension of the trivial subspace \(\{ \mathbf{0} \}\) is zero.
Table 2.4.16.
Term Meaning
spanning set enough directions to generate the whole subspace
independent set no direction is redundant
basis just enough directions: spanning and independent
dimension number of directions in any basis

Activity 2.4.17. Dimensions of coordinate spaces (U2-LO4).

(a)
What is the dimension of \(\R^3\text{?}\)
Solution.
The standard basis for \(\R^3\) is a basis, i.e., the set of three vectors \(\{ \mathbf{e}_1, \mathbf{e}_2, \mathbf{e}_3 \}\) defined in DefinitionΒ 1.3.14 is linearly independent and spans \(\R^3\text{.}\) Thus \(\R^3\) has dimension \(3\text{.}\)
(b)
What is the dimension of \(\R^4\text{?}\)
Solution.
The standard basis \(\mathbf{e}_1, \dots, \mathbf{e}_4\) for \(\R^4\) is a basis, and is a set of four vectors, so \(\dimens(\R^4) = 4\text{.}\)
(c)
What is the dimension of \(\R^n\text{?}\)
Solution.
The standard basis is a basis for \(\R^n\text{,}\) so \(\dimens(\R^n) = n\text{.}\)

Activity 2.4.18. The dimension of a parametric subspace (U2-LO4).

Find the dimension of the space
\begin{equation*} W = \left\{ \begin{bmatrix} r \\ s \\ r + 2s \end{bmatrix} : r,s \in \R \right\}\text{.} \end{equation*}
Solution.
The set
\begin{equation*} S = \left\{ \begin{bmatrix} 1 \\ 0 \\ 1 \end{bmatrix}, \begin{bmatrix} 0 \\ 1 \\ 2 \end{bmatrix} \right\} \end{equation*}
is a basis for \(W\) since \(S\) is linearly independent: neither vector in \(S\) is a scalar multiple of the other. Indeed, every scalar multiple of the second vector has first entry \(0\text{,}\) whereas the first vector has first entry \(1\text{.}\) Similarly, every scalar multiple of the first vector has second entry \(0\text{,}\) whereas the second vector has second entry \(1\text{.}\) Thus the vectors are independent by ActivityΒ 2.4.4. In the solution to ActivityΒ 2.3.21, we showed that these vectors span \(W\text{,}\) so \(S\) is a basis for \(W\text{.}\) Since \(S\) contains two vectors, \(\dimens(W) = 2\text{.}\)

Why is this true?.

Suppose \(B\) is linearly independent and \(|B| = m = \dimens(U)\text{.}\) By TheoremΒ 2.4.11, one cannot add any new vectors to the set \(B\) and remain linearly independent. But FactΒ 2.4.19 says that if \(B\) is not already a spanning set for \(U\text{,}\) one can add new vectors to \(B\) from \(U\text{,}\) and remain linearly independent. Thus \(B\) must be a basis.
Conversely, if \(B\) spans \(U\text{,}\) then by FactΒ 2.4.19 we can choose a subset of \(B\) which is a basis for \(U\text{.}\) But any proper subset of \(B\) contains fewer than \(m\) vectors, and thus by TheoremΒ 2.4.14, cannot be a basis for \(U\text{.}\) Thus \(B\) is the only subset of itself that can be a basis, and because \(B\) must contain a basis, the set \(B\) must itself be a basis.

Activity 2.4.22. Adding a vector to an independent pair (U2-LO4).

Let \(\mathbf{u},\mathbf{v}\text{,}\) and \(\mathbf{w}\) are non-zero vectors in \(\R^n\text{,}\) where \(\{ \mathbf{v}, \mathbf{w} \}\) is independent. Explain why \(\{ \mathbf{u}, \mathbf{v}, \mathbf{w} \}\) is independent if and only if \(\mathbf{u}\) is not in the subspace \(M = \spans \{ \mathbf{v}, \mathbf{w}\}\text{.}\) See FigureΒ 2.4.23 and FigureΒ 2.4.24.
Vectors v and w span a plane, while u points outside the plane.
A pale blue parallelogram labeled \(M\) represents the plane spanned by \(\mathbf{v}\) and \(\mathbf{w}\text{,}\) both drawn from the origin and lying in the plane. A red vector \(\mathbf{u}\) starts at the origin and points upward outside the plane. The label \(\mathbf{u}\notin M\) emphasizes that \(\mathbf{u}\) is not in the span of the other two vectors.
Figure 2.4.23. \(\{ \mathbf{u}, \mathbf{v}, \mathbf{w} \}\) independent.
Vectors u, v, and w all lie in the same plane.
A pale blue parallelogram labeled \(M\) represents the plane spanned by \(\mathbf{v}\) and \(\mathbf{w}\text{.}\) The red vector \(\mathbf{u}\) also lies inside the same plane and starts at the origin with the other two vectors. The label \(\mathbf{u}\in M\) indicates that \(\mathbf{u}\) belongs to the span of \(\mathbf{v}\) and \(\mathbf{w}\text{.}\)
Figure 2.4.24. \(\{ \mathbf{u}, \mathbf{v}, \mathbf{w} \}\) dependent.
Solution.
If \(\{ \mathbf{u}, \mathbf{v}, \mathbf{w} \}\) is independent, suppose that \(\mathbf{u}\) is in \(M = \spans \{ \mathbf{v}, \mathbf{w} \}\text{,}\) say, that \(\mathbf{u} = a \mathbf{v} + b \mathbf{w}\) for some scalars \(a\) and \(b\text{.}\) Then \(1 \mathbf{u} - a \mathbf{v} - b \mathbf{w} = 0\text{.}\) Thus a nontrivial linear combination of \(\mathbf{u}, \mathbf{v}\text{,}\) and \(\mathbf{w}\) is equal to zero, contradicting the independent of \(\{ \mathbf{u}, \mathbf{v}, \mathbf{w} \}\text{.}\)
On the other hand, suppose \(\mathbf{u}\) is not in \(M\text{.}\) We need to show that \(\{ \mathbf{u}, \mathbf{v}, \mathbf{w} \}\) is independent. If \(r \mathbf{u} + s \mathbf{v} + t \mathbf{w} = 0\text{,}\) where \(r\text{,}\) \(s\text{,}\) and \(t\) are not all zero, then \(r \neq 0\text{,}\) for otherwise \(s \mathbf{v} + t \mathbf{w} = 0\text{,}\) which contradicts the independence of \(\{ \mathbf{v}, \mathbf{w} \}\text{.}\) But then \(\mathbf{u} = -s/r \mathbf{v} - t/r \mathbf{w}\text{,}\) which contradicts that \(\mathbf{u}\) is not in \(M\text{.}\)

Note 2.4.25.

More generally, if \(\{ \mathbf{x}_1, \dots, \mathbf{x}_k \}\) are a linearly independent set of vectors in \(\R^n\text{,}\) and \(\mathbf{x}_{k+1}\) is another vector in \(\R^n\text{,}\) then \(\{ \mathbf{x}_1, \dots, \mathbf{x}_{k+1} \}\) is a linearly independent set if and only if \(\mathbf{x}_{k+1}\) is not contained in the span of the set \(\{ \mathbf{x}_1, \dots, \mathbf{x}_k \}\text{.}\)

Activity 2.4.26. Extending a pair of vectors to a basis (U2-LO4).

Find a basis for \(\R^4\) that contains the two vectors
\begin{equation*} \mathbf{v}_1 = \begin{bmatrix} 1 \\ 0 \\ 2 \\ 0 \end{bmatrix} \quad\text{and}\quad \mathbf{v}_2 = \begin{bmatrix} 0 \\ 0 \\ 3 \\ 3 \end{bmatrix}\text{.} \end{equation*}
Solution.
Since \(\R^4\) is four dimensional, we must find two vectors \(\mathbf{w}_1\) and \(\mathbf{w}_2\) such that the vectors \(\{ \mathbf{v}_1, \mathbf{v}_2, \mathbf{w}_1,\mathbf{w}_2 \}\) is linearly independent. FactΒ 2.4.19 states that we can choose these vectors from any basis, so we might as well choose them from the standard basis \(\{ \mathbf{e}_1, \mathbf{e}_2, \mathbf{e}_3, \mathbf{e}_4 \}\text{.}\)
One strategy is to choose one vector \(\mathbf{e}_i\) not contained in the span of the set \(\{ \mathbf{v}_1, \mathbf{v}_2 \}\text{,}\) and then choose a vector \(\mathbf{e}_j\) not contained in the span of the set \(\{ \mathbf{e}_i, \mathbf{v}_1, \mathbf{v}_2 \}\text{.}\) By NoteΒ 2.4.25, the set \(\{ \mathbf{e}_j, \mathbf{e}_i, \mathbf{v}_1, \mathbf{v}_2 \}\) is then linearly independent.
The vector \(\mathbf{e}_2\) is not contained in the span of the set \(\{ \mathbf{v}_1, \mathbf{v}_2 \}\text{,}\) since the second entry in any linear combination of the vectors \(\mathbf{v}_1\) and \(\mathbf{v}_2\) is equal to zero, and thus the vector cannot be equal to \(\mathbf{e}_2\text{.}\)
We also claim that the vector \(\mathbf{e}_1\) is not contained in the span of the set \(\{ \mathbf{e}_2, \mathbf{v}_1, \mathbf{v}_2 \}\text{.}\) If
\begin{equation*} \mathbf{e}_1 = a \mathbf{e}_2 + b \mathbf{v}_1 + c \mathbf{v}_2\text{,} \end{equation*}
then writing out the vectors gives
\begin{equation*} \begin{bmatrix} 1 \\ 0 \\ 0 \\ 0 \end{bmatrix} = a\begin{bmatrix} 0 \\ 1 \\ 0 \\ 0 \end{bmatrix} + b\begin{bmatrix} 1 \\ 0 \\ 2 \\ 0 \end{bmatrix} + c\begin{bmatrix} 0 \\ 0 \\ 3 \\ 3 \end{bmatrix}. \end{equation*}
Checking each entry, we get the system of linear equations
\begin{align*} 1 \amp = b\\ 0 \amp = a\\ 0 \amp = 2b + 3c\\ 0 \amp = 3c \end{align*}
Practice this system in The Elimination Scratchpad
 4 
The Elimination Scratchpad
The first, third, and fourth equations immediately contradict one another, so such a system cannot be solved.
Thus \(\{ \mathbf{e}_1, \mathbf{e}_2, \mathbf{v}_1, \mathbf{v}_2 \}\) is a basis for \(\R^4\text{.}\)

Subsection Bases and coordinate systems

One way to think of a basis is as providing a coordinate system for a subspace. The uniquely determined coefficients in the linear combination of a vector in the subspace are the coordinates.

Definition 2.4.28. Ordered Bases of a Subspace.

Let \(S = \{ \mathbf{b}_1, \dots, \mathbf{b}_n \}\) be a basis of the subspace \(U\text{.}\) We call the tuple \(B = (\mathbf{b}_1, \dots, \mathbf{b}_n)\) an ordered basis of \(U\text{.}\)
As an example, \((\mathbf{e}_1, \mathbf{e}_2)\) and \((\mathbf{e}_2, \mathbf{e}_1)\) are two different ordered bases of \(\R^2\text{.}\) The two sets \(\{ \mathbf{e}_1, \mathbf{e}_2 \}\) and \(\{ \mathbf{e}_2, \mathbf{e}_1 \}\) are equal, and so describe the same basis of \(\R^2\text{.}\)
Given an ordered basis \(B\) for an \(m\)-dimensional subspace \(U\) of \(\R^n\text{,}\) and any vector \(\mathbf{v} \in U\text{,}\) we can describe its β€˜coordinates’ with respect to the basis \(B\text{,}\) identifying \(\mathbf{v}\) with a vector in \(\R^m\text{.}\)

Definition 2.4.29. Coordinate Vectors With Respect to a Basis.

Let \(U\) be an \(m\)-dimensional subspace of \(\R^n\text{,}\) and let \(B = (\mathbf{b}_1,\dots,\mathbf{b}_m)\) be an ordered basis for \(U\text{.}\) By TheoremΒ 2.4.9, given any vector \(\mathbf{v} \in U\text{,}\) there exist unique scalars \(t_1,\dots,t_m\) such that
\begin{equation*} \mathbf{v} = t_1 \mathbf{b}_1 + \cdots + t_m \mathbf{b}_m \end{equation*}
and we define the coordinate vector of a vector \(\mathbf{v} \in U\) with respect to \(B\) to be the \(m\)-vector
\begin{equation*} C_B(\mathbf{v}) = \begin{bmatrix} t_1 \\ \vdots \\ t_m \end{bmatrix}\text{.} \end{equation*}

Note 2.4.30.

If \(B = (\mathbf{b}_1,\dots,\mathbf{b}_m)\) is an ordered basis for a subspace \(U\text{,}\) then \(C_B(\mathbf{b}_i) = \mathbf{e}_i\text{,}\) where \(\mathbf{e_i}\) is the \(i\)th standard basis vector in \(\R^m\text{.}\)
A slanted parallelogram grid determined by basis vectors v1 and v2.
A blue oblique grid fills the plane, with one family of lines parallel to \(\mathbf{v}_1\) and the other parallel to \(\mathbf{v}_2\text{.}\) Black arrows from the origin label the basis vectors \(\mathbf{v}_1\) and \(\mathbf{v}_2\text{.}\) A black point at a grid intersection is labeled \(2\mathbf{v}_1-\mathbf{v}_2\text{,}\) showing how integer coordinates in the basis land on grid points.
Figure 2.4.31. A parallelogram grid constructed from a basis \(B = (\mathbf{v}_1, \mathbf{v}_2)\) for \(\R^2\text{.}\) The points lying at the intersection of lines on the grid are precisely those vectors \(\mathbf{v} \in \R^2\) where the entries of the vector \(C_B(\mathbf{v})\) are integers.

Activity 2.4.32. Coordinates relative to an ordered basis (U2-LO4).

Let \(B = (\mathbf{v}_1, \mathbf{v}_2, \mathbf{v}_3)\) be an ordered basis for \(\R^3\text{,}\) where
\begin{equation*} \mathbf{v}_1 = \begin{bmatrix} 1 \\ 0 \\ 0 \end{bmatrix} \quad \mathbf{v}_2 = \begin{bmatrix} 1 \\ 1 \\ 0 \end{bmatrix} \quad \mathbf{v}_3 = \begin{bmatrix} 2 \\ 0 \\ 1 \end{bmatrix}\text{.} \end{equation*}
What is \(C_B(\mathbf{v})\) if
\begin{equation*} \mathbf{v} = \begin{bmatrix} 1 \\ 1 \\ -5 \end{bmatrix}\text{.} \end{equation*}
Solution.
We need to find scalars \(c_1, c_2\text{,}\) and \(c_3\) such that
\begin{equation*} \mathbf{v} = c_1 \mathbf{v}_1 + c_2 \mathbf{v}_2 + c_3 \mathbf{v}_3\text{.} \end{equation*}
Comparing entries of the vectors gives a system of three equations, i.e.,
\begin{align*} c_1 + c_2 + 2c_3 \amp = 1\\ c_2 \amp = 1\\ c_3 \amp = -5 \end{align*}
Practice this system in The Elimination Scratchpad
 5 
The Elimination Scratchpad
Using back substitution, we find immediately that \(c_3 = -5\) from the last equation, then \(c_2 = 1\) from the second. Substituting these values into the first equation gives
\begin{equation*} c_1 = 1 - c_2 - 2c_3 = 1 - 1 - 2(-5) = 10. \end{equation*}
These values give the unique solution to this system. Thus
\begin{equation*} C_B(\mathbf{v}) = \begin{bmatrix} 10 \\ 1 \\ -5 \end{bmatrix}\text{.} \end{equation*}

Subsection Column and row space

In this section, we will often realize vectors in \(\R^n\) as rows rather than columns. The notion of span, linear independence, and basis are defined analogously as how they are defined for column vectors.

Definition 2.4.33. Column and Row Space.

Let
\begin{equation*} A = \begin{bmatrix} a_{11} \amp a_{12} \amp \cdots \amp a_{1n} \\ a_{21} \amp a_{22} \amp \cdots \amp a_{2n} \\ \vdots \amp \vdots \amp \ddots \amp \vdots \\ a_{m1} \amp a_{m2} \amp \cdots \amp a_{mn} \end{bmatrix} \end{equation*}
be an \(m \times n\) matrix.
  • The columns of \(A\text{,}\) considered as vectors in \(\R^m\text{,}\) span a subspace of \(\R^m\) called the column space of \(A\text{,}\) denoted \(\col(A)\text{.}\)
  • The rows of \(A\text{,}\) considered as vectors in \(\R^n\text{,}\) span a subspace of \(\R^n\) called the row space of \(A\text{,}\) denoted \(\row(A)\text{.}\)

Note 2.4.34.

The column space is the image space from DefinitionΒ 2.3.13 written with a column-based name:
\begin{equation*} \operatorname{col}(A)=\operatorname{im}(A). \end{equation*}
The notation \(\operatorname{im}(A)\) emphasizes outputs of the map \(\mathbf{x}\mapsto A\mathbf{x}\text{.}\) The notation \(\operatorname{col}(A)\) emphasizes the columns that span those outputs.

Why is this true?.

Each time we apply a row operation to a matrix, we replace one or more of its rows with a linear combination of other rows. Thus the row space of a matrix \(A'\) obtained by applying a row operation to a matrix \(A\) must be contained in the row space of \(A\text{.}\) But applying the argument in reverse (since every row operation is reversible), the row space of \(A\) must be contained in the row space of \(A'\text{.}\) Thus the two row spaces are equal. But if the row space is not changed after applying a single row operation, it is not changed after applying an arbitrary number of row operations, and so the result follows.

Why is this true?.

The nonzero rows of \(R\) are linearly independent by FactΒ 2.4.27, and span \(\row(R)\) by definition. They thus by definition form a basis for \(\row(R)\text{.}\)

Note 2.4.37.

If \(A\) is row equivalent to a row echelon matrix \(R\text{,}\) then \(\row(A)=\row(R)\text{.}\) By LemmaΒ 2.4.36, the nonzero rows of \(R\) form a basis for this space. Thus \(\dimens(\row(A))\) equals the number of nonzero rows, or equivalently the number of pivots, in \(R\text{.}\) In particular, this pivot count is independent of the choice of row echelon form.

Activity 2.4.38. Finding a basis for a span (U2-LO4).

Find a basis for \(V = \spans \{ \mathbf{v}_1, \mathbf{v}_2, \mathbf{v}_3, \mathbf{v}_4 \}\text{,}\) where
\begin{equation*} \mathbf{v}_1 = \begin{bmatrix} 2 \\ 1 \\ 0 \end{bmatrix} \quad \mathbf{v}_2 = \begin{bmatrix} 1 \\ 2 \\ -3 \end{bmatrix} \quad \mathbf{v}_3 = \begin{bmatrix} 0 \\ 1 \\ -2 \end{bmatrix} \quad \mathbf{v}_4 = \begin{bmatrix} 1 \\ 1 \\ -1 \end{bmatrix}\text{.} \end{equation*}
Solution.
The subspace \(V\) is the row space of the matrix
\begin{equation*} \begin{bmatrix} 2 \amp 1 \amp 0 \\ 1 \amp 2 \amp -3 \\ 0 \amp 1 \amp -2 \\ 1 \amp 1 \amp -1 \end{bmatrix}\text{.} \end{equation*}
If we reduce this matrix to row echelon form, we thus find a basis for \(V\text{.}\) At each arrow, apply the row operations from top to bottom:
\begin{align*} \begin{bmatrix} 2 \amp 1 \amp 0 \\ 1 \amp 2 \amp -3 \\ 0 \amp 1 \amp -2 \\ 1 \amp 1 \amp -1 \end{bmatrix} \amp \xrightarrow{\substack{R_1\to \frac{1}{2}R_1\\R_2\to R_2-R_1\\R_4\to R_4-R_1}} \begin{bmatrix} 1 \amp \frac{1}{2} \amp 0 \\ 0 \amp \frac{3}{2} \amp -3 \\ 0 \amp 1 \amp -2 \\ 0 \amp \frac{1}{2} \amp -1 \end{bmatrix}\\ \amp \xrightarrow{\substack{R_2\to \frac{2}{3}R_2\\R_3\to R_3-R_2\\R_4\to R_4-\frac{1}{2}R_2}} \begin{bmatrix} 1 \amp \frac{1}{2} \amp 0 \\ 0 \amp 1 \amp -2 \\ 0 \amp 0 \amp 0 \\ 0 \amp 0 \amp 0 \end{bmatrix}. \end{align*}
Thus
\begin{equation*} \left\{ \begin{bmatrix} 1 \\ \frac{1}{2} \\ 0 \end{bmatrix}, \begin{bmatrix} 0 \\ 1 \\ -2 \end{bmatrix} \right\} \end{equation*}
is a basis for \(V\text{.}\)

Warning 2.4.40. Pivot columns come from the original matrix.

Row reduction identifies pivot positions, but row operations do not preserve the original columns of \(A\text{.}\) When finding a basis for \(\operatorname{col}(A)\text{,}\) use the pivot columns of the original matrix \(A\text{,}\) not the columns of the row-reduced matrix.

Activity 2.4.41. Selecting original pivot columns in SymPy (U2-LO3, U2-LO4).

The pivot-column rule translates directly into code. The assignment R, pivots = A.rref() stores the reduced matrix and its zero-based pivot indices separately. Rows and columns are indexed starting at zero: A[i, j] selects one entry, so A[0, 2] is the entry in the first row and third column.
A colon means β€œtake all entries in this direction”: A[:, j] selects every row of column j, while A[j, :] selects every column of row j.
import sympy as sp

A = sp.Matrix([
    [2, 4, 0],
    [1, 2, 1],
    [3, 6, 2],
])
R, pivots = A.rref()
R, pivots
Output:
(Matrix([
[1, 2, 0],
[0, 0, 1],
[0, 0, 0]]), (0, 2))
A list comprehension builds a list by evaluating an expression for each item in a sequence. Read [A[:, j] for j in pivots] as β€œfor each pivot index j, take column j of A and put it in the list.”
columns = [A[:, j] for j in pivots]
columns
This is equivalent to the following loop; append adds one item to the end of a list.
columns = []
for j in pivots:
    columns.append(A[:, j])
  1. What is A[0, 2]?
  2. Predict the two column vectors in columns. Which mathematical columns do they come from? Why do they form a basis for \(\col(A)\text{?}\)
  3. What would [R[:, j] for j in pivots] return? Would these vectors form a basis for \(\col(A)\text{?}\) Explain.
  4. What would [A[j, :] for j in pivots] select? What goes wrong in [A[:, j+1] for j in pivots]?
Solution.
  1. The entry A[0, 2] is \(0\text{.}\)
  2. The indices (0, 2) select mathematical columns 1 and 3. The result is a list of two \(3\times1\) column matrices:
    [Matrix([
    [2],
    [1],
    [3]]), Matrix([
    [0],
    [1],
    [2]])]
    
    They are the original pivot columns, so the preceding theorem says they form a basis for \(\col(A)\text{.}\) The middle column is twice the first.
  3. The expression returns a list containing
    \begin{equation*} \begin{bmatrix}1\\0\\0\end{bmatrix},\qquad \begin{bmatrix}0\\1\\0\end{bmatrix}. \end{equation*}
    They form a basis for \(\col(R)\text{,}\) but not for \(\col(A)\) (you can see this directly by noting that every vector in their span has third coordinate zero, whereas the original pivot columns have third coordinates \(3\) and \(2\)). Row operations can change the column space.
  4. The row expression selects rows 1 and 3 as \(1\times3\) matrices. Adding one to the pivot indices requests indices 1 and 3, but a three-column matrix has only indices 0, 1, 2. The latter request raises an IndexError. Add one only when translating an index into mathematical column numbering, not when indexing the matrix in Python.

Definition 2.4.42. Rank of a matrix.

The rank of a matrix \(A\text{,}\) denoted \(\rank(A)\text{,}\) is the common dimension of its column and row spaces:
\begin{equation*} \rank(A)=\dimens(\col(A))=\dimens(\row(A)). \end{equation*}
Table 2.4.43.
Goal Row reduction tells you Use these vectors
basis for \(\operatorname{row}(A)\) nonzero rows of REF/RREF rows of the reduced matrix
basis for \(\operatorname{col}(A)\) pivot column positions corresponding columns of original \(A\)
basis for \(\operatorname{null}(A)\) free variables basic solution vectors in \(\mathbb R^n\)
rank number of pivots a number
nullity number of free variables a number

Why is this true?.

This gives an algorithm for computing rank: use AlgorithmΒ 2.2.40 to row-reduce the matrix to REF, then count the pivots.

Activity 2.4.46. Finding the rank of a matrix (U2-LO3).

Find the rank of the matrix
\begin{equation*} C = \left[\begin{array}{cccc} 1 \amp 1 \amp 2 \amp 7 \\ 0 \amp 1 \amp 0 \amp 3 \\ 2 \amp 1 \amp 4 \amp 11 \end{array}\right] \end{equation*}
Solution.
We convert the matrix to row echelon form using AlgorithmΒ 2.2.40. Subtract 2 times Row 1 from Row 3:
\begin{equation*} \left[\begin{array}{cccc} 1 \amp 1 \amp 2 \amp 7 \\ 0 \amp 1 \amp 0 \amp 3 \\ 0 \amp -1 \amp 0 \amp -3 \end{array}\right] \end{equation*}
Add Row 2 to Row 3:
\begin{equation*} \left[\begin{array}{cccc} 1 \amp 1 \amp 2 \amp 7 \\ 0 \amp 1 \amp 0 \amp 3 \\ 0 \amp 0 \amp 0 \amp 0 \end{array}\right] \end{equation*}
The matrix is now in REF with 2 leading ones, and so the rank of \(C\) is \(2\text{.}\)

Activity 2.4.47. Finding the rank of a matrix (continued) (U2-LO3).

Find the rank of the matrix
\begin{equation*} D = \left[\begin{array}{cccc} 1 \amp 0 \amp 1 \amp 2 \\ 0 \amp 1 \amp 0 \amp 3 \\ 2 \amp 1 \amp 2 \amp -1 \end{array}\right] \end{equation*}
Solution.
Subtract 2 times Row 1 from Row 3:
\begin{equation*} \left[\begin{array}{cccc} 1 \amp 0 \amp 1 \amp 2 \\ 0 \amp 1 \amp 0 \amp 3 \\ 0 \amp 1 \amp 0 \amp -5 \end{array}\right] \end{equation*}
Subtract Row 2 from Row 3:
\begin{equation*} \left[\begin{array}{cccc} 1 \amp 0 \amp 1 \amp 2 \\ 0 \amp 1 \amp 0 \amp 3 \\ 0 \amp 0 \amp 0 \amp -8 \end{array}\right] \end{equation*}
Multiply Row 3 by \((-1/8)\text{:}\)
\begin{equation*} \left[\begin{array}{cccc} 1 \amp 0 \amp 1 \amp 2 \\ 0 \amp 1 \amp 0 \amp 3 \\ 0 \amp 0 \amp 0 \amp 1 \end{array}\right] \end{equation*}
Matrix is now in REF with 3 leading ones, and so the rank of \(D\) is \(3\text{.}\)

Activity 2.4.48. Bases and dimensions of matrix subspaces (U2-LO3, U2-LO4).

Let
\begin{equation*} A = \begin{bmatrix} 2 \amp 1 \amp 0 \\ 1 \amp 2 \amp -3 \\ 0 \amp 1 \amp -2 \\ 1\amp 1 \amp -1 \end{bmatrix} \end{equation*}
be the matrix we considered in the solution to ActivityΒ 2.4.38.
(a)
What is \(\dimens(\row(A))\text{?}\)
Solution.
The dimension of the row space of \(A\) is equal to the rank of \(A\text{,}\) which is \(2\) (the number of non-zero rows in the row echelon form for \(A\text{,}\) as computed in the solution to ActivityΒ 2.4.38).
(b)
Find a basis for the column space of \(A\text{.}\)
Solution.
The leading 1s in the row echelon form for \(A\) computed in ActivityΒ 2.4.38 occur in the 1st and 2nd columns, so the 1st and 2nd columns of \(A\) form a basis for the column space, i.e.,
\begin{equation*} \left\{ \begin{bmatrix} 2 \\ 1 \\ 0 \\ 1 \end{bmatrix}, \begin{bmatrix} 1 \\ 2 \\ 1 \\ 1 \end{bmatrix} \right\} \end{equation*}
is a basis for \(\col(A)\text{.}\)
(c)
What is \(\dimens(\col(A))\text{?}\)
Solution.
The dimension of the column space of \(A\) is two, since we constructed a basis with two elements in the previous task. Alternatively, the dimension of the column space is equal to the rank of \(A\text{,}\) which we also computed to be two.
(d)
Find a basis for the nullspace of \(A\text{.}\)
Solution.
To find a basis for the solutions to the equation \(A \mathbf{x} = \mathbf{0}\text{,}\) we use the row-echelon form computed in ActivityΒ 2.4.38 and find basic solutions as in DefinitionΒ 2.2.63. The row-echelon form gives the equations \(x_1 + \frac{1}{2}x_2 = 0\) and \(x_2 - 2x_3 = 0\text{.}\) Setting the free variable \(x_3 = 1\text{,}\) we obtain \(x_2 = 2\) and \(x_1 = -1\text{,}\) so the basic solution is
\begin{equation*} \begin{bmatrix} -1 \\ 2 \\ 1 \end{bmatrix}\text{.} \end{equation*}
Thus \(\left\{ \begin{bmatrix} -1 \\ 2 \\ 1 \end{bmatrix} \right\}\) is a basis for the nullspace of \(A\text{.}\)

Definition 2.4.49.

The nullity of a matrix \(A\) is equal to \(\dimens(\nulls(A))\text{.}\) It is denoted \(\nullity(A)\text{.}\)
Rank counts independent directions transmitted by a matrix. Nullity counts independent input directions forgotten by a matrix. The next theorem relates these two dimensions. But, first, let’s do two examples.
We can now state one of the preview patterns from Section 2.1, introduced in ActivityΒ 2.1.4, in the language of null spaces.

Activity 2.4.50. Same output from a null-space direction (U2-LO3, U2-LO6).

Suppose \(A\mathbf{x}=\mathbf{y}\) and \(A\mathbf{z}=\mathbf{0}\text{.}\) Compute \(A(\mathbf{x}+t\mathbf{z})\text{,}\) where \(t\in\mathbb R\text{.}\) What does this say about uniqueness of outputs?
Solution.
\begin{align*} A(\mathbf{x}+t\mathbf{z}) \amp = A\mathbf{x}+tA\mathbf{z}\\ \amp = \mathbf{y}+t\mathbf{0}\\ \amp = \mathbf{y}. \end{align*}
So every vector \(\mathbf{x}+t\mathbf{z}\) gives the same output. A nonzero vector in the null space creates a whole line of inputs with the same output.

Activity 2.4.51. Revisiting the height map with rank and nullity (U2-LO3).

Return again to ActivityΒ 2.1.1. Let
\begin{equation*} P= \begin{bmatrix} 1\amp0\amp0\\ 0\amp1\amp0 \end{bmatrix}. \end{equation*}
Find the column space, null space, rank, and nullity of \(P\text{.}\)
Solution.
The column space is the span of the columns of \(P\text{.}\) Its first two columns are the standard basis vectors of \(\mathbb R^2\text{,}\) and its third column is zero, which adds no new vectors to the span. Therefore
\begin{equation*} \col(P) = \spans\left\{ \begin{bmatrix}1\\0\end{bmatrix}, \begin{bmatrix}0\\1\end{bmatrix} \right\} = \mathbb R^2, \end{equation*}
so \(\rank(P)=2\text{.}\)
To find the null space, solve \(P\mathbf{x}=\mathbf{0}\text{:}\)
\begin{equation*} P\begin{bmatrix}x_1\\x_2\\x_3\end{bmatrix} =\begin{bmatrix}x_1\\x_2\end{bmatrix} =\begin{bmatrix}0\\0\end{bmatrix}. \end{equation*}
Thus \(x_1=x_2=0\text{,}\) while \(x_3\) is free. Setting \(x_3=t\) gives every solution as
\begin{equation*} \mathbf{x}=\begin{bmatrix}0\\0\\t\end{bmatrix} =t\begin{bmatrix}0\\0\\1\end{bmatrix},\qquad t\in\mathbb R. \end{equation*}
Hence
\begin{equation*} \nulls(P) = \spans\left\{ \begin{bmatrix}0\\0\\1\end{bmatrix} \right\}, \end{equation*}
so \(\nullity(P)=1\text{.}\)

Remark 2.4.52.

In ActivityΒ 2.4.51, we found \(\rank(P)=2\) and \(\nullity(P)=1\text{,}\) so
\begin{equation*} \rank(P)+\nullity(P)=2+1=3. \end{equation*}
The two transmitted directions and the one forgotten height direction account for all three input directions. The next theorem shows that this dimension count holds for every matrix.

Note 2.4.54.

\begin{equation*} \text{input dimensions}=\text{transmitted dimensions}+\text{forgotten dimensions} \end{equation*}
\begin{equation*} n=\rank(A)+\nullity(A) \end{equation*}

Activity 2.4.55. Image and null-space bases from RREF (U2-LO3, U2-LO4).

Consider the matrix
\begin{equation*} B = \begin{bmatrix} 3 \amp -1 \amp 2 \amp 0 \\ -6 \amp 2 \amp -2 \amp 6 \end{bmatrix}\text{.} \end{equation*}
You may use the fact that the reduced row echelon form of \(B\) is the matrix
\begin{equation} \begin{bmatrix} 1 \amp -1/3 \amp 0 \amp -2 \\ 0 \amp 0 \amp 1 \amp 3 \end{bmatrix}\text{.}\tag{2.4.1} \end{equation}
(a)
Find a basis for \(\im(B)\text{.}\)
Solution.
We use the fact that \(\im(B) = \col(B)\text{.}\) Using TheoremΒ 2.4.39, since the RREF in (2.4.1) has pivots in the 1st and 3rd columns, the column space of \(B\text{,}\) and thus the image of \(B\text{,}\) has a basis given by the 1st and 3rd columns of \(B\text{,}\) i.e., we have a basis
\begin{equation*} \left\{ \begin{bmatrix} 3 \\ - 6 \end{bmatrix}, \begin{bmatrix} 2 \\ -2 \end{bmatrix} \right\} \text{.} \end{equation*}
(b)
Find a basis for \(\nulls(B)\text{.}\)
Solution.
The 2nd and 4th columns of the matrix in (2.4.1) do not contain pivots, so \(x_2\) and \(x_4\) correspond to free variables in the equation, and solutions to \(A\mathbf{x} = \mathbf{0}\) are specified by the two equations \(x_1 = x_2/3 + 2x_4\) and \(x_3 = -3x_4\text{.}\) The two basis solutions give a basis for the nullspace, and thus we have a basis of the form
\begin{equation*} \left\{ \begin{bmatrix} 1/3 \\ 1 \\ 0 \\ 0 \end{bmatrix}, \begin{bmatrix} 2 \\ 0 \\ -3 \\ 1 \end{bmatrix} \right\}\text{.} \end{equation*}

Activity 2.4.56. Using a SymPy null-space vector (U2-LO3, U2-LO4, U2-LO6).

In SymPy, the command A.nullspace() returns a Python list of basis vectors, each stored as a SymPy column matrix. With a nonempty list called basis, basis[0] selects its first vector, since list indices start at zero. The number of vectors is len(basis), which gives the nullity. If the null space is \(\{\mathbf{0}\}\text{,}\) the returned list is empty and has no first item.
import sympy as sp

A = sp.Matrix([
    [1, 0, 2],
    [0, 1, -1],
    [2, 1, 3],
])
basis = A.nullspace()
basis
Output:
[Matrix([
[-2],
[ 1],
[ 1]])]
With two numbers, * is ordinary multiplication; with a number and a matrix, it scales every entry. With two SymPy matrices, * means matrix multiplication, so A * z is the matrix-vector product when z is a column matrix. A flat list passed to sp.Matrix, such as sp.Matrix([-2, 1, 1]), creates that column matrix. This differs from NumPy arrays, where A @ z is the matrix-vector product and * acts entry by entry.
The command sp.ones(3, 1) creates a \(3\times1\) column of ones. The attribute z.T is the transpose, a \(1\times3\) row, and z.shape reports the pair (rows, columns).
z = basis[0]
A * z
  1. What are len(basis) and z.shape? Predict A * z.
  2. Why must we select basis[0] before multiplying, rather than write A * basis?
  3. Compute A * sp.ones(3, 1) and z.T * A. Explain why neither is the requested zero column.
  4. What does the zero product tell you about \(A(\mathbf{x}+t\mathbf{z})\text{?}\)
Solution.
  1. The list contains one basis vector, so len(basis) is 1 and the nullity is \(1\text{.}\) The vector has three rows and one column, so z.shape is (3, 1). The product is
    Matrix([
    [0],
    [0],
    [0]])
    
  2. basis is a list containing a matrix; it is not itself the column matrix. A * basis raises a TypeError. Selecting basis[0] supplies the vector needed for the product.
  3. The two products are
    \begin{equation*} A\begin{bmatrix}1\\1\\1\end{bmatrix}=\begin{bmatrix}3\\0\\6\end{bmatrix},\qquad \mathbf{z}^{T}A=\begin{bmatrix}0\amp2\amp-2\end{bmatrix}. \end{equation*}
    The first is a nonzero column; the second is a nonzero row. Transposing a null-space vector changes both the order and the meaning of the multiplication.
  4. Since \(A\mathbf{z}=\mathbf{0}\text{,}\) linearity gives \(A(\mathbf{x}+t\mathbf{z})=A\mathbf{x}\) for every scalar \(t\text{.}\) Changing an input by this null-space direction leaves its output unchanged.

Subsection Redundant features in a data matrix

A data matrix can have redundant columns. This means one feature column is a linear combination of other feature columns.

Example 2.4.57. Redundant features in house data.

Rows below represent houses. The three features are
\begin{equation*} \text{first-level area},\qquad \text{second-level area},\qquad \text{total area}, \end{equation*}
measured in hundreds of square feet:
\begin{equation*} X= \begin{bmatrix} 9&7&16\\ 11&9&20\\ 14&0&14\\ 8&8&16 \end{bmatrix}. \end{equation*}
Let \(\mathbf{v}_1,\mathbf{v}_2,\mathbf{v}_3\) be the columns of \(X\text{.}\) The third column satisfies
\begin{equation*} \mathbf{v}_3=\mathbf{v}_1+\mathbf{v}_2, \end{equation*}
so the third feature carries no new independent direction. The dependence relation is
\begin{equation*} \mathbf{v}_1+\mathbf{v}_2-\mathbf{v}_3=\mathbf{0}, \end{equation*}
or equivalently
\begin{equation*} X \begin{bmatrix} 1\\ 1\\ -1 \end{bmatrix} = \mathbf{0}. \end{equation*}
The null-space direction
\begin{equation*} \mathbf{z} = \begin{bmatrix} 1\\ 1\\ -1 \end{bmatrix} \end{equation*}
says that coefficient vectors differing by a multiple of \(\mathbf{z}\) give the same prediction vector.

Activity 2.4.58. Redundant square-footage features (U2-LO6).

Use the data matrix
\begin{equation*} X= \begin{bmatrix} 9&7&16\\ 11&9&20\\ 14&0&14\\ 8&8&16 \end{bmatrix}. \end{equation*}
  1. Compare the coefficient vectors
    \begin{equation*} \mathbf{c} = \begin{bmatrix} 3\\ 1\\ 0 \end{bmatrix}, \qquad \mathbf{c}' = \begin{bmatrix} 2\\ 0\\ 1 \end{bmatrix}. \end{equation*}
    Compute \(X\mathbf{c}\) and \(X\mathbf{c}'\text{.}\)
  2. The two coefficient vectors tell different stories. Why do they make the same predictions?
  3. What warning does this give about asking which feature is most important?
Solution.
We compute
\begin{equation*} X\mathbf{c} = \begin{bmatrix} 34\\ 42\\ 42\\ 32 \end{bmatrix}, \qquad X\mathbf{c}' = \begin{bmatrix} 34\\ 42\\ 42\\ 32 \end{bmatrix}. \end{equation*}
The coefficient vectors are different, but they differ by the null-space direction:
\begin{equation*} \mathbf{c}-\mathbf{c}' = \begin{bmatrix} 1\\ 1\\ -1 \end{bmatrix}. \end{equation*}
The third column of \(X\) is the sum of the first two, so
\begin{equation*} X(\mathbf{c}-\mathbf{c}')=\mathbf{0}. \end{equation*}
By linearity, \(X\mathbf{c}-X\mathbf{c}'=\mathbf{0}\text{,}\) hence \(X\mathbf{c}=X\mathbf{c}'\text{.}\)
The predictions are the same, but the coefficient interpretations are different. One coefficient vector puts weight on first-level and second-level area separately. The other puts weight on first-level area and total area. With redundant features, individual coefficient importance is not uniquely determined by the data matrix.
Further feature redundancy examples include:
  • minutes and seconds, where \(\text{seconds}=60\cdot \text{minutes}\text{;}\)
  • height in inches and height in centimeters, where \(\text{centimeters}=2.54\cdot \text{inches}\text{;}\)
  • subtotal, tax, tip, and total bill, where \(\text{total}=\text{subtotal}+\text{tax}+\text{tip}\text{;}\)
  • exam parts and exam total, where \(\text{total}=\text{part 1}+\text{part 2}+\text{part 3}\text{.}\)

Warning 2.4.59.

These are linear redundancies. Not every relationship between features is linear. For example, rectangle area is width times height, not a linear combination of width and height.

Activity 2.4.60. Auditing redundant features in code (U2-LO3, U2-LO6).

The matrix below stores the house features from ActivityΒ 2.4.58.
import numpy as np

X = np.array([
    [9., 7., 16.],
    [11., 9., 20.],
    [14., 0., 14.],
    [8., 8., 16.],
])

z = np.array([1., 1., -1.])
c = np.array([3., 1., 0.])
c_alt = np.array([2., 0., 1.])

rank = np.linalg.matrix_rank(X)

X @ z, rank, X @ c, X @ c_alt
Here c_alt stores the vector \(\mathbf{c}'\text{.}\)
Output:
(array([0., 0., 0., 0.]),
 2,
 array([34., 42., 42., 32.]),
 array([34., 42., 42., 32.]))
  1. What does the zero output mean?
  2. What does the rank say about the three feature columns?
  3. Why do \(X\mathbf{c}\) and \(X\mathbf{c}'\) agree?
  4. What does this say about interpreting coefficients when features are redundant?
Solution.
The zero output means that \(\mathbf{z}\) is a null-space direction. The rank is \(2\text{,}\) so the three feature columns contain only two independent directions.
The vectors \(\mathbf{c}\) and \(\mathbf{c}'\) differ by \(\mathbf{z}\text{,}\) and \(X\mathbf{z}=\mathbf{0}\text{.}\) Therefore they give the same prediction vector.
When features are redundant, different coefficient vectors can make the same predictions. Individual coefficients may not have a unique interpretation.

Activity 2.4.61. A difference matrix forgets level (U2-LO3).

Recall the difference matrix from ActivityΒ 1.3.10. For four input coordinates, let
\begin{equation*} D=\begin{bmatrix} -1&1&0&0\\ 0&-1&1&0\\ 0&0&-1&1 \end{bmatrix}. \end{equation*}
Compute \(D\begin{pmatrix}1\\1\\1\\1\end{pmatrix}\text{.}\) What input direction is forgotten?
Solution.
We get
\begin{equation*} D\begin{pmatrix}1\\1\\1\\1\end{pmatrix}=\mathbf{0}. \end{equation*}
The matrix records consecutive differences. Adding the same constant to every entry does not change the differences, so the constant direction \((1,1,1,1)\) is forgotten.

Activity 2.4.62. Reading the difference matrix in code (U2-LO3, U2-LO6).

D = np.array([
    [-1., 1., 0., 0.],
    [0., -1., 1., 0.],
    [0., 0., -1., 1.],
])

x = np.array([2., 5., 9., 10.])
ones = np.ones(4)

D @ x, D @ (x + 10*ones), D @ ones
Output:
(array([3., 4., 1.]),
 array([3., 4., 1.]),
 array([0., 0., 0.]))
  1. What does D @ x measure?
  2. Why do the first two outputs agree?
  3. What does D @ ones say about the map?
Solution.
The product D @ x measures consecutive differences:
\begin{equation*} 5-2=3,\qquad 9-5=4,\qquad 10-9=1. \end{equation*}
Adding \(10\) to every entry changes the level but not the differences, so the first two outputs agree.
The output D @ ones is \(\mathbf{0}\text{,}\) so the constant direction is a null-space direction. The difference matrix forgets level.
Redundant features create null-space directions. If \(X\mathbf{z}=\mathbf{0}\text{,}\) then
\begin{equation*} X(\mathbf{c}+t\mathbf{z}) = X\mathbf{c} \end{equation*}
for every scalar \(t\text{.}\) Thus many coefficient vectors can produce the same prediction vector. Rank counts how many independent feature directions remain; nullity counts how many independent coefficient changes are invisible to the data matrix.

Row reduction at a glance.

Watch: Row reduction at a glance (3:52)
 8 
math345-textbook.github.io/videos/row-reduction-at-a-glance/
.
The table below collects the uses of row reduction in SectionΒ 2.2, SectionΒ 2.3, and this section. Let \(A\) be an \(m\times n\) matrix. For given vectors \(\mathbf v_1,\ldots,\mathbf v_k\in\mathbb R^m\text{,}\) write \(M=[\,\mathbf v_1\ \cdots\ \mathbf v_k\,]\text{.}\) REF suffices throughout; use back-substitution when actual solutions or coefficients are needed.
Table 2.4.63.
Use Computation Conclusion
Find all solutions.
Activities 2.2.43, 2.2.57.
Reduce \([A\mid\mathbf b]\text{.}\) If consistent, assign parameters to free variables and back-substitute.
Expressing basic variables in terms of these parameters gives every solution.
Classify a system.
Activities 2.2.52, 2.2.53.
Reduce \([A\mid\mathbf b]\text{.}\) Inspect rows and variable-column pivots.
A row \([0\ \cdots\ 0\mid d]\) with \(d\ne0\) means no solution. Otherwise, no free variables means unique; any free variables means infinitely many.
Test span membership / reachability.
Activity 2.3.27.
Reduce \([M\mid\mathbf w]\text{;}\) back-substitute if consistent.
Consistency means \(\mathbf w\in\spans\{\mathbf v_i\}\text{,}\) equivalently \(\mathbf w\in\im(M)\text{.}\) A solution \(\mathbf c\) gives \(\mathbf w=\sum_{i=1}^k c_i\mathbf v_i\text{.}\)
Test independence / find a dependence relation.
Activity 2.4.6.
Reduce \(M\text{.}\) If free variables occur, back-substitute to find a nonzero solution of \(M\mathbf c=\mathbf0\text{.}\)
Every column a pivot means independence. A nonzero \(\mathbf c\) gives the dependence relation \(\sum_{i=1}^k c_i\mathbf v_i=\mathbf0\text{.}\)
Test spanning / verify a basis.
Activity 2.4.18.
Reduce the candidate vectors’ column matrix \(M\text{;}\) inspect pivots.
Every row a pivot means spanning \(\mathbb R^m\text{.}\) Every column a pivot means independence. An independent spanning set is a basis.
Find coordinates in an ordered basis.
Activity 2.4.32.
For \(B=(\mathbf b_1,\ldots,\mathbf b_d)\text{,}\) put its vectors in the columns of \(M\text{.}\) Reduce \([M\mid\mathbf v]\) and back-substitute.
For \(\mathbf v\in\spans(B)\text{,}\) the unique coefficient vector is \(C_B(\mathbf v)\text{.}\)
Find a row-space basis / another basis for a span.
Activity 2.4.38.
Reduce \(A\) to REF \(R\text{.}\) For a supplied spanning list, first place its vectors as rows.
The nonzero rows of \(R\) form a basis for the original row span.
Compute rank, nullity, and dimensions.
Activities 2.4.46, 2.4.48.
Reduce \(A\) to REF, then count its pivots \(r\text{.}\)
Rank and row/image dimensions equal \(r\text{.}\) Nullity equals \(n-r\text{,}\) the number of free variables.
Find an image basis / reduce a spanning set.
Activity 2.4.48.
Reduce \(A\text{,}\) or the column matrix \(M\) of the spanning vectors. Identify pivot columns.
The corresponding columns of the original matrix form a basis for its image, preserving the original span.
Find basic solutions / a null-space basis.
Activity 2.4.48.
Reduce \(A\text{.}\) In \(A\mathbf x=\mathbf0\text{,}\) set each free variable to \(1\) in turn, the others to \(0\text{,}\) and back-substitute.
These basic solutions form a basis for \(\nulls(A)\text{;}\) their linear combinations give every homogeneous solution.