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:
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$:
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.
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).
Problem: Show that applying the projection matrix twice gives the same result: $P^2 = P$.
Solution:
The middle $(A^TA)^{-1}(A^TA)$ cancels to $I$.
Problem: If $A$ has rank $r < n$, then $A^TA$ is singular. How do you compute the projection?
Solution: Use the pseudoinverse: $P = A A^+ = A(A^TA)^+ A^T$, or equivalently use the thin SVD: $A = U_r \Sigma_r V_r^T$, then $P = U_r U_r^T$. This projects onto the column space regardless of rank.
Robotics connection: Rank-deficient Jacobians appear when a robot is at a kinematic singularity.
Problem: In a SLAM system, the measurement Jacobian $H$ has a null space corresponding to gauge freedom (absolute position/orientation). What dimension is this null space for 2D SLAM?
Solution: For 2D SLAM with poses $(x, y, \theta)$: the null space has dimension 3 — corresponding to translation (2 DOF) and rotation (1 DOF) of the entire map. This is why we need to “anchor” at least one pose.