---
title: Vector spaces and subspaces
heading: The column space and the null space
eyebrow: A7 · Lesson 15 · Vector spaces
xp: 40
---

::: hook
Every sinusoid at 60 Hz can be written as $A\cos\omega t + B\sin\omega t$: two numbers pin it down, and adding two such sinusoids just adds their $A$'s and $B$'s. So 60 Hz sinusoids behave exactly like arrows in a plane, which is why phasors work. Collections like this, where you can add and scale and stay inside, are **vector spaces**. Two of them come with every matrix: the outputs it can produce, and the inputs it sends to zero. Those two spaces answer every question about whether $A\mathbf{x} = \mathbf{b}$ has a solution and how many.
:::

::: play
- This matrix has columns $(1, m)$ and $k(1, m)$: the second column is a multiple of the first.
- Every output $A\mathbf{x}$ lands on the solid line, the **column space**. The dashed line is the **null space**: every input on it is sent to zero.
- Move $k$ and $m$. The two lines turn, but each stays a line through the origin.
:::
:::

```sim plot
view: complex
range: 4
slider: k = -2..2 step 0.1 = 1.5
slider: m = -2..2 step 0.1 = 0.5
curve: u*(1 + j*m) | over: u = -4..4 | label: column space
curve: u*(-k + j) | over: u = -4..4 | dashed | color: ch2 | label: null space
arrow: 1 + j*m | label: column 1
arrow: k*(1 + j*m) | color: ch3 | label: column 2
readout: A times (-k, 1), first entry = 1*(-k) + k*1 | digits: 3
```

::: predict
## The solutions of $x + y + z = 0$ form a plane through the origin. What about the solutions of $x + y + z = 1$?

- [ ] Also a vector space
- [x] A plane, but not a vector space: it misses the origin, and adding two solutions gives a sum of 2
- [ ] A line
- [ ] Not a plane at all

::: reveal
It's a plane, but not a subspace. $(1, 0, 0)$ and $(0, 1, 0)$ are both solutions, yet their sum $(1, 1, 0)$ has $x + y + z = 2$. A subspace must be closed under adding and scaling, and so must contain zero. Solutions of $A\mathbf{x} = \mathbf{0}$ always form a subspace; solutions of $A\mathbf{x} = \mathbf{b}$ with $\mathbf{b} \ne \mathbf{0}$ never do.
:::
:::

::: nameit
## Vector spaces

A **vector space** is a set where you can add any two members and scale any member, and stay in the set (with the usual arithmetic rules). Examples:

- $\mathbb{R}^n$, lists of $n$ real numbers;
- sinusoids $A\cos\omega t + B\sin\omega t$ at one frequency, which act like $\mathbb{R}^2$;
- polynomials of degree at most 3, which act like $\mathbb{R}^4$;
- all signals $x(t)$ on an interval, an infinite-dimensional space that A10 and C9 work in.

## Subspaces

A **subspace** is a vector space inside a bigger one: a subset closed under addition and scaling. It always contains $\mathbf{0}$. In $\mathbb{R}^3$ the subspaces are $\{\mathbf{0}\}$, lines through the origin, planes through the origin, and $\mathbb{R}^3$ itself.

## The column space

The **column space** $C(A)$ is all combinations of $A$'s columns, that is, every $A\mathbf{x}$. So:

$$A\mathbf{x} = \mathbf{b} \text{ is solvable} \iff \mathbf{b} \in C(A)$$

## The null space

The **null space** $N(A)$ is every $\mathbf{x}$ with $A\mathbf{x} = \mathbf{0}$. It's a subspace: if $A\mathbf{x} = \mathbf{0}$ and $A\mathbf{y} = \mathbf{0}$ then $A(c\mathbf{x} + d\mathbf{y}) = \mathbf{0}$. Find it by elimination: reduce $A$, then solve with the free variables set to 1 one at a time.

If $\mathbf{x}_p$ solves $A\mathbf{x} = \mathbf{b}$, so does $\mathbf{x}_p + \mathbf{x}_n$ for every $\mathbf{x}_n$ in the null space. A nonzero null space means **non-unique** solutions. In a circuit, that's a sign something is underdetermined, such as a node not connected to ground, whose voltage could float to anything.
:::

::: example
## Find the null space of $A = \begin{bmatrix}1 & 2 & 3\\2 & 4 & 7\end{bmatrix}$.

::: solution
1. **Eliminate.** Subtract 2 × row 1 from row 2:
   $$\begin{bmatrix}1 & 2 & 3\\0 & 0 & 1\end{bmatrix}$$
2. **Read the rows.** Row 2 says $z = 0$; row 1 says $x + 2y = 0$.
3. **Choose the free variable.** The free variable is $y$; set $y = 1$ to get $x = -2$.
4. **Check.**
   $$\begin{aligned} A(-2, 1, 0) &= (-2 + 2, -4 + 4) \\ &= (0, 0) \end{aligned}$$

**Answer:** $N(A)$ is the line of multiples of $(-2, 1, 0)$.
:::
:::

::: example
## Write $5\cos(\omega t - 30°)$ as a vector in the space of $A\cos\omega t + B\sin\omega t$.

::: solution
1. **Expand the shifted cosine.**
   $$\begin{aligned} &\cos(\omega t - 30°) \\ &= \cos 30°\cos\omega t \\ &\quad + \sin 30°\sin\omega t \end{aligned}$$
2. **Read off the coordinates.**
   $$\begin{aligned} A &= 5\cos 30° \\ &= 4.33 \\ B &= 5\sin 30° \\ &= 2.5 \end{aligned}$$
3. **Compare with the phasor.** The sinusoid is the vector $(4.33, 2.5)$, the same as its phasor's real and imaginary parts (with the sine axis as the imaginary one).

**Answer:** $5\cos(\omega t - 30°)$ is the vector $(4.33, 2.5)$.
:::
:::

::: example
## Is the set of vectors $(x, y, z)$ with $x + y + z = 1$ a subspace of $\mathbb{R}^3$? What about $x + y + z = 0$?

::: solution
1. **The first set misses the origin.** It's a plane, but $(0, 0, 0)$ gives a sum of 0. Every subspace contains the zero vector, so it isn't one.
2. **It isn't closed either.** $(1, 0, 0)$ and $(0, 1, 0)$ are in it, but their sum $(1, 1, 0)$ isn't.
3. **The second set.** It's a plane through the origin, and sums and multiples stay on it.
4. **As a null space.** It's the null space of the 1 × 3 matrix $\begin{bmatrix}1 & 1 & 1\end{bmatrix}$, with dimension 2. KCL at a node with three branches has exactly this form.

**Answer:** $x + y + z = 1$ is not a subspace; $x + y + z = 0$ is one, a plane of dimension 2.
:::
:::

::: check
given: k = 2 | 3 | -2
answer: -k

## $A = \begin{bmatrix}1 & \given{k}\\2 & 2\given{k}\end{bmatrix}$. A null-space vector has second component 1. What is its first component?

::: right
Right. $x + ky = 0$ with $y = 1$ gives $x = -k$ = {answer}.
:::

::: misses
- [k] Check the sign: $x + ky = 0$.
- [1] Column 2 is {k} times column 1, so it takes $-\given{k}$ of column 1 to cancel it.
- [any] Not yet. Solve $x + ky = 0$ with $y = 1$.
:::
:::

::: check
given: m = 2 | -2 | 0.5; b1 = 2 | 3
answer: b1*m

## The column space of $A$ is the line through $(1, \given{m})$. For which $y$ is $(\given{b1}, y)$ in it, so that $A\mathbf{x} = (\given{b1}, y)$ is solvable?

::: right
Right. It must be a multiple of $(1, m)$: $y = \given{b1}m$ = {answer}.
:::

::: misses
- [m] The multiple is {b1}, so $y = \given{b1} \times \given{m}$.
- [b1/m] Divide the other way: $y/b_1$ must equal $m$.
- [any] Not yet. $(\given{b1}, y)$ must be a multiple of $(1, \given{m})$.
:::
:::

::: check
kind: choice

## Which of these is a subspace of $\mathbb{R}^3$?

- [x] All $(x, y, z)$ with $x = 2y$
- [ ] All $(x, y, z)$ with $x = 2y + 1$
- [ ] All $(x, y, z)$ with $x \ge 0$
- [ ] All $(x, y, z)$ with $xy = 0$

::: right
Right. It's the null space of $\begin{bmatrix}1 & -2 & 0\end{bmatrix}$, a plane through the origin.
:::

::: misses
- [2] It misses the origin.
- [3] Scaling by $-1$ leaves the set.
- [4] $(1, 0, 0)$ and $(0, 1, 0)$ are in it, but their sum isn't.
- [any] Check: contains 0, closed under adding and scaling?
:::
:::

::: check
given: x = 1 | 3 | -3; y = 2 | -1
answer: x + 2*y

## Find $z$ so that $(\given{x}, \given{y}, z)$ is in the null space of $\begin{bmatrix}1 & 2 & -1\end{bmatrix}$.

::: right
Right. $x + 2y - z = 0$ gives $z$ = {answer}.
:::

::: misses
- [-(x + 2*y)] $-z$ moves across as $+z$: $z = x + 2y$.
- [any] Not yet. Solve $x + 2y - z = 0$ for $z$.
:::
:::

::: check
given: M = 5 | 10; p = 30 | 60
answer: M*sin(p*pi/180)
tolerance: 0.5%

## In the space of $A\cos\omega t + B\sin\omega t$, what is $B$ for $\given{M}\cos(\omega t - \given{p}°)$?

::: right
Right. $\cos(\omega t - \varphi) = \cos\varphi\cos\omega t + \sin\varphi\sin\omega t$, so $B = M\sin\varphi$ = {answer}.
:::

::: misses
- [M*cos(p*pi/180)] That's $A$, the cosine coordinate.
- [-M*sin(p*pi/180)] Check the sign in $\cos(a - b) = \cos a\cos b + \sin a\sin b$.
- [any] Not yet. Expand $\cos(\omega t - \varphi)$.
:::
:::

::: check
kind: choice

## A circuit's nodal equations $G\mathbf{v} = \mathbf{i}$ have a nonzero null space. What does that usually mean?

- [ ] The circuit has too many sources
- [x] Some node voltage isn't pinned down, such as a part of the circuit with no path to ground
- [ ] The circuit has no solution for any currents
- [ ] The resistors are all equal

::: right
Right. A null-space vector is a change in voltages that changes no currents, like lifting an isolated island of the circuit by 1 V. Such a voltage is undetermined.
:::

::: misses
- [3] With a null space, solutions may still exist; they just aren't unique.
- [any] What does $G\mathbf{v}_n = \mathbf{0}$ mean physically?
:::
:::

::: check
kind: parts
given: a = 2 | 3; b = 1 | 5

## Find the null space of $\begin{bmatrix}1 & \given{a} & \given{b}\end{bmatrix}$.

::: part
answer: -a
tolerance: 0.5%

### The special solution with $y = 1$, $z = 0$ has $x$ = ?

::: misses
- [a] Check the sign: $x + a = 0$.
- [any] Set the free variables and solve $x + ay + bz = 0$.
:::
:::

::: part
answer: -b
tolerance: 0.5%

### The special solution with $y = 0$, $z = 1$ has $x$ = ?

::: misses
- [any] $x + b = 0$.
:::
:::
:::

::: check
kind: derivation
vars: p = 0.5..5, t = -2..2

## $A = \begin{bmatrix}1 & 2\\p & 2p\end{bmatrix}$ has rank 1. Its column space is the line through $(1, p)$.

::: step
answer: 3*p

### For $A\mathbf{x} = (3, q)$ to have a solution, what must $q$ be?
:::

::: step
answer: 3 - 2*t

### The null space is spanned by $(-2, 1)$. With $x_2 = t$, what is $x_1$ in the complete solution?
:::

::: right
Right. The complete solution is $(3, 0) + t(-2, 1)$: one particular solution plus the whole null space.
:::
:::

::: explain
## Why does the set of solutions of $A\mathbf{x} = \mathbf{0}$ always form a subspace, while the solutions of $A\mathbf{x} = \mathbf{b}$ with $\mathbf{b} \ne \mathbf{0}$ never do?

::: model
If $A\mathbf{x} = \mathbf{0}$ and $A\mathbf{y} = \mathbf{0}$, then $A(c\mathbf{x} + d\mathbf{y}) = cA\mathbf{x} + dA\mathbf{y} = \mathbf{0}$, so every combination is also a solution, and $\mathbf{0}$ itself is one. With $\mathbf{b} \ne \mathbf{0}$, adding two solutions gives $A(\mathbf{x} + \mathbf{y}) = 2\mathbf{b}$, which isn't $\mathbf{b}$, and $\mathbf{0}$ isn't a solution at all. The solutions of $A\mathbf{x} = \mathbf{b}$ are the null space shifted by one particular solution: a parallel copy that misses the origin.
:::
:::

::: practice

::: check
given: k = 2..9 int
answer: -2*k

## $A = \begin{bmatrix}2 & 1\\2\given{k} & \given{k}\end{bmatrix}$. A null-space vector has first component 1. What is its second component?

::: misses
- [any] Row 1: $2x + y = 0$.
:::
:::

::: check
given: M = 4 | 8; p = 30 | 60
answer: M*cos(p*pi/180)
tolerance: 0.5%

## In the space of $A\cos\omega t + B\sin\omega t$, what is $A$ for $\given{M}\cos(\omega t - \given{p}°)$?

::: misses
- [M*sin(p*pi/180)] That's $B$.
- [any] $A = M\cos\varphi$.
:::
:::

::: check
given: a = 1 | 3; b = 2 | 5
answer: -(a + b)

## Find $z$ so that $(\given{a}, \given{b}, z)$ is in the plane $x + y + z = 0$.

::: misses
- [a + b] Move it across: $z = -(x + y)$.
- [any] $z = -x - y$.
:::
:::
:::
