---
title: Linear combinations and span
heading: Everything you can reach by scaling and adding
eyebrow: A7 · Lesson 2 · Linear combinations
xp: 40
---

::: hook
A circuit with two sources obeys superposition: its output is some amount of the first source plus some amount of the second. Mixing a red, a green and a blue light makes every color a screen can show. Both are **linear combinations**: scale some vectors and add them up. Almost every question in linear algebra comes down to one about linear combinations: which vectors can you reach, and with what weights?
:::

::: play
- The two fixed vectors are $\mathbf{v} = (2, 1)$ and $\mathbf{w} = (-1, 2)$. The sliders set the weights $c$ and $d$, and the green arrow is $c\mathbf{v} + d\mathbf{w}$.
- Steer the green arrow onto the target dot at $(1, 4)$. The readout shows how far away you are.
- Can you reach every point in the plane this way? What would have to be true of $\mathbf{v}$ and $\mathbf{w}$ for some points to be out of reach?
:::
:::

```sim plot
view: complex
range: 6
slider: c = -3..3 step 0.1 = 0.5
slider: d = -3..3 step 0.1 = 0.5
arrow: c*(2 + j) | label: cv
arrow: d*(-1 + 2*j) | from: c*(2 + j) | color: ch2 | label: dw
arrow: c*(2 + j) + d*(-1 + 2*j) | color: ch3 | label: cv + dw
dot: 1 + 4*j | label: target
readout: distance to target = sqrt((2*c - d - 1)^2 + (c + 2*d - 4)^2) | digits: 3
```

::: predict
## You need weights $c$ and $d$ with $c(2, 1) + d(-1, 2) = (1, 4)$. How many pairs $(c, d)$ work?

- [x] Exactly one
- [ ] None
- [ ] Two
- [ ] Infinitely many

::: reveal
Exactly one: $c = 1.2$, $d = 1.4$. The two vectors point in different directions, so every point in the plane is reachable, and in only one way. If they were parallel, the combinations would all lie on one line: most targets would be unreachable, and those on the line could be reached in infinitely many ways.
:::
:::

::: nameit
## Linear combinations

A **linear combination** of vectors $\mathbf{v}_1, \ldots, \mathbf{v}_n$ is $c_1\mathbf{v}_1 + \cdots + c_n\mathbf{v}_n$, for any numbers $c_i$. Scaling and adding work one component at a time.

## Span

The **span** of a set of vectors is all their linear combinations.

- One nonzero vector spans a line through the origin.
- Two vectors in different directions span a plane (all of 2D, or a plane through the origin in 3D).
- Two parallel vectors only span a line.

## The column picture

A system of equations is a question about linear combinations. The system

$$2x - y = 1, \qquad x + 2y = 4$$

asks for weights $x$ and $y$ with $x\begin{bmatrix}2\\1\end{bmatrix} + y\begin{bmatrix}-1\\2\end{bmatrix} = \begin{bmatrix}1\\4\end{bmatrix}$. In matrix form that's $A\mathbf{x} = \mathbf{b}$, where the columns of $A$ are the vectors being combined. So: **$A\mathbf{x} = \mathbf{b}$ has a solution exactly when $\mathbf{b}$ is in the span of $A$'s columns.**

The **row picture** of the same system is two lines crossing at the solution. Both pictures are true; the column picture is the one that scales up to big systems.

## Superposition

A linear circuit's output is a linear combination of its sources: $v_\text{out} = k_1V_1 + k_2V_2$, where $k_1$ is the output with $V_1$ = 1 V alone and $k_2$ the output with $V_2$ = 1 V alone. That's why C1 can find each source's contribution separately and add them.
:::

::: example
## Write $\mathbf{b} = (4, 5)$ as a combination of $(1, 1)$ and $(1, -1)$.

::: solution
1. **Set up the equations.** You need $c + d = 4$ and $c - d = 5$.
2. **Add them.** Adding the two equations gives $2c = 9$, so $c = 4.5$, and then $d = -0.5$.
3. **Check.**
   $$\begin{aligned} &4.5(1, 1) - 0.5(1, -1) \\ &= (4.5 - 0.5, 4.5 + 0.5) \\ &= (4, 5) \end{aligned}$$

**Answer:** $\mathbf{b} = 4.5(1, 1) - 0.5(1, -1)$, so $c = 4.5$ and $d = -0.5$.
:::
:::

::: example
## A linear circuit gives 0.5 V at its output when source 1 alone is 1 V, and 0.25 V when source 2 alone is 1 V. What does it give with $V_1$ = 10 V and $V_2$ = 4 V?

::: solution
1. **Weights.** The output is a linear combination of the sources, with the single-source responses as weights: 0.5 for $V_1$ and 0.25 for $V_2$.
2. **Superpose.**
   $$\begin{aligned} v_\text{out} &= 0.5 \times 10 + 0.25 \times 4 \\ &= 6\ \text{V} \end{aligned}$$

**Answer:** the output is 6 V.
:::
:::

::: example
## Can $(1, 2, 4)$ be written as a combination of $(1, 0, 1)$ and $(0, 1, 1)$?

::: solution
1. **Write a general combination.**
   $$\begin{aligned} &c(1, 0, 1) + d(0, 1, 1) \\ &= (c, d, c + d) \end{aligned}$$
2. **Match the first two entries.** They force $c = 1$ and $d = 2$, and then the third entry is 3, not 4. So no: $(1, 2, 4)$ is out of reach.
3. **The span.** The span of the two vectors is the plane where the third entry equals the sum of the first two:
   $$z = x + y$$
   The target $(1, 2, 3)$ lies in it; $(1, 2, 4)$ sits one unit above it.

**Answer:** no. $(1, 2, 4)$ sits one unit above the plane $z = x + y$ that the two vectors span.
:::
:::

::: check
given: c = 2 | -1 | 3; d = 2 | -2 | 3; v1 = 1 | 3; w1 = 2 | -4
answer: c*v1 + d*w1

## $\mathbf{v} = (\given{v1}, 5)$ and $\mathbf{w} = (\given{w1}, 1)$. What is the first component of $\given{c}\mathbf{v} + \given{d}\mathbf{w}$?

::: right
Right. Component by component: $c v_1 + d w_1$ = {answer}.
:::

::: misses
- [c*v1 + w1] Scale $\mathbf{w}$ by {d} as well.
- [any] Not yet. Scale each vector, then add the first components.
:::
:::

::: check
given: b1 = 4 | 6 | 1; b2 = 2 | -2
answer: (b1 + b2)/2

## Find $c$ so that $c(1, 1) + d(1, -1) = (\given{b1}, \given{b2})$.

::: right
Right. Adding $c + d = b_1$ and $c - d = b_2$ gives $c = \frac{b_1 + b_2}{2}$ = {answer}.
:::

::: misses
- [(b1 - b2)/2] That's $d$.
- [b1 + b2] Divide by 2: adding the equations gives $2c$.
- [any] Not yet. Write the two component equations and add them.
:::
:::

::: check
kind: choice

## What do the vectors $(1, 2)$ and $(2, 4)$ span?

- [ ] The whole plane
- [x] A line through the origin
- [ ] Just the two points
- [ ] Nothing

::: right
Right. $(2, 4) = 2(1, 2)$, so every combination is a multiple of $(1, 2)$: a single line.
:::

::: misses
- [1] They're parallel: $(2, 4)$ is twice $(1, 2)$.
- [3] The span includes every combination, so infinitely many points.
- [any] Is one a multiple of the other?
:::
:::

::: check
given: k1 = 0.5 | 0.2; k2 = 0.25 | 0.4; V1 = 10 | 5; V2 = 4 | 12
answer: k1*V1 + k2*V2
unit: V

## A linear circuit gives {k1} V at its output for 1 V on source 1 alone, and {k2} V for 1 V on source 2 alone. What is the output with $V_1$ = {V1} V and $V_2$ = {V2} V?

::: right
Right. Superposition: $k_1V_1 + k_2V_2$ = {answer}.
:::

::: misses
- [(k1 + k2)*(V1 + V2)] Each source has its own weight.
- [k1*V1] Add source 2's contribution too.
- [any] Not yet. Scale each response by its source and add.
:::
:::

::: check
given: p = 2 | 4; q = 6 | 10
answer: q/p
tolerance: 0.5%

## For what $k$ are $(1, k)$ and $(\given{p}, \given{q})$ parallel, so that they span only a line?

::: right
Right. $(\given{p}, \given{q}) = \given{p}(1, k)$ needs $k = \frac{q}{p}$ = {answer}.
:::

::: misses
- [p/q] Upside down: the second component over the first.
- [any] Not yet. Make $(\given{p}, \given{q})$ a multiple of $(1, k)$.
:::
:::

::: check
kind: choice

## The columns of a 3 × 2 matrix $A$ point in different directions. For which $\mathbf{b}$ in 3D does $A\mathbf{x} = \mathbf{b}$ have a solution?

- [ ] Every $\mathbf{b}$
- [x] Only $\mathbf{b}$ in the plane spanned by the two columns
- [ ] Only $\mathbf{b} = \mathbf{0}$
- [ ] Only $\mathbf{b}$ on one line

::: right
Right. Two vectors span a plane, and $A\mathbf{x}$ can only reach combinations of the columns.
:::

::: misses
- [1] Two vectors can't fill 3D. Most $\mathbf{b}$ are off their plane.
- [3] $\mathbf{b} = 0$ works, but so does any combination of the columns.
- [4] The columns point in different directions, so they span a plane, not a line.
- [any] What do two independent vectors span?
:::
:::

::: check
kind: parts
given: p = 2 | 5 | 7; q = 1 | 3

## Write $(\given{p}, \given{q})$ as $c(1, 1) + d(1, -1)$.

::: part
answer: (p + q)/2
tolerance: 0.5%

### What is $c$?

::: misses
- [p + q] Adding the equations gives $2c = p + q$.
- [any] $c + d = p$ and $c - d = q$.
:::
:::

::: part
answer: (p - q)/2
tolerance: 0.5%

### What is $d$?

::: misses
- [(q - p)/2] Check the sign: $c - d = q$.
- [any] Subtract the equations.
:::
:::
:::

::: check
kind: derivation
vars: x = 0.5..5, y = 0.5..5

## Solve $c(2, 1) + d(1, 1) = (x, y)$.

::: step
answer: x - y

### The equations are $2c + d = x$ and $c + d = y$. Subtract them: what is $c$?
:::

::: step
answer: 2*y - x

### What is $d$?
:::

::: right
Right. $c = x - y$ and $d = 2y - x$: every target is reachable, because the two vectors aren't parallel.
:::
:::

::: explain
## Explain why "$A\mathbf{x} = \mathbf{b}$ has a solution" means the same as "$\mathbf{b}$ is a combination of the columns of $A$."

::: model
Multiplying $A$ by $\mathbf{x}$ takes $x_1$ times the first column plus $x_2$ times the second, and so on: the entries of $\mathbf{x}$ are the weights in a linear combination of the columns. So $A\mathbf{x} = \mathbf{b}$ asks whether some choice of weights makes that combination equal $\mathbf{b}$. If $\mathbf{b}$ lies in the span of the columns, such weights exist and they are the solution; if it doesn't, no weights work and the system has no solution.
:::
:::

::: practice

::: check
given: c = 2 | 3; d = -1 | 2; v2 = 1 | 4; w2 = 3 | -2
answer: c*v2 + d*w2

## $\mathbf{v} = (1, \given{v2})$ and $\mathbf{w} = (2, \given{w2})$. What is the second component of $\given{c}\mathbf{v} + \given{d}\mathbf{w}$?

::: misses
- [any] $cv_2 + dw_2$.
:::
:::

::: check
given: b1 = 3 | 7; b2 = 1 | -3
answer: (b1 - b2)/2

## Find $d$ so that $c(1, 1) + d(1, -1) = (\given{b1}, \given{b2})$.

::: misses
- [(b1 + b2)/2] That's $c$.
- [any] Subtract the two component equations.
:::
:::

::: check
given: k1 = 0.3 | 0.6; V1 = 5 | 9; out = 4 | 6
answer: out - k1*V1
unit: V

## A linear circuit gives {k1} V per volt of source 1. With source 1 at {V1} V and source 2 on, the output is {out} V. How much of the output is due to source 2?

::: misses
- [any] Subtract source 1's share, $k_1V_1$.
:::
:::
:::
