David's Blog

The ramblings of a frustated Python Data Scientist ...

Linear Combinations and Spans


Introduction

This is my second blog post in my series on learning Linear Algebra. You can find the full set of post on this page:

Videos covered by this page

The following vidoes are included in the material on this page.

Linear Combinations and Spans

The next video in the Vectors and Spaces video series was a lesson on Linear Combinations and Spans:


Linear Combinations

Given two vectors $\vec{v}$ and $\vec{w}$, a linear combination of $\vec{v}$ and $\vec{w}$ is any vector of the form

$$a\vec{v} + b\vec{w}$$

where $a$ and $b$ are scalars.

For example, the vector:

$$ \vec{a} \begin{bmatrix} 6 \\ 8 \\ 10 \end{bmatrix} $$

is a linear combination of the vectors

$$ \vec{b} \begin{bmatrix} 1 \\ 1 \\ 1 \end{bmatrix}, \vec{c} \begin{bmatrix} 1 \\ 2 \\ 3 \end{bmatrix} $$

since:

$$ 4\begin{bmatrix} 1 \\ 1 \\ 1 \end{bmatrix} + 2\begin{bmatrix} 1 \\ 2 \\ 3 \end{bmatrix} = \begin{bmatrix} 6 \\ 8 \\ 10 \end{bmatrix} $$

More generally, a linear combination of n vectors:

$$v1, v2, . . . , vn$$

is any vector of the form:

$$c_1v_1 + c_2v_2 + · · · + c_nv_n$$

where $$c_1, c_2, . . . , c_n \in \Re$$ are scalars.

In [1]:
import numpy as np

b = np.array([1, 1, 1])
c = np.array([1, 2, 3])

print(f'4.b + 2.c = {(4 * b) + (2 * c)}')
4.b + 2.c = [ 6  8 10]

The Span of Vectors

The span of a collection of vectors is the set of all possible linear combinations of them. For example, the span of the vectors

$$ \begin{bmatrix} 1 \\ 5 \\ 3 \end{bmatrix}, \begin{bmatrix} 2 \\ 1 \\ 7 \end{bmatrix} $$

is the set of all vectors of the form

$$ s\begin{bmatrix} 1 \\ 5 \\ 3 \end{bmatrix} + t\begin{bmatrix} 2 \\ 1 \\ 7 \end{bmatrix} $$

as $s$ and $t$ range over all possible scalars.

So:

$$ Span(\vec{v_1}, \vec{v_2} \dots \vec{v_n}) = \Bigl\{c_1v_1 + c_2v_2 \dots c_nv_n | c_i \in \Re for 1 \leq i \leq n \Bigl\} $$

Unit Vectors

The units vectors $\hat{i}$ and $\hat{j}$ are represented as:

$$ \hat{1} \begin{bmatrix} 1 \\ 0 \end{bmatrix}, \hat{j} \begin{bmatrix} 0 \\ 1 \end{bmatrix} $$

And are said to be orthogonal i.e. at $90^\circ$ to each other. This means they can be used to represent any angle or vector in $\Re^2$ and as such form a basis of $\Re^2$.

Example

Given:

$$ \vec{a} \begin{bmatrix} 1 \\ 2 \end{bmatrix}\; , \; \vec{b} \begin{bmatrix} 0 \\ 3 \end{bmatrix}\; and \; \vec{x} \begin{bmatrix} x_1 \\ x_2 \end{bmatrix} $$

Prove:

$$c_1\vec{a} + c_2\vec{b} = \vec{x}$$$$ c_1 \begin{bmatrix} 1 \\ 2 \end{bmatrix} + c_2 \begin{bmatrix} 0 \\ 3 \end{bmatrix} = \begin{bmatrix} x_1 \\ x_2 \end{bmatrix} $$

So:

$$ 1.c_1 + 0.c_2 = x_1 $$$$ 2.c_1 + 3.c_2 = x_2 $$

Multiple top equation by $-2$ you get:

$$ -2.c_1 + 0 = -2x_1 $$$$ 2.c_1 + 3.c_2 = x_2 $$

Then add these two equations and the $c_1$ parts cancel out giving:

$$ 3c_2 = x_2 - 2x_1 $$

So:

$$c_2 = \frac{1}{3}(x_2 - 2x_1)$$

And from the first equation above ($0.c_2$) we know:

$$ c_1 = x_1 $$

So to get to the point:

$$ \begin{bmatrix} 2 \\ 2 \end{bmatrix} $$$$ c_1 = x_1 \; so \; c_1 = 2 $$$$ c_2 = \frac{1}{3}(x_2 - 2x_1) \; so \; c_2 = \frac{1}{3}(2-4) \; = \; -\frac{2}{3} $$

Solution:

$$ 2 \begin{bmatrix} 1 \\ 2 \end{bmatrix} -\frac{2}{3} \begin{bmatrix} 0 \\ 3 \end{bmatrix} = \begin{bmatrix} 2 \\ 2 \end{bmatrix} $$