Skip to main content

MATH 345: Linear Algebra and Optimization

Section 2.4 Independence, bases, and rank

Subsection Linear independence

Activity 2.4.1.

In ActivityΒ 2.3.4 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.6, 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.
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.1. 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 = 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 = 0\text{.}\)

Activity 2.4.2.

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*}
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 using row operations to row echelon form:
\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 \rightarrow \left[\begin{array}{ccc|c} 3 \amp 1 \amp -1 \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 \rightarrow \left[\begin{array}{ccc|c} 3 \amp 1 \amp -1 \amp 0 \\ 0 \amp \frac{7}{3} \amp \frac{14}{3} \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.
The last example demonstrates 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.3.

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*}
We could use row-reduction here, though in this case a more ad-hoc approach is more efficient. The third equation gives \(t_3 = 0\text{,}\) and once this is deduced the fourth equation gives \(t_1 = 0\text{.}\) Then the first equation gives \(t_2 = 0\text{.}\) Thus the only solution to the equation is the trivial solution, and so the vectors are linearly independent.

Activity 2.4.4.

Is the set \(S = \{ \mathbf{0} \}\) linearly independent?
Hint.
Does the equation \(t \mathbf{0} = \mathbf{0}\) have a nontrivial solution?

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.5.

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.5, any linearly independent subset of \(\R^3\) must contain at most \(3\) vectors.

Definition 2.4.6. 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.7 says that, even though a subspace has many different bases, all bases must have the same number of vectors.

Definition 2.4.8. 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.9.
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.6.

(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.8 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.7.

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 the scalar multiple of the other). In the solution to ActivityΒ 2.3.6, 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.5, one cannot add any new vectors to the set \(B\) and remain linearly independent. But FactΒ 2.4.10 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.10 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.7, 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.8.

If \(\mathbf{v}\) and \(\mathbf{w}\) are nonzero vectors in \(\R^3\text{,}\) show that \(\{ \mathbf{v}, \mathbf{w} \}\) is dependent if and only if \(\mathbf{v}\) and \(\mathbf{w}\) are parallel, i.e., if one vector is a scalar multiple of the other.
Solution.
If \(\mathbf{v}\) and \(\mathbf{w}\) are parallel, then one is a scalar multiple of the other, say \(\mathbf{v} = a \mathbf{w}\) for some scalar \(a\text{.}\) Then \(1 \mathbf{v} - a \mathbf{w} = 0\text{,}\) which is a nontrivial linear combination of \(\mathbf{v}\) and \(\mathbf{w}\text{,}\) so \(\{ \mathbf{v}, \mathbf{w} \}\) is dependent.
Conversely, if \(\{ \mathbf{v}, \mathbf{w} \}\) is dependent, then \(s \mathbf{v} + t \mathbf{w} = 0\) for some scalars \(s\) and \(t\text{,}\) where \(s \neq 0\) or \(t \neq 0\text{.}\) If, say, \(s \neq 0\text{,}\) then \(\mathbf{v} = -t/s \mathbf{w}\text{,}\) so \(\mathbf{v}\) and \(\mathbf{w}\) are parallel. A similar argument works if \(t \neq 0\text{.}\)

Activity 2.4.9.

Let \(\mathbf{u},\mathbf{v}\text{,}\) and \(\mathbf{w}\) are non-zero vectors in \(\R^n\text{,}\) where \(\{ \mathbf{v}, \mathbf{w} \}\) is independent. Show that \(\{ \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.13 and FigureΒ 2.4.14.
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.13. \(\{ \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.14. \(\{ \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.15.

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.10.

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.10 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.15, 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 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*}
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.16. 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 \}\text{,}\) and so describe the same bases of \(\R^2\text{.}\)

Note 2.4.17.

Many Linear Algebra textbooks, including Linear Algebra With Applications, Nicholson write ordered bases using set notation \(\{ \cdots \}\text{,}\) despite the order in which the basis elements appear being important. We use tuple notation \(( \cdots )\) to emphasize the importance of the order.
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.18. 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{.}\) Given any vector \(\mathbf{v} \in U\text{,}\) there exists 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*}
See FigureΒ 2.4.20 for an illustration of this concept, taken from Stanford’s MATH 51 Textbook.

Note 2.4.19.

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.20. 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.11.

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*}
Using back substitution, we find that \(c_1 = 10\text{,}\) \(c_2 = 1\text{,}\) and \(c_3 = -5\) are the unique solution to this system. Thus
\begin{equation*} C_B(\mathbf{v}) = \begin{bmatrix} 10 \\ 1 \\ -5 \end{bmatrix}\text{.} \end{equation*}

Subsection Rank of a matrix

We are now going to connect the concept of dimension with the notion of rank. 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.21. 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\) 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.22.

The column space is the image space from SectionΒ 2.3 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.4, and span \(\row(R)\) by definition. They thus by definition form a basis for \(\row(R)\text{.}\)

Remark 2.4.25.

In DefinitionΒ 2.2.28, we defined the rank of a matrix as the number of leading 1s (i.e., the number of pivots) of any matrix \(R\) in row echelon form which is row-equivalent to \(A\text{.}\) By LemmaΒ 2.4.24, \(\rank(A) = \dimens(\row(A))\text{,}\) which justifies that the rank of \(A\) is independent of the choice of matrix \(R\text{.}\)

Activity 2.4.12.

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{:}\)
\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} \rightarrow \begin{bmatrix} 1 \amp 0.5 \amp 0 \\ 0 \amp 1.5 \amp -3 \\ 0 \amp 1 \amp -2 \\ 0 \amp 0.5 \amp -1 \end{bmatrix} \rightarrow \begin{bmatrix} 1 \amp 0.5 \amp 0 \\ 0 \amp 1 \amp -2 \\ 0 \amp 0 \amp 0 \\ 0 \amp 0 \amp 0 \end{bmatrix}\text{.} \end{equation*}
Thus
\begin{equation*} \left\{ \begin{bmatrix} 2 \\ 1 \\ 0 \end{bmatrix}, \begin{bmatrix} 0 \\ 1 \\ -2 \end{bmatrix} \right\} \end{equation*}
is a basis for \(V\text{.}\)

Warning 2.4.27. 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.
Table 2.4.28.
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

Activity 2.4.13.

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.12.
(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.12).
(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.12 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.12 and find basic solutions as in DefinitionΒ 2.2.36. 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.30.

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 row-reduction definition of rank now connects to dimension.

Note 2.4.32.

\begin{equation*} \text{input dimensions}=\text{transmitted dimensions}+\text{forgotten dimensions} \end{equation*}
\begin{equation*} n=\rank(A)+\nullity(A) \end{equation*}
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.14. Same output from a null-space direction.

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?
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.15. Revisiting the height map with rank and nullity.

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{.}\) How does rank-nullity describe the height direction that \(P\) forgets?
Solution.
The column space is
\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{.}\)
The null space is
\begin{equation*} \nulls(P) = \spans\left\{ \begin{bmatrix}0\\0\\1\end{bmatrix} \right\}, \end{equation*}
so \(\nullity(P)=1\text{.}\) Since \(P\) has three input coordinates,
\begin{equation*} \rank(P)+\nullity(P)=2+1=3. \end{equation*}
Rank-nullity says that the two output directions and the one forgotten height direction account for all three input directions.

Activity 2.4.16.

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.26, 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*}

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.
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.17. Redundant square-footage features.

Use the data matrix
\begin{equation*} X= \begin{bmatrix} 9&7&16\\ 11&9&20\\ 14&0&14\\ 8&8&16 \end{bmatrix}, \qquad \mathbf{z} = \begin{bmatrix} 1\\ 1\\ -1 \end{bmatrix}. \end{equation*}
  1. Compute \(X\mathbf{z}\text{.}\)
  2. What does this say about the three feature columns?
  3. 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{.}\)
  4. The two coefficient vectors tell different stories. Why do they make the same predictions?
  5. What warning does this give about asking which feature is most important?
Solution.
First,
\begin{equation*} X\mathbf{z} = X \begin{bmatrix} 1\\ 1\\ -1 \end{bmatrix} = \mathbf{0}. \end{equation*}
This means the columns are dependent. The total-area column is the sum of the first-level and second-level columns.
Now,
\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} = \mathbf{z}. \end{equation*}
Since \(X\mathbf{z}=\mathbf{0}\text{,}\)
\begin{equation*} X\mathbf{c} = X(\mathbf{c}'+\mathbf{z}) = X\mathbf{c}'+X\mathbf{z} = X\mathbf{c}'. \end{equation*}
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.

Note 2.4.33. Common exact feature redundancies.

Common exact feature redundancies include:
  • first-level area, second-level area, and total area;
  • 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{.}\)
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.18. Which features are linearly redundant?

For each feature list, decide whether one feature is a linear combination of the others.
  1. first-level area, second-level area, total area;
  2. height in inches, height in centimeters;
  3. width, height, area of a rectangle;
  4. quiz 1 score, quiz 2 score, quiz total;
  5. bedrooms, bathrooms, selling price.
Solution.
Items 1, 2, and 4 contain exact linear redundancies:
\begin{equation*} \text{total area} = \text{first-level area} + \text{second-level area}, \end{equation*}
\begin{equation*} \text{centimeters} = 2.54(\text{inches}), \end{equation*}
and
\begin{equation*} \text{quiz total} = \text{quiz 1} + \text{quiz 2}. \end{equation*}
Item 3 is related but not linearly redundant, because
\begin{equation*} \text{area} = (\text{width})(\text{height}) \end{equation*}
is not a linear combination of width and height.
Item 5 may contain useful statistical relationships, but there is no exact linear redundancy from the feature names alone.

Activity 2.4.19. Auditing redundant features in code.

The matrix below stores the house features from the previous activity.
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 = int(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.20. A difference matrix forgets level.

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.21. Reading the difference matrix in code.

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, dtype=int)

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.