Phase I — Mathematical Foundations | Week 1 | 2.5 hours Every optimization method manipulates vectors and matrices. Today we build the language.
Robot pose = vector in $\mathbb{R}^3$ (x, y, θ). Transforming between sensor frames = matrix multiplication. Null space of a measurement Jacobian tells you which directions are unobservable — critical for SLAM and calibration.
A vector space $V$ over $\mathbb{R}$ is a set with addition and scalar multiplication satisfying the usual axioms. The key concept:
Linear independence: Vectors $\{v_1, \ldots, v_k\}$ are linearly independent if: $$c_1 v_1 + c_2 v_2 + \cdots + c_k v_k = 0 \implies c_1 = c_2 = \cdots = c_k = 0$$
Basis: A linearly independent set that spans $V$. Every vector in $V$ has a unique representation in terms of the basis.
Dimension: Number of vectors in any basis of $V$.
A matrix $A \in \mathbb{R}^{m \times n}$ defines a linear map $T: \mathbb{R}^n \to \mathbb{R}^m$ where $T(x) = Ax$.
Geometric interpretation: $A$ maps the standard basis vectors $e_1, \ldots, e_n$ to the columns of $A$.
For $A \in \mathbb{R}^{m \times n}$:
| Subspace | Definition | Dimension |
|---|---|---|
| Column space $C(A)$ | $\{Ax : x \in \mathbb{R}^n\}$ | $r$ (rank) |
| Null space $N(A)$ | $\{x : Ax = 0\}$ | $n - r$ |
| Row space $C(A^T)$ | $\{A^T y : y \in \mathbb{R}^m\}$ | $r$ |
| Left null space $N(A^T)$ | $\{y : A^T y = 0\}$ | $m - r$ |
Fundamental theorem of linear algebra: $C(A) \perp N(A^T)$ and $C(A^T) \perp N(A)$.
Orthogonal projection of $b$ onto column space of $A$: $$\hat{b} = A(A^T A)^{-1} A^T b$$
This is the closest point to $b$ in $C(A)$ — the essence of least squares!
Projection matrix: $P = A(A^T A)^{-1} A^T$. Key properties: $P^2 = P$, $P^T = P$.
Implement from scratch — no numpy.linalg:
# See: code/week01/gram_schmidt.py
Use your Gram-Schmidt to decompose $A = QR$.
Given a subspace defined by column vectors, project an arbitrary vector onto it.
For each exercise above, compare your output with numpy.linalg.qr, numpy.linalg.lstsq.
Find the rank, null space, and column space of: $$A = \begin{pmatrix} 1 & 2 & 3 \\ 2 & 4 & 6 \\ 1 & 3 & 4 \end{pmatrix}$$
Are the vectors $[1, 2, 3]$, $[4, 5, 6]$, $[7, 8, 9]$ linearly independent?
Project $b = [1, 2, 3]$ onto the column space of $A = \begin{pmatrix} 1 & 0 \\ 0 & 1 \\ 0 & 0 \end{pmatrix}$.
Compute $A^T A$ and $A A^T$ for a $3 \times 2$ matrix. Note the dimensions.
Given a rotation matrix $R(\theta) = \begin{pmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{pmatrix}$, verify $R^T R = I$.
6–10. Additional rank, null-space, and projection problems (verify all with NumPy).