Chapter 7 Formula Sheet
One page for the whole chapter. Equation numbers are the book’s; the measured columns are this module’s.
§7.1 Gradient descent
Section titled “§7.1 Gradient descent”| what | equation | notes |
|---|---|---|
| the problem | Eq 7.4, differentiable | |
| one step | Eq 7.5 | |
| the update | Eq 7.6, the whole algorithm | |
| least squares by descent | , | Eq 7.9, 7.10 |
| condition number | §4.5; the aspect ratio of the valley | |
| preconditioning | solve | want small and cheap |
The transpose in Eq 7.6 is bookkeeping. Gradients are rows in this book (Eq 5.40), iterates are columns. In NumPy both are flat arrays, so the mistake is invisible until you reshape.
Step size on a quadratic
Section titled “Step size on a quadratic”| quantity | formula | Example 7.1 value |
|---|---|---|
| curvature bounds | , | , |
| condition number | ||
| divergence threshold | ||
| fastest step size | ||
| convergence rate | ||
| per-mode contraction | must be under for every |
Measured iteration counts to from : at , at the book’s , at , at , at , divergence from . The curve is a U, not a slide.
Adaptive step size, §7.1.1
Section titled “Adaptive step size, §7.1.1”- went up → the step was too large. Undo it and decrease . The undo is what buys monotonic convergence.
- went down → try a larger .
§7.1.2 Momentum
Section titled “§7.1.2 Momentum”| what | equation |
|---|---|
| the update | |
| the memory | |
| unrolled |
Equations 7.11 and 7.12, with . The unrolled form is an exponentially weighted moving average with effective window .
| heavy-ball optimum on a quadratic | formula | Example 7.1 value |
|---|---|---|
| step size | ||
| momentum | ||
| rate | became |
That is above the where plain descent diverges. Measured at that step size: diverges, takes iterations, takes , takes , takes , and never converges. Momentum has a lower stability bound as well as an upper one.
Speedup against plain descent, measured: at , at , at , at — tracking .
§7.1.3 Stochastic gradient descent
Section titled “§7.1.3 Stochastic gradient descent”| what | equation |
|---|---|
| loss as a sum | |
| negative log-likelihood | |
| batch update | |
| mini-batch estimate |
Equations 7.13, 7.14, 7.15. The only requirement is that the estimate be unbiased, — not that it be accurate.
| batch size (of ) | spread relative to | bias over 3000 draws |
|---|---|---|
Noise scales as — the second factor is the finite-population correction, and it is why the noise hits exactly zero at .
§7.2 Constrained optimization
Section titled “§7.2 Constrained optimization”| what | equation |
|---|---|
| the problem | s.t. for all |
| indicator form | , with if else |
| the Lagrangian | , |
| the dual function | |
| the dual problem | |
| recovering | |
| minimax inequality | |
| weak duality | , i.e. |
| stationarity | |
| complementary slackness | for each : or |
Equations 7.17–7.28. is always concave, because it is a pointwise minimum of functions affine in — however nonconvex and the are.
Equality constraints: replace by and . The two non-negative multipliers enter only as a difference, so equality multipliers are unconstrained.
| measured | value |
|---|---|
| minimax gap for on | , strict |
| Example 7.6 gap (convex) | |
| gap on s.t. (nonconvex) | , dual optimum attained at the infeasible |
§7.3 Convexity
Section titled “§7.3 Convexity”| what | statement | equation |
|---|---|---|
| convex set | for all | Def 7.2, Eq 7.29 |
| convex function | Def 7.3, Eq 7.30 | |
| first order | Eq 7.31 | |
| second order | positive semidefinite | — |
| epigraph | is a convex set iff is convex | — |
| concave | concave iff convex | — |
| the problem | s.t. , , all convex | Eq 7.38 |
Equation 7.31 is the one that pays. Substitute and it reads for every — a stationary point of a convex function is global, in one line.
Closure rules, Example 7.4
Section titled “Closure rules, Example 7.4”| operation | preserves convexity | measured on and over |
|---|---|---|
| yes | min , no chord violation | |
| , | yes | scaling cannot flip an inequality |
| yes | min , no chord violation | |
| no | min , violation | |
| no | min , violation | |
| (sets) | yes, any family | — |
| , (sets) | no | counterexample must be disjoint |
Equation 7.30 is also called Jensen’s inequality; extended to a distribution it reads .
Example 7.3, the negative entropy
Section titled “Example 7.3, the negative entropy”, convex for , with (Eq 7.32).
| test | left side | right side | slack |
|---|---|---|---|
| chord at , | |||
| tangent at , read at | |||
| second derivative at | measured | — |
§7.3.1 Linear programming
Section titled “§7.3.1 Linear programming”| what | equation |
|---|---|
| primal | s.t. |
| Lagrangian | |
| stationarity | — no in it |
| dual | s.t. , |
Equations 7.39–7.43. Primal: variables, constraints. Dual: variables, equality constraints. Solve whichever is smaller — a default, not a rule.
The optimum is always a vertex, and a vertex has exactly active constraints. The gradient of a linear objective is the constant , so there is no stationary point and no gradient method applies.
Example 7.5 measured: five feasible vertices of ten intersections, objective from to . , value , , gap . Rotating through : all five vertices win over contiguous arcs ( to ) with exactly five switches — the answer jumps, it does not slide.
§7.3.2 Quadratic programming
Section titled “§7.3.2 Quadratic programming”| what | equation |
|---|---|
| primal | s.t. , positive definite |
| Lagrangian | |
| stationarity | — is present |
| solved for | |
| dual Lagrangian | |
| dual | s.t. — no equalities |
Equations 7.45–7.52. The single difference from the LP is whether the stationarity condition contains : if not it becomes a constraint on (Eq 7.42), if so it substitutes back (Eq 7.50).
Example 7.6 measured: eigenvalues and ; with against an unconstrained , so the constraint costs ; ; gap exactly zero. Equation 7.51 reproduces a direct evaluation of the Lagrangian to over random .
§7.3.3 The convex conjugate
Section titled “§7.3.3 The convex conjugate”| what | equation |
|---|---|
| Definition 7.4 | |
| the line through a point | |
| minimum intercept | ; the conjugate is its negative |
| differentiable case | with |
| separable sums | |
| Example 7.9 |
Equations 7.53–7.68. The transform acts on the function, not on or . It needs neither convexity nor differentiability; convexity is what makes it invertible.
The slopes swap: if the slope of at is , the slope of at is .
| domain of | ||
|---|---|---|
| all of | ||
| all of | ||
| all of | ||
| all of | ||
| only | ||
| only |
A kink in the primal becomes a domain boundary in the dual.
The double conjugate and the duality gap
Section titled “The double conjugate and the duality gap”when is convex; otherwise is the convex envelope. Measured on : is flat at across and is below at the origin.
This is the Lagrangian duality gap seen from the other side. is always concave, so it can only represent a convex envelope; whatever the envelope flattens, the gap loses. Convex problems have zero gap because there is nothing to flatten.
The smoothed hinge, Exercise 7.11
Section titled “The smoothed hinge, Exercise 7.11”Differentiable at both joins (measured slope jump ) and exactly below the hinge on the linear branch — a measured at . Smoothing is never free.
§7.4 Where to go next
Section titled “§7.4 Where to go next”| weakness of gradient descent | remedy | reference |
|---|---|---|
| first-order, ignores curvature | acceleration methods | Nesterov (2018) |
| long valleys | conjugate gradients | Shewchuk (1994) |
| — | Newton, using the Hessian | Goh (2017); Bottou et al. (2018) |
| Hessian too expensive | quasi-Newton, L-BFGS | Nocedal and Wright (2006) |
| Euclidean geometry is wrong | mirror descent, natural gradient | Beck and Teboulle (2003); Toussaint (2012) |
| kinks, non-differentiability | subgradient methods | Shor (1985); Bertsekas (1999) |
| datasets too large for batch | stochastic gradient descent | Hazan (2015); Bottou et al. (2018) |
| duality and convexity | — | Boyd and Vandenberghe (2004); Bertsekas (2009) |
| convex analysis foundations | — | Rockafellar (1970); Hiriart-Urruty and Lemaréchal (2001) |
Recall card
Section titled “Recall card”- Equation 7.6 is the whole of unconstrained optimisation in this book: x minus gamma times the gradient, transposed. Everything else in Chapter 7 repairs it or constrains it.
- Two numbers govern a quadratic: mu and L. The ceiling is 2 over L, the fastest step is 2 over (mu plus L), and the rate is (kappa minus 1) over (kappa plus 1). On Example 7.1 those are 0.099724, 0.090909 and 0.823217.
- Iterations against step size form a U. 104 at the optimum, 39113 at 0.0997, divergence from 0.0998. And a step just past the ceiling can improve for 24 iterations before turning — check the growth factor, not the first few steps.
- Momentum changes the exponent, not the constant. O(kappa) becomes O(root kappa), measured 2.69 times faster at kappa 10 and 71.36 times at kappa ten thousand. Its step size 0.115976 is 16.3 percent ABOVE the plain ceiling, and at that step size too LITTLE momentum diverges.
- SGD needs unbiased, not accurate. At batch size one the typical gradient error is 2.34 times the norm of the true gradient. Keep the N over batch-size factor, or the effective learning rate silently tracks the batch size.
- Mini-batch noise falls as one over root B times root of (N minus B) over (N minus 1). The second factor is why the noise is exactly zero at a full batch.
- Equation 7.18 is right and useless; Equation 7.20 replaces the infinite wall with a linear slope. For non-negative multipliers the Lagrangian is a lower bound at any feasible point, and its maximum over the multipliers rebuilds the indicator.
- Weak duality always holds and D is always concave, however nonconvex the primal — because D is a pointwise minimum of functions affine in lambda. That is duality’s structural payoff; tightness is a separate question.
- The gradient does not vanish at a constrained optimum. The condition is grad f plus A-transpose lambda equals zero: flat where you are free, pushed where you are pinned. Complementary slackness says a slack constraint has zero price.
- Equality multipliers are unconstrained, because splitting an equality into two inequalities makes their two non-negative multipliers enter only as a difference.
- Convexity means every chord stays above the curve, its epigraph is a convex set, its tangent is a global lower bound, and its Hessian is positive semidefinite. Any one of those implies the others.
- Sampling can disprove convexity and never prove it. A function failing on under 3 percent of its domain by 1e-4 passes 99.7 percent of random chord tests, at any sample size.
- Only non-negative weighted sums and maxima are safe. Difference and product both broke convexity on x squared and exp of minus x. Intersection of sets is safe for any family; union and difference need disjoint counterexamples.
- One recipe for both duals: write the Lagrangian, collect the x terms, set the x-derivative to zero. If that condition has no x it is a CONSTRAINT and the dual is an LP; if it has x it SUBSTITUTES and the dual is a concave quadratic.
- An LP optimum is always a vertex with exactly d active constraints, because a linear objective has a constant nonzero gradient and therefore no stationary point. Rotating the objective makes the answer jump between corners.
- Definition 7.4 re-indexes a function by SLOPE instead of position, recording the negated intercept of each supporting line. The slopes swap: the derivative of f-star at s is the x that achieved the supremum.
- f-star-star is f for convex functions and the convex envelope otherwise, and that lost envelope IS the Lagrangian duality gap. The chapter’s two duality sections are one idea.
- A kink in the primal becomes a domain boundary in the dual. The hinge’s conjugate is finite only on a box, and smoothing it by a proximal round trip costs exactly gamma over two in uniform accuracy.
Next: Chapter 8 turns these methods on real data — empirical risk, model selection, and the gap between fitting and generalising.
pch.coffeeTagline
pch.coffeeCtapch.feedbackHeading
pch.feedbackSubheading