Phase I — Mathematical Foundations | Week 1 | 2.5 hours Necessary conditions tell you “not here.” Sufficient conditions tell you “definitely here.”
When Ceres or g2o reports “convergence,” it means the optimality conditions are satisfied below a threshold. Understanding these conditions helps you diagnose: did the solver find a true minimum, or did it stop at a saddle point?
If $x^*$ is a local minimizer of $f$ and $f$ is differentiable:
Any minimizer must be a stationary point (zero gradient). But not every stationary point is a minimizer — it could be a maximum or saddle.
If $x^*$ is a local minimizer:
The Hessian can’t have negative eigenvalues at a minimum (you’d be able to decrease $f$ along the corresponding eigenvector).
If $\nabla f(x^*) = 0$ and $H(x^*) \succ 0$ (PD), then $x^*$ is a strict local minimum.
| Condition | $\nabla f = 0$ | Hessian | Conclusion |
|---|---|---|---|
| FONC (necessary) | ✓ | — | Must hold at any minimum |
| SONC (necessary) | ✓ | PSD | Must hold at any minimum |
| SOSC (sufficient) | ✓ | PD | Guarantees local minimum |
When $\nabla f = 0$ and $H$ is PSD (but not PD): - $f(x) = x^4$ at $x = 0$: minimum despite $f''(0) = 0$ - $f(x) = x^3$ at $x = 0$: inflection point, NOT a minimum
Higher-order analysis is needed for degenerate cases.
$x^*$ is a saddle point if $\nabla f(x^*) = 0$ and $H(x^*)$ is indefinite (has both positive and negative eigenvalues).
In high dimensions, saddle points vastly outnumber local minima. If $H$ has $n$ eigenvalues, there are $2^n$ sign combinations — most are saddle-type.
For convex $f$: - FONC ($\nabla f = 0$) is both necessary AND sufficient for global optimality - No need to check the Hessian - This is the power of convexity
# See: code/week01/optimality_conditions.py
Find all stationary points of a 2D function, classify each.
Identify and visualize saddle points — show descent directions (negative curvature eigenvectors).
Given a “solution” from an optimizer, verify the optimality conditions and report: - Gradient norm (should be ~0) - Hessian eigenvalues (should be ≥0) - Condition number (large = poorly conditioned)
Demonstrate that adding noise to gradient descent helps escape saddle points.
For each function, find all stationary points and classify them:
Problem: Ceres Solver reports convergence based on three thresholds: (1) gradient tolerance, (2) relative function change, (3) relative parameter change. Map each to the optimality conditions. Which is the most theoretically justified?
Solution: (1) Gradient tolerance checks FONC: $\|\nabla f\| < \epsilon_g$. This is the most theoretically justified — directly checks stationarity. (2) Function change $|f_{k} - f_{k-1}|/|f_k| < \epsilon_f$ checks if progress has stalled, but could trigger at a saddle. (3) Parameter change $\|\Delta x\| < \epsilon_x$ also checks stalling. In practice, (1) is primary but all three are needed — (2) and (3) catch slow convergence that (1) might miss due to numerical noise.
Problem: For a random quadratic $f(x) = \frac{1}{2}x^T A x$ where $A$ has entries drawn from $\mathcal{N}(0,1)$, what fraction of eigenvalues are positive? What does this imply about random non-convex problems?
Solution: For a GOE (Gaussian Orthogonal Ensemble) random symmetric matrix, eigenvalues follow the Wigner semicircle law centered at 0. About half are positive, half negative. So a random quadratic in $\mathbb{R}^n$ is a saddle point with probability approaching 1 as $n \to \infty$ — there are $2^n$ possible sign patterns but only 1 gives PD (minimum). In neural networks ($n \sim 10^6$), local minima are exponentially rare compared to saddle points. This is why SGD with momentum works — it naturally escapes saddle points.
Problem: Show that $f(x,y) = x^4 + y^4$ has a minimum at the origin, but SOSC fails. What additional analysis proves it?
Solution: $\nabla f(0,0) = 0$ ✓. $H(0,0) = \text{diag}(0, 0)$ — PSD but not PD, so SOSC doesn’t apply. However, for all $(x,y) \neq (0,0)$: $f(x,y) = x^4 + y^4 > 0 = f(0,0)$. Direct verification shows it’s a global minimum. The issue is that SOSC is sufficient but not necessary — the function is “flatter than quadratic” at the origin. Fourth-order analysis: the 4th-order terms $x^4 + y^4$ are positive definite, confirming the minimum.