Your feet feel the tilt, not the turn
Blindfold yourself on a hillside. You can still feel one thing perfectly: how steeply the ground tilts under your boots. So you lean into the downhill direction and take a stride. Here is what your feet cannot tell you — how long that tilt lasts. A one-in-three slope that runs for fifty metres and a one-in-three slope that stops dead after five centimetres feel exactly the same underfoot. Take a long confident stride on the second one and you have walked off a ledge. Push the walker around and watch it happen:
That is the honest limit of a gradient. A gradient is a local measurement: it reports the tilt at one point and says nothing about the next point. The information you actually wanted — how fast the tilt itself is changing — lives in the second derivatives, the Hessian, and that is a whole square table of numbers. For a model with a million knobs that is a trillion numbers per step. Nobody computes it.
So we are stuck with the tilt. Now look at the valley tab, where the same blindness costs you in a quieter way. The loss is — gentle along , steep along — and the tilt at the start reads . One direction pushes ten times harder than the other, and a single stride has to serve both. Multiply out what one step does to each coordinate on its own and the whole problem becomes arithmetic you can do in your head.
Each direction is quietly multiplied by its own number every step, and the two numbers share one . At the steep coordinate is annihilated in a single step () while the gentle one only shrinks by a tenth — it needs 44 steps to get within 1 % of zero. Raise to hurry it along and at the steep factor hits exactly : flips for ever, never diverging, never arriving. Past that it explodes. There is no that suits both. Not a bad choice of — no choice at all.
Unit 10 attacked that by rebuilding the landscape: standardise the columns, the ten-to-one becomes one-to-one, one stride fits everybody. That fix is real and it is the first thing to try. But it only reaches as far as your data does. The stiffness of a deep network comes from the layers, not just the inputs, and it drifts while you train. You cannot restandardise your way out of that.
So the rest of this act takes the other road. Leave the landscape alone. Change the walker. Everything that follows is one of three instincts bolted onto the same plain step — and each instinct is one line of arithmetic.
On you set exactly. What does the steep coordinate do?
If you want the algebra · 2 proofs, step by step
Claim. On , one step of plain descent multiplies each coordinate by ; the walk converges in every direction exactly when ; and on at the gentle coordinate needs steps to fall inside of zero.
Claim. If does not change faster than a rate (that is, ), then one step guarantees — so progress is guaranteed exactly while , and is largest at .
Momentum — give the walker mass
Swap the walker for a loaded supermarket trolley. Two things change at once. The trolley has a wonky wheel that jerks it left, then right, then left — and you barely notice, because a jerk one way followed by a jerk the other way cancels out in something heavy. And the trolley has a direction: once it is rolling down the aisle, every small push in that same direction adds to the roll, and it goes faster and faster. There is a price, and you know it already: at the till you cannot stop it. Roll the trolley down the same valley and watch both halves:
The panel of bars is the entire idea. Look at the two strips. Along the gentle direction , every step's push points the same way, so the bars stack into one long bar — and the trolley moves further per step than the walker ever could. Along the steep direction , the pushes alternate in sign, so the bars cancel and almost nothing survives. The trolley did not learn which direction was which. It simply added up recent pushes, and adding up is what separates a consistent direction from a flapping one.
Writing it down takes one extra vector. Call it the velocity : it is what is left of the last move.
"New move = a faded copy of the last move, plus a fresh downhill push." The dial is how much of the last move survives — the friction. At you get the plain walker back, exactly. At , a direction that keeps getting the same push builds up until each step is times the plain step, while a direction that keeps flipping cancels itself to nothing.
Now the price. Run the defaults and read the loss: . It went up. At step 1 the steep coordinate landed exactly on the floor, so its fresh push is zero — but the velocity still says "you were plunging, keep going", and it carries straight through the bottom to . That is not a bug and it is not a bad . It is a rolling object doing what rolling objects do. Momentum is not a method that lowers the loss every step; it is a method that lowers the loss over a stretch of steps, and pays for speed with overshoot on the way.
One warning the picture makes obvious: never set . Friction is the only thing draining the extra energy out of the swing. With none, the trolley rings for ever or flies apart.
After one momentum step the walker sits at , exactly at the floor of the steep direction, where the fresh slope is . What does step 2 do to ?
A direction receives the same gradient at every step. With and stride , how big does each step eventually become?
If you want the algebra · 2 proofs, step by step
Claim. If a direction receives the same gradient at every step, momentum's step size rises from to — a factor of at .
Claim. is identical to ; and on with the first three points are , , .
AdaGrad — a stride each, out of a permanent record
Momentum kept the one shared stride and added memory on top. AdaGrad goes at the real problem instead: it stops sharing. Every knob is issued a school report on its first day. Nothing about where it went — only how loud its pushes have been, added up as squares, from the beginning of time. A knob with a loud record gets gentle taps from now on. A knob with a quiet record keeps its full push. And the record is never cleared, which is the part that eventually costs.
Watch the first step, because it is the most surprising number in this unit. The steep knob felt a slope of ; the gentle one felt . Both move by exactly . The ten-to-one mismatch that broke the shared stride in §1 has simply disappeared, and nobody standardised anything.
The reason is one line of cancellation. On step 1 the record holds only that step's own square, so the square root of the record is the size of the slope, and dividing the slope by its own size leaves .
with every operation done one entry at a time ( means "multiply entry by entry"). On step 1, : only the sign of the slope survives. Its size decides nothing. Every knob takes a step of exactly , and the only thing the gradient contributes is which way.
That is why AdaGrad's famous win is rare features. A word that appears in one document in ten thousand gives its weight a slope almost never, so its record stays tiny and its strides stay long. A word that appears everywhere is throttled. You get frequency-aware strides for nothing, without ever writing down what is rare.
Now the catch, and it is written into the update: is a running total. It only ever grows, so only ever shrinks, whether or not the knob has arrived. Two steps in, the stride is already down from to . Open the long run tab and watch it trace — a curve that reaches zero, and reaches it whether or not you did. A shrinking step is a brake, not a convergence. AdaGrad routinely stops short of the bottom because it ran out of stride, not because it arrived.
Two knobs start together. Knob A feels a slope of at every step; knob B feels then , alternating, for ever. After many steps, which one is AdaGrad still moving in long strides?
If you want the algebra · 2 proofs, step by step
Claim. With , the first AdaGrad step moves every coordinate by exactly in the direction .
Claim. On a constant slope , AdaGrad's step at time is ; the total distance it can ever cover in steps grows only like , so reaching a target distance costs about steps.
RMSProp — form, not career average
No selector picks a side on career averages. They look at recent form — the last ten innings, with the latest counting most — because a bad patch from nine seasons ago tells you nothing about today. AdaGrad judges every knob on its career. RMSProp keeps the whole per-knob idea and changes one word: forget. The catch is the one every selector knows too. After a single innings, "recent form" is a wild number.
One line of AdaGrad changes. Instead of adding squares to a total for ever, keep a fading average: hold on to a share of what you had and let of the new square in.
A slope from steps ago is worth of a fresh one — the memory comb in the widget is exactly that. As a rule of thumb the average remembers about the last steps, which at is ten. And because can now fall as well as rise, the brake can be released again. The stride never dies.
Compare the two stride curves in the third panel. AdaGrad's slides towards zero and stays there; RMSProp's settles at a healthy size and keeps working. On the session's valley the difference shows up fast: after two steps RMSProp's strides are then , and the loss has fallen while AdaGrad is still at .
But look at that first number again. is three times . Where did that come from? The average started at zero, so on step 1 it holds only — a tenth of the true size. Its square root is too small, and dividing by something too small makes the step too big, by exactly . Set , as people often do, and the first step is 31.6 times what you asked for. RMSProp never fixes this. You just live through it — the average fills up within a few steps and the problem goes away on its own. The next method refuses to live through it.
You raise the forgetting dial from to . What happens to the very first step?
A knob has been feeling the same slope for hundreds of steps. What does RMSProp's stride settle at, and what does AdaGrad's do?
If you want the algebra · 2 proofs, step by step
Claim. On a constant slope , RMSProp's accumulator is , so its step size tends to and never dies.
Claim. RMSProp's first step is — at and at .
Adam — two notebooks and a probation period
A new analyst joins and starts two notebooks about a project. One records which way the decisions have been trending. The other records how big they have been running. On day two both notebooks are nearly empty, and a careful manager knows exactly what to do with a nearly-empty notebook: discount it. Not ignore it — discount it, heavily at first, less each week, until a year in the notebooks are full and can be read at face value. That discount is a number, it shrinks the analyst's authority on purpose, and it retires itself.
You have already met both notebooks. The direction notebook is momentum, written as a fading average instead of a running velocity. The loudness notebook is RMSProp. Adam keeps both, one per knob, and divides the first by the root of the second.
The step is average direction divided by root average loudness. The numerator averages signed slopes, so slopes that disagree cancel; the denominator averages squares, which cannot cancel. A knob being pushed consistently gets a ratio near ; a knob being shaken about gets a ratio near zero. Noise is throttled automatically, and nothing had to detect it.
Now the probation rate. Both notebooks start empty, so after steps has filled to only a share of full and to . Correct each by its own share, put the corrected pair into an RMSProp-shaped step, and everything cancels except one leftover factor — and that leftover factor is . Only sits under a root, so only its correction picks up a square root. That is the whole derivation, and it is folded into the drawer below.
What it buys is visible in one number. Drag the step slider to : the stride is exactly in both knobs. RMSProp's spike is gone, and AdaGrad's early fade never happens. Watch on the log axis: it starts at , dips to a minimum of at — the two notebooks fill at different speeds, so the correction is not monotone — and then climbs back to the plain and stays there. The scaffolding comes down by itself.
Two practical notes. Libraries call by the names , with the same defaults and . And count from : at the denominator is zero and the whole rate blows up. That off-by-one is one of the most-committed bugs in machine learning.
A knob's slope alternates while another knob's stays steady at . Both use Adam. Which one takes the bigger steps, and why?
If you want the algebra · 2 proofs, step by step
Claim. Correcting both zero-started averages for how full they are turns the RMSProp step into with — the square root landing on the correction only.
Claim. At , Adam moves every coordinate by exactly in the direction — RMSProp's spike is cancelled precisely.
Five walkers, one valley — and the dial that decides the race
Same valley, same start , same stride , five rules. Everything you are about to see comes from the update rule alone — no tuning, no tricks, no head start. Press play, then do the thing the race is really for: turn the stiffness dial and watch the result change shape.
At the lecture setting the story is already rich. Plain descent looks excellent — because happens to annihilate the steep direction in one step, which is luck, not skill. Momentum pays an early debt (the loss rises to at step 2) and then rings its way down. AdaGrad evens the two directions immediately and then loses its stride. RMSProp reaches the floor first and by a distance. Adam walks a steady -sized pace, rolls through the bottom around step eleven because it still carries momentum, and swings back.
| Method | after 2 | after 25 | ||
|---|---|---|---|---|
| Gradient descent | 0.3281 | 0.00258 | ||
| Momentum | 4.3092 | 0.196 | ||
| AdaGrad | 3.8173 | 0.547 | ||
| RMSProp | 1.3688 | |||
| Adam | 3.5236 | 0.179 |
Now do not crown a winner. This valley is tiny, clean, noiseless, only ten-to-one stiff, and the stride was chosen to suit it. Change any one of those and the order changes. That is not a weakness of the demo — it is the demo, and the dial is how you see it.
Push stiffness to with the same . Plain descent is now outside its own safety limit and leaves the map inside five steps; so does momentum, which inherits that limit and adds energy to it. The two adaptive methods do not notice. Drop to to rescue descent and it survives — and now crawls, because the stride that keeps the stiff direction stable is far too small for the gentle one. That is §1's impossible choice returning at scale.
The safe window for the shared stride is set by the stiffest direction; the number of steps is set by the softest. Their ratio is the condition number , and it is the tax that plain descent pays and the adaptive methods refuse to. AdaGrad, RMSProp and Adam all divide by a measurement of the slope's own size, so the size never reaches the stride — they cannot see at all.
That is the honest reason Adam and its cousin AdamW are the default for transformers and large language models. At that scale, slope sizes differ across layers by orders of magnitude, they drift while training, and the readings are noisy mini-batch estimates. Nobody is going to hand-tune a stride per layer. A method that self-scales, smooths and starts fairly is the practical pick — not because it wins a race on a two-knob toy, but because it never needed the race to be fair.
You make the valley a hundred times stiffer ( up by ) and leave everything else alone. What happens to plain gradient descent's largest usable stride?
On the same stiffer valley, why do AdaGrad, RMSProp and Adam keep working without you touching ?
If you want the algebra · 1 proof, step by step
Claim. On the stride that minimises the worst per-step factor is , and at that stride every coordinate shrinks by at best per step, where .
Then someone builds a wall
Find the smallest value of — but you may only pick . Do it now, before reading on. The bowl bottoms at , that point is banned, so you slide as close to it as the rule lets you and stop at , where . It took three seconds, and you just broke every method in this course. At the slope of is . Not zero. Four. Every technique you have — set the derivative to zero, walk until the tilt vanishes, check the Hessian — is hunting for a flat spot that is not there.
Slide the wall and watch the readout flip. While the wall sits at it is not in your way: the free answer survives and the slope there is zero, the old world. The instant three things happen at once, and they happen in almost every constrained problem you will ever meet.
One: the free answer is thrown away. The rule did not adjust the answer, it replaced it. Two: the new answer sits exactly on the edge of the allowed set, not comfortably inside it. Three: the gradient at the answer is not zero, and it points straight into the wall — which is precisely why you cannot move.
Point three is the whole reason this half of the unit exists. We need a new test for "I have arrived", one that says: the slope is nonzero, but every direction that would use it is blocked.
Before we can build that test, everything has to be written in one shape. Open the standard form tab. Two mechanical moves do it. A becomes a by multiplying through by . Everything else moves to the left of the sign.
Three roles, and this unit gives each a name you can picture. is the score — the number you want small. is the path — a line you must sit exactly on. Each is a fence — a wall you must stay behind. So is written , and its gradient is . Keep that minus sign. More answers are lost to that sign than to any other step in the topic.
One last piece of the shape, and it looks like pedantry until you try to break it. You will never see a strict . Try to minimise subject to . Is the answer? No — is allowed and smaller. Is ? No. You can keep going for ever, getting closer to without ever being allowed to reach it. The problem has no answer at all. Including the boundary is what makes the answer exist — and since the answer almost always sits on the boundary, a form that excluded it would throw away the thing we came for.
Minimise subject to . Where is the answer, and what is the slope there?
If you want the algebra · 1 proof, step by step
Claim. subject to has infimum and no minimiser; replacing by makes the answer exist, at .
Pushing a box against a wall
Push a heavy box along a corridor at an angle, so it presses against the wall. While your push has any sideways component along the wall, the box slides. It keeps sliding. It stops only at the instant your push is square-on — when nothing you are doing runs along the wall any more, and all of it goes into the wall. That is not a fact about boxes. It is the stopping condition for every constrained problem, and it is the first of the five conditions we are building.
Drag the point around the fence and watch the bar. The downhill arrow has been split into two pieces: the part that runs along the fence, and the part that pushes across it. While the along-part exists you are not finished — slide that way and the score improves, legally, without ever leaving the allowed set. The bar shrinks as you approach the answer and reaches zero exactly at it.
When the along-part is gone, all of points across the fence. And there is only one direction that is "across the fence": the fence's own gradient , which points out of the allowed side. Two arrows pointing along one line is not a vague picture — it is an equation.
Parallel — not equal. The two arrows almost never have the same length, and is the stretch factor between them. Writing "" is the single most common slip in this topic, and the widget shows you the two lengths side by side so you can see how different they are: on the straight fence and , a stretch of .
There is a second way to read the same picture, and it is worth having both. The level curves of are the score's contour lines. Shrink them until the smallest one still touches the allowed set. It touches — it does not cross — and at a touching point two curves share a tangent, which means their normals lie on one line. Tangency and "nothing left to slide" are the same statement seen from two angles.
Open the budget circle tab, because you have been doing this for months without being told. Ridge regression is usually taught as "minimise the error plus ". Its honest original form is a constrained problem: minimise the training error subject to — a budget on how large the coefficients may grow. The grey rings are the error, the red circle is the budget, and the answer is where the smallest reachable ring touches the circle. That picture is the entire geometry of ridge, and the in your notes is the stretch factor at that touching point. Lasso is the same picture with a diamond instead of a circle — and corners are exactly where coefficients become zero.
At a candidate point on a fence you find that has a component of size running along the fence. What does that tell you?
If you want the algebra · 1 proof, step by step
Claim. At a minimum sitting on an active fence (with ), the component of along the fence must vanish, hence for some .
Turn the wall into a fine
We know how to optimise a function with no rules: differentiate, set to zero. So the plan is to get rid of the rules. And there is exactly one way to get rid of a rule without changing the answer: charge for breaking it. Put a guard at the fence. Cross it and you pay rupees per metre past it; stay behind it and you pay nothing. Now there is no fence — only a bill. You want the bill small. The guard, who would love you to stray, wants it large. That tug-of-war is the whole method.
The first honest attempt at that bill is a wall written as a function: charge inside and outside. It is perfectly correct — any illegal point now scores infinity, so the unconstrained problem has exactly the same answer as the constrained one. It is also useless, because you cannot differentiate a vertical cliff, and differentiating is the only thing we know how to do.
So look at the top panel and do the one thing that saves the method: put a straight line under the wall and raise its slope. The line is zero at the fence, harmless on the allowed side (where makes it negative or zero), and climbing on the banned side. It is not the wall — it is always below the wall — but as grows it does more and more of the wall's job. And the wall is exactly what you get if you let the guard pick the worst for you:
The infinite wall, rebuilt out of straight lines. Obey the fence and the guard's best move is , so you pay nothing; break it and the guard sends up without limit. That one line is why the Lagrangian — score, plus a fine for leaving the path, plus a fine for crossing each fence — is not an approximation of the constrained problem. It is the constrained problem, with the rules relaxed into prices.
Two sign rules come out of the same picture, and they are not conventions.
Every fence fine must satisfy . Drag below zero in the top panel and watch: the line now dips below zero on the banned side, so crossing the fence would lower your bill. The optimiser would sprint out of bounds on purpose — and the widget draws it doing exactly that. A fine has to raise the bill, never lower it. This rule has a name, dual feasibility, and you have just seen the whole of it in one drag.
The path fine is free. Any sign. The path constraint is , and you can drift off it in either direction; both directions are equally illegal, so the fine has no natural sign. You will find negative 's constantly and they are correct. Forcing will make you find nothing.
The lower panel is the same idea on a real problem: behind a fence at . Slide and watch — a perfectly ordinary unconstrained minimisation, one you could do in your sleep — climb towards , the true constrained answer, and touch it exactly at . At that price, the straight line does the whole wall's job.
Why is a negative fence multiplier forbidden, when a negative on the path is perfectly fine?
You are minimising subject to one fence, and your candidate point sits comfortably inside the allowed region. What does the guard charge?
If you want the algebra · 2 proofs, step by step
Claim. — the indicator of the fence, exactly.
Claim. If some were allowed, the minimiser of would be pushed outside the feasible set on purpose, and the construction above would fail.
Room left, and the rule that falls out of it
Stand somewhere legal and measure the one number the Lagrangian keeps ignoring: how much room you have left before you touch the fence. If there is room, the guard has no grounds to charge you. If there is no room, the guard may charge whatever the geometry demands. That sentence is a theorem, and the way to prove it is to give the room a name and differentiate with respect to it.
Here is the move. The fence is an inequality, and calculus is bad at inequalities. So turn it into an equation by adding the room:
Why squared? Because writing with would just swap one inequality for another. A square is never negative by construction — the rule is built into the algebra instead of sitting beside it as a condition — and it stays smooth, so we can still differentiate. Nothing is lost: says exactly , back again.
And then the payoff falls out in four lines. appears in only inside , so ; multiply by and halve to get ; substitute . The name of the rule now makes sense: complementary slackness was derived from the slack.
A product of two numbers is zero only if one of them is. So for every fence, exactly one of two worlds holds — and the widget's greyed-out quadrant is the world that cannot exist.
Room to spare. : you are strictly inside. The guard has no grounds, so . The fence is inactive, or slack — it is doing no work, and deleting it entirely would not move the answer.
Touching. : you are pressed against the edge. Now is free to be positive, and usually is. The fence is active, or tight, and it is holding you back.
Two traps live here and both are easy. The first: "the fence is active" and "we are on the boundary" are the same world, not two — active means means on the boundary. The real split is fine is zero versus fence is touched. The second, and it costs more marks: on the boundary the fine is not forced to zero. With the product is zero for any at all. A positive fine on an active fence is the normal case; in two sections you will meet a problem whose answer sits on the fence with .
And the multiplier is not bookkeeping. It is a price: relax fence by a small amount and the best score improves by about . A fence with is a fence you would pay nothing to remove — because it was never in your way. We will cash that in at §13.
At the optimum you find for the third fence. What can you conclude about ?
If you want the algebra · 1 proof, step by step
Claim. Writing each fence as and differentiating with respect to gives .
Five conditions, and a branching interrogation
Here is the anticlimax that makes this topic learnable. The famous KKT conditions — Karush, Kuhn and Tucker — are not a new idea. They are the oldest idea in the course, set every derivative to zero, run on the Lagrangian with the slack variables in it. Differentiate with respect to each kind of unknown in turn and each condition falls out, one per kind. Only the last one has to be added by hand.
Four of the five are derivatives. The fifth is §9's guard argument, and no derivative will ever give it to you. Note what condition 1 is: it is §8's two-arrows-on-one-line, written for many rules at once. And note that is absent from the sign rule. It stays free.
Now the part that turns this into a procedure you can actually run. Condition 4 is one product per fence, and a product being zero offers two branches: the fine is zero, or the fence is touched. Guess a branch for every fence, solve the resulting equations, and let conditions 2, 3 and 5 throw out the guesses that lie. Work through the four branches yourself:
Three of the four cases died, and notice how they died — each one is a different lesson. Case 2 and case 3 produced a perfectly well-formed answer and then returned a negative multiplier, and . That is not a sign convention to be fixed; it means the case you assumed is impossible — the fence would have to pull you towards it rather than push you away. Discard and move on. Case 4 never even got that far: it broke the path before any fine rate was computed. And the surviving case returned , negative, and perfectly legal, because was never sign-restricted.
The branches multiply. Each fence doubles the count, so fences give cases — and the classic slip is to write . The two agree at (both ) and at (both ), which is exactly why the mistake survives; they part company at , where the truth is , not . Equality constraints add no branches at all: the path is always tight and is never forced to zero.
Three honest footnotes about that count. Branches overlap — a point can have and at once, and will then turn up in two of them; finding the same point twice is normal. A branch may yield no solution, one, or a whole family, so counts branches to check, not candidates you will collect. And grows viciously: ten fences give , and a support vector machine has one fence per training point. Nobody solves a real one by listing cases. The case list is a hand tool; §13 is the algorithm.
While testing a case you assumed active, the algebra returns . What do you do?
A problem has one equality constraint and three inequality constraints. How many cases does complementary slackness create?
If you want the algebra · 1 proof, step by step
Claim. Setting every partial derivative of to zero yields conditions 1–4, and condition 5 is the sign rule of the previous drawer.
Which problems are honest
You now have a test that finds candidates. When is a candidate the answer? There is a physical test you can do on any graph with a piece of string. Stretch it tight between two points on the curve. If the string never sags below the curve — if the curve always stays on or under its own chords — the function is a bowl, and a bowl has exactly one bottom. Stretch the string on a curve with two dips and it cuts straight across the hump: not a bowl, and everything gets harder.
Drag the two points and read the two numbers. The point on the chord sits at height ; the point on the curve directly below it sits at . If the second is never above the first, you have a convex function.
Then switch to the tangent tab, which is the same fact in a different pose: lay a tangent line at any point and let it run. For a bowl the tangent is a global under-estimate — the curve never dips below it anywhere. Run the sweep on both tabs and they agree on every curve, every time; on the chord test fails times in sampled pairs, on it fails in of them.
Chord above the curve, on the left; tangent below the curve, on the right. Same property, two poses — and the right-hand one is the useful one, because it says a local reading of the slope is a global promise. That is the whole reason convexity matters: on a bowl, what you can measure at your feet constrains the entire landscape.
The same test applies to sets, on the third tab: a set is convex when the segment joining any two of its points stays inside. A disc passes; a crescent and a ring fail. So a convex problem means a bowl objective, bowl fences, linear path — and then the allowed region is convex too, and there is nothing to get trapped in.
Now collect the payoff, stated carefully, because the two halves of it are constantly confused.
KKT is necessary — every true answer must pass the test — provided the constraints are well behaved where the answer sits. The technical name is a constraint qualification, and the common one is that the gradients of the active constraints are linearly independent there. Two active fences with parallel gradients break it, the multipliers may fail to exist, and the test can miss the answer entirely.
KKT is sufficient only if the problem is convex. For convex , convex and linear , a point passing all five conditions is the global minimum, full stop, no second check. For a non-convex problem it might be a maximum or a saddle, and you must verify some other way. So never write "all five conditions hold, therefore this is the minimum" without saying which part is convex.
Two shapes cover most of what you will meet, and both are convex. A linear program has a linear score and linear rules: subject to . A quadratic program has a bowl score and linear rules: subject to . Ridge, lasso and the support vector machine are all quadratic programs. Their duals come out in closed form, and both are worked in the drawer below.
You run the five conditions on a problem and one point passes all of them. Is it the minimum?
If you want the algebra · 2 proofs, step by step
Claim. If for all , then for all .
Claim. For s.t. the dual is s.t. ; for s.t. with invertible it is s.t. .
Who moves first — and what a wall is worth
Two people share one number: you pick and want the bill low, the guard picks and wants it high. Everything about duality comes from one question nobody asks in the algebra — who moves first? If you choose and the guard answers, that is one game. If the guard announces the price and you then choose knowing it, that is a different game, and it is a worse deal for the guard. Moving second is an advantage. Whoever gives it up loses something.
Put both games on paper. If you move first, the guard sees your choice and answers with the worst for you — which, as §9 showed, is when you obeyed the fence and when you did not. So the min-max quietly scores every illegal point at infinity and every legal one at its true score: it is the original problem.
Left, the primal: you move first. Right, the dual: the guard moves first, and the inner part is the dual function — an ordinary unconstrained minimisation with no left in the answer. The inequality is weak duality and it is always true, for every problem, convex or not. The shortfall is the duality gap, and when it is zero we have strong duality.
Now open a bundle of lines, because this is the picture that explains why anybody bothers. Fix any and look at as a function of : it is a straight line, with height and slope . One line per . The dual function is the lowest of all of them — and the lowest of any bundle of straight lines always bends downward.
So is concave. Always. However lumpy, non-convex, multi-valleyed and awful and are, the view from below is a single hill with one peak and no local traps. Maximising it is a well-behaved problem when the original is not. (Say that carefully: the dual function is concave; the dual problem, maximising a concave function, is a convex optimization problem. Both statements are right and they are about different objects.)
Three reasons this matters, and the third is the one that decides this course. Fewer unknowns: the primal has one variable per parameter, the dual has one per constraint — swap a thousand-variable primal for a three-variable dual and the work collapses. No local traps, by the paragraph above. And the variables change meaning: in a support vector machine the primal is over the weight vector, whose length is the number of features, while the dual is over one multiplier per training point. That swap is what lets kernels in, and it is why we spent this session here.
Does the gap ever actually open? Yes — and it is worth seeing both outcomes. On the gap tab, two allowed bands is a genuinely non-convex problem whose feasible set is two separate intervals, and its gap closes anyway: . Two wells is non-convex and does not close: while , a gap of . Read the lesson in the right direction. Weak duality is free. Convexity plus a strictly feasible point is sufficient for the gap to close — not necessary. Sometimes you get lucky; you just cannot count on it.
One thing remains: the multiplier itself. We have called it a stretch factor, a fine rate, a price. Make that literal.
Drag the wall. The answer slides along the path, the score rises, and the chip compares two numbers: what the multiplier predicted and what actually happened. At the answer is with and . Move the wall back to and the multiplier says the score should fall by about , to . Re-solve properly and the truth is , giving .
The multiplier is the slope of the value function — how much the best achievable score changes per unit of relaxation. It is exact for an infinitesimal move and approximate for a real one (the discrepancy above is the curvature of the value curve). And watch what happens as you slide the wall left past : the fence stops biting, drops to , and the value curve goes flat. The price of a wall you are not touching is nothing — which is complementary slackness, arriving from the economics side.
That reading is why multipliers appear all over applied work under the name shadow price. The in ridge regression is the price of the coefficient budget. In a resource allocation, is what one more machine-hour is worth to you — before you buy it. It is not bookkeeping left over from a derivation; it is the answer to the question you were going to ask next.
A colleague computes the dual of a horrible non-convex problem and gets . What have they proved about the primal answer ?
At the optimum of a resource problem, the multiplier on the "at most 40 machine-hours" constraint comes out as . Your supplier offers you an extra hour. What is it worth?
If you want the algebra · 3 proofs, step by step
Claim. For any function of two arguments, .
Claim. is concave in , whatever and are.
Claim. Let subject to . Then — relaxing the fence by improves the best score by about .
Two points and a line — where all of this is going
One number line. Two labelled points: is a positive, is a negative. Draw the boundary that separates them with the widest possible gap. You already know where it goes. What you may not know is that finding it uses every single thing in this half of the unit — standard form, the Lagrangian, stationarity, the dual, and complementary slackness — and that the last one explains why these machines are called support vector machines.
The trick is the translation. "Widest gap" sounds like a maximisation with no obvious objective, so rescale the boundary until both classes clear it by at least : . The margin's width is then , so making the gap widest means making smallest — and minimising subject to two fences is an ordinary quadratic program. Slide on the first tab and watch the two constraints go red the moment : is the smallest value that still clears both.
Now do it the other way, through the dual, because that is how it is actually solved. Stationarity in gives ; stationarity in gives . Substitute both back and the two primal variables vanish, leaving a one-variable concave problem:
and then the classifier is rebuilt out of the multipliers: ; and since , complementary slackness forces that point's constraint tight, , so . Boundary at , margin edges at , width . This is the general rule with , written out for two points.
Then the sentence this whole half of the unit was built for. Drag the third point on the last tab. While it sits out at , comfortably beyond the margin, its constraint is slack — — so complementary slackness forces . The classifier does not move. You could delete that training point entirely and get the same machine. Drag it inside the margin and its multiplier comes alive, the boundary shifts, and it becomes load-bearing.
That is what "support vector" means: the points whose constraints are tight, the ones with , the only ones carrying the answer. A million training points, a handful of multipliers that are not zero, and the rest could be thrown away. The sparsity of a support vector machine is complementary slackness, and nothing else. It is also why the dual is the form people solve: one multiplier per training point, most of them zero, and the data entering only through products — which is the doorway that kernels walk through.
Units 13 and 14 are that door. You now have the key.
A trained classifier reports for of its training points. What does that mean geometrically, and what may you do with those points?
If you want the algebra · 1 proof, step by step
Claim. For (class ) and (class ), minimising subject to has dual with , giving , , boundary and margin width ; and a third point at gets .
What to carry forward
Two halves, one thread. The first half fixes the walker because one stride can never suit two directions; the second half admits that sometimes the place you want to stand is not allowed, and builds a test for arriving where the ground is still tilted.
| The picture | What it says | The line of math it becomes |
|---|---|---|
| Walking blindfolded | feet feel the tilt, never how long it lasts; one stride, two factors | |
| The loaded trolley | agreeing pushes stack, alternating pushes cancel; speed costs overshoot | ; speed-up |
| The permanent record | a stride per knob out of its own history; first step is exactly , then the brake never lifts | ; step |
| Form, not career average | forget at rate and the stride survives; the zero start puffs step 1 | ; inflation |
| Two notebooks | signed average over root squared average; disagreement cancels, loudness divides out | |
| The race | the stiffest direction sets the safe stride, the softest sets the step count | ; cost |
| The wall | the answer moves onto the boundary, where the gradient is not zero | s.t. |
| The box in the corridor | you stop when nothing of runs along the fence | , parallel not equal |
| The guard's fine | an infinite wall rebuilt out of straight lines; a negative fine pays you to trespass | |
| Room left | name the room as a square and differentiate: fine and spare room never coexist | |
| The interrogation | each fence is active or not; guess, solve, discard on a negative multiplier | five conditions; branches |
| The string test | never above its chords, never below its tangents; then a candidate is the answer | |
| Who moves first | moving second is an advantage; the view from below is a bundle of lines, so always a hill | ; concave |
| The price of a wall | the multiplier is the slope of the value function; untouched walls cost nothing | |
| Two points and a line | the classifier is built from the multipliers, and almost all of them are zero | ; deletable |
Divide by what you have felt, and price what blocks you. Every adaptive method is the same move: measure how loud a knob's slopes have been, divide its stride by that, and the curvature never reaches the step size — momentum adds memory so agreement compounds, forgetting keeps the brake from becoming a life sentence, and Adam does all three with a start-up correction that retires itself. Every constrained method is the other same move: replace each wall by the cheapest straight line that does its job, and the price of that line tells you three things at once — which way the answer is pinned, whether the wall matters at all, and exactly what you would pay to move it.
Practice arena — fourteen problems, solved in full
Fourteen problems, easy to hard, across both halves: descent on a two-knob fit and recovering the stride from where it landed, four logged runs read backwards, exact line search, momentum's hyperparameters recovered from three numbers, AdaGrad against RMSProp on a long slope, RMSProp in vector form on badly scaled columns, Adam by hand with its bias correction — then framing a word problem, standard form and the branch count, a quadratic form on the unit circle where the multiplier is the eigenvalue, a fence tested both ways, the full four-case enumeration, a primal-and-dual round trip with the shadow price, and a two-point classifier built from its multipliers. Every number is machine-verified.
Three habits do most of the work. For any optimizer question, tabulate before you calculate — one row per step, columns for the gradient, the accumulators and the new point, in that fixed order; nearly every lost mark is a value used one step out of date. For any constrained question, write the standard form first and keep the minus signs — is , so . And never stop at the first case that works: test every branch, or say in writing why a branch is impossible.
A straight line is fitted to the two points and by minimising . (a) Derive and in simplest form and write the two update lines. (b) From with , run two iterations; report , and the loss after each. (c) A second run started from the same with a different rate and landed at after one step. Recover that rate and check it on both coordinates. (d) From the Hessian of , give the two eigenvalues, the largest safe rate, and decide whether is safe — and by how much.
The five rules used throughout this set. All start from the current point with ; squares, roots and divisions of vectors are taken element by element; only prevents division by zero and is dropped in hand calculation.
| method | rule |
|---|---|
| gradient descent | |
| momentum | |
| AdaGrad | |
| RMSProp | |
| Adam |
What this tests. Chain rule into a gradient, the plain rule run without slips, the fact that one step is exactly times the gradient vector — so a landing point hands back — and the speed limit . Plan. Differentiate each square by the chain rule and collect; then per iteration in this order: gradient at the current point, update both knobs with that same gradient, loss at the new point; for (c) write one step with unknown and solve from each coordinate; for (d) read trace and determinant off the Hessian.
Show the full solution
| 0 | |||
| 1 | |||
| 2 | — |
answers at a glance: (a) , . (b) ; , ; , . (c) , from both coordinates. (d) ; safe for ; is unsafe by .
One step is exactly times the gradient vector, which is why a landing point gives back — and why both coordinates must agree. The classic slip is updating first and then using the new inside the -gradient: both knobs must move on the same old gradient. The second slip is testing safety against ; the speed limit is set by the steepest direction, .
Four runs on were logged, all starting from . A: . B: . C: . D: . (a) Three of the four are plain gradient descent. Name them, give each one's , and list the five bands of behaviour of on this loss. (b) Name the odd run out, recover its and its (momentum, ), and verify them on its third step. (c) Re-run B with the decaying rate : give and . (d) Give the first with and that ; the percentage drop from ; and the first at which the factor turns positive, so the sign stops flipping.
What this tests. Diagnosis: on every plain run is a geometric sequence, so the ratio is the fingerprint, and a run whose ratio drifts must be carrying the loaded trolley. Plan. Divide each term by the one before; a constant ratio identifies plain descent and gives from ; for the drifting run use to get from step 1 alone, then from step 2, then check step 3; finally do the decay arithmetic with two inequalities.
Show the full solution
| run | ratios | behaviour | ||
|---|---|---|---|---|
| A | monotone | |||
| B | oscillating, shrinking | |||
| C | diverging | |||
| D | — | — | not plain |
| range of | factor | what happens |
|---|---|---|
| in | monotone descent | |
| lands on in one step | ||
| in | oscillates, still converges | |
| permanent oscillation | ||
| diverges |
answers at a glance: (a) A, B, C are plain, with ; bands monotone, one step, oscillating convergence, permanent oscillation, divergence. (b) D is momentum with , ; step-3 check . (c) ; . (d) , ; drop; the factor turns positive at .
On a quadratic, plain descent is a geometric sequence — so always divide consecutive iterates first. A constant ratio means plain descent and hands you ; a drifting ratio means something is carrying memory. The slip is trying to fit from step 1, where the trolley is still empty and cannot appear: step 1 gives , step 2 gives , step 3 checks them both.
Let , which is with and ; start at , where . (a) With direction , show it is a descent direction, write , minimise it exactly, and give and . (b) Take and repeat: give , , and . (c) Derive the closed form and evaluate it for (a) and (b). (d) Give the exact minimiser and , and the amount by which still exceeds . Also verify the free check and .
What this tests. That "how far do I walk?" is itself a one-variable minimisation, that on a quadratic it has a formula, and that an exact line search always leaves the new gradient perpendicular to the direction just walked. Plan. Substitute the line into to get a parabola in ; set ; step; repeat once; then do the same substitution with symbols to get the formula, and finish with for the exact answer.
Show the full solution
answers at a glance: (a) descent since ; , , , . (b) , , , . (c) ; and . (d) , , excess ; both orthogonality checks give .
"How far?" is its own one-variable problem, and on a quadratic its answer is — slope over curvature, measured along the direction you are actually walking. Always spend the one line on : if it is not zero, the line search was not exact. The slip is minimising over instead of over the single number .
A run of momentum on starts at with ; the log records and , and nothing else. (a) Recover and , in that order, saying why the order is forced. (b) Continue the run: give , , , , and . (c) Run plain gradient descent from with the same for four steps, and give the two distances from the target after four steps — one for momentum, one for plain descent — saying which is past and which is short.
What this tests. Reading the loaded trolley backwards: makes the first step pure descent, so falls out alone and shows up only at step 2 — and then whether you can see the overshoot that memory buys. Plan. One step with unknown; one step with unknown; then roll the recursion forward two more rows; finally run the plain map four times and subtract.
Show the full solution
| 0 | |||
| 1 | |||
| 2 | |||
| 3 | |||
| 4 | — | — |
answers at a glance: (a) (from step 1, where hides ), then . (b) , , ; , , . (c) plain run ; momentum ends past the target, plain descent short of it.
is the crack that lets you read a momentum log backwards: step 1 is pure descent and gives ; only step 2 can give . The slip is fitting both at once from step 2 and getting a whole family of answers. The second thing to keep: momentum overshoots by design — the trolley keeps rolling after the slope has flattened — which is exactly what makes it fast in a long valley and jumpy near the bottom.
A single weight sits on a long, perfectly straight slope: at every iteration. Take and ignore . (a) Give AdaGrad's accumulator in closed form, show its step size is , and give the first four step sizes. (b) Give the first at which AdaGrad's step has fallen below of . (c) For RMSProp with , prove by unrolling the geometric series, then give the first four step sizes and the value they approach. (d) Give the two limits as and the step each method takes at , plus the ratio between them.
What this tests. The permanent record against form-not-career-average, on the one input where they visibly disagree: a slope that never changes. Plan. Sum copies of for AdaGrad and cancel against ; for RMSProp unroll into a geometric series and use ; then two limits and one division.
Show the full solution
answers at a glance: (a) , step : . (b) from . (c) , step : . (d) limits and ; at , versus , a ratio of .
Both methods divide by a root of remembered squares; the only difference is whether the memory is a permanent record (AdaGrad, sum) or recent form (RMSProp, fading average). On a constant slope that difference is against — a brake that never lifts, against one that lifts after a few steps. The slip is thinking AdaGrad's shrinking step means "converging": here nothing has converged at all, the walker has simply been throttled.
A model is fitted to two rows, and , with . (a) Write in terms of the residuals and evaluate at . (b) Give , the range of for which plain descent is stable, the optimum , and — at — the first move of , its per-step contraction factor, the number of steps it needs to close of its gap, and what does in one step. (c) Run RMSProp with , for two steps, showing , and the step vector each time. (d) Give after two RMSProp steps and after two plain steps at , and the ratio.
What this tests. The whole reason per-weight step sizes exist: one column is ten times bigger than the other, so the curvature ratio is a hundred, and one shared rate cannot serve both. Plan. Residual times feature, summed, gives the gradient; gives the curvature and the speed limit; then run RMSProp in vector form keeping every intermediate to six decimals — the point is that its two steps come out equal on the first iteration even though the gradients differ by a factor of .
Show the full solution
answers at a glance: (a) , . (b) , stable for , ; at : , factor , steps for , and 's factor is so it lands in one step. (c) ; . (d) versus , a ratio of .
Divide by the root of a remembered square and the gradient's size cancels — what is left is its direction, times a step the method sets for each weight separately. That is why RMSProp's first move is in every coordinate no matter how lopsided the columns are. The slip is fading the notebook with the new squared gradient on the first step and forgetting the factor: , not .
Three gradients were logged for one weight: . Run Adam by hand with , , , and . (a) Tabulate : first the two correction denominators and , then , the ratio and . (b) Give the three iterates plain gradient descent would have produced at the same on the same gradients. (c) Give the three Adam step sizes, and give the number together with the two averages that produced it — say which average can cancel and which cannot.
What this tests. The two notebooks and the probation rate, in full arithmetic: a signed average on top, a squared average underneath, and a start-up correction that makes step 1 honest. Plan. Compute the two denominators first — they are the same every run and are where most slips live — then one row at a time; never reuse a corrected value in the next row's recursion (the recursion runs on the raw ).
Show the full solution
| ratio | ||||||
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | ||||||
| 3 |
answers at a glance: (a) denominators and ; , , . (b) plain descent gives . (c) step sizes ; , small because the signed average nearly cancelled while the squared average could not.
Adam divides a signed average by the root of a squared average: disagreement shrinks the numerator but never the denominator, so conflicting gradients automatically produce small steps. The probation correction is what makes step 1 come out at exactly . The slip is feeding the corrected back into the next row — the recursion always runs on the raw , and the correction is applied fresh each time.
You have metres of fencing and want to enclose the largest possible rectangular plot. (a) Name the decision variables, the objective and the constraint, and reduce the perimeter equation to its simplest form. (b) Solve with one multiplier: give , , and the area , and confirm it is a maximum by eliminating one variable. (c) The fencing budget rises to metres. Give the new optimum and area, the gain the multiplier predicts, the gain that actually occurs, the difference between them, and the exact value function together with its slope at .
What this tests. Framing — what may I choose, what do I want, what limits me — and then the multiplier's second life as the price of a wall: how much the best attainable value improves per unit of extra budget. Plan. Three sentences of framing, then and the constraint; then re-solve at the new budget and compare against the true jump, and explain the difference with the value function.
Show the full solution
answers at a glance: (a) variables ; subject to . (b) , , m². (c) new optimum with ; predicted gain , true gain , difference ; with slope at .
The multiplier is not a bookkeeping nuisance — it is the price of one more unit of budget, , available before you re-solve anything. The slip is expecting that price to be exact for a large change: it is a slope, so it captures the straight-line part and misses the curvature (here predicted against delivered). The second slip is forgetting to divide the perimeter by and carrying , which scales by a half.
(a) Put each of these into the standard form subject to , keeping every sign explicit and giving the gradient of each converted rule: (i) ; (ii) ; (iii) ; (iv) ; (v) ; (vi) — for this last one, state what goes wrong and name the value that cannot be attained. (b) Complementary slackness splits the search into branches. Give the number of branches for fences, and say for which of the guess happens to agree with the true count and for which it fails, with both numbers. (c) For a problem with one path and no fences, name which of the five conditions are empty and write down what survives. (d) In the slack formulation with variables and fences, count the unknowns; evaluate for .
What this tests. The bookkeeping that everything else rests on — every rule pushed to the side, every maximisation flipped — and the size of the branching interrogation that complementary slackness sets up. Plan. Move everything to one side so the right-hand side is and the sense is ; negate the objective to flip a max; then count branches as per inequality and nothing per equality.
Show the full solution
| as written | standard form | gradient |
|---|---|---|
| not allowed | — |
answers at a glance: (a) ; ; ; ; ; is not allowed — the infimum is excluded, so no minimiser exists. (b) ; agrees at and , fails at (, not ). (c) fence feasibility, complementary slackness and are empty; and survive. (d) ; for that is .
Standard form first, every time: right-hand side , sense , maximisation negated. A that is not flipped puts the wrong sign on and then the fine comes out negative and the whole branch is thrown away for the wrong reason. And count branches as in the number of inequalities only — equalities never branch, because they are never slack.
Maximise and minimise with subject to . (a) Write and , impose , and simplify the resulting system to one familiar matrix equation. (b) Give the characteristic equation and both values of . (c) Give the maximum and minimum of and the unit vectors where each is attained, to six decimals. (d) Verify the maximum by direct substitution, showing the arithmetic, and verify that the two optimisers are orthogonal.
What this tests. That the tangency condition on the unit circle is the eigenvalue equation, and that the constrained values of a quadratic form are exactly the eigenvalues. Plan. Differentiate both sides, divide out the , read off ; then trace and determinant give the characteristic polynomial; then on a unit eigenvector, so the values need no further work.
Show the full solution
answers at a glance: (a) , , so . (b) , . (c) at ; at . (d) direct check gives ; dot product .
"Maximise a quadratic form on the unit sphere" is the eigenvalue problem wearing a different hat — which is exactly how the first principal component is found. Once you recognise , stop computing: on a unit eigenvector equals , so the answers are already on the page. The slip is forgetting to normalise: gives , not , because scales with .
Minimise subject to . (a) Put it in standard form and work both branches of the fine-or-no-fine split; say which branch dies and on which condition, give , check all five conditions, and give . (b) Write the Lagrangian and minimise it over for a fixed , confirming it really is a minimum. (c) Substitute back to get in closed form and say what shape it is. (d) Solve : give , and the gap ; recover from and verify complementary slackness.
What this tests. The same one-fence problem answered twice — once by the branching interrogation, once by turning the wall into a fine — and the fact that the two answers agree. Plan. Branch on versus and kill the loser on a named condition; then build by substituting the inner minimiser, and maximise the resulting parabola over .
Show the full solution
Branch 2, (pressed against the fence). Then , and stationarity gives All five conditions at : stationarity ✓; no path to check; fence feasibility ✓; complementary slackness ✓; ✓. So
answers at a glance: (a) branch gives and dies on fence feasibility (); branch gives , , all five conditions hold, . (b) , with . (c) , a concave (downward) parabola. (d) , , gap ; recovered and .
Rejecting a branch is progress, not failure — but you must name which condition killed it: here died on feasibility, and a branch that returns dies on the sign condition instead. The other thing to keep: the dual is built by substituting the inner minimiser back in, so it is a function of alone — if an is still visible in your , the substitution was not finished.
Minimise subject to , and . (a) Put it in standard form, say how many cases the interrogation has, and write the Lagrangian. (b) Write the two stationarity equations as expressions for and , and use the path to eliminate from the second. (c) Work all four cases: for each, give the point, the multipliers, and either the value of or the exact condition that rejects it. (d) Give and say why its sign is legal; give and verify directly what they claim about the two fences; and state why the surviving point is the global minimum.
What this tests. A complete four-case interrogation with one path and two fences, and the discipline of rejecting each losing case on a named condition rather than by eye. Plan. Standard form and the Lagrangian; differentiate once in and once in to get the two fines as formulas; then walk the four patterns in order, each time solving the small linear system the pattern leaves behind and checking what the pattern did not enforce.
Show the full solution
Case 3: , . Then , and Rejected on the same sign condition.
Case 4: both fences touched, and . Then so the point is not on the path at all. Rejected on path feasibility — and note this happens before any multiplier is computed.
| case | point | multipliers | verdict |
|---|---|---|---|
| 1 | survives, | ||
| 2 | rejected: | ||
| 3 | rejected: | ||
| 4 | — | rejected: off the path |
answers at a glance: (a) , , ; cases; . (b) , . (c) case 1 survives at , , ; case 2 , case 3 , case 4 . (d) is legal because paths are unsigned; with and ; convex, so it is the global minimum.
Every case must die of a named cause: infeasible point, or a negative fine. Those are the only two ways out. The classic slip is demanding — the sign condition belongs to fences alone, and a perfectly good answer gets thrown away when a negative is treated as an error. The second slip is forgetting to check the conditions the case pattern did not assume: assuming does not make true, it must still be verified.
Minimise subject to and . (a) Put it in standard form, write the Lagrangian and give the two stationarity equations. (b) Work both cases; give and , and say what kills the losing case. (c) Minimise over for fixed multipliers and substitute back to get , showing where each of the three quadratic coefficients comes from. (d) Give the dual Hessian, its determinant and trace, and both eigenvalues, and conclude the shape of . (e) Solve the dual: give , the gap, and the recovered . (f) The wall moves to : give the predicted new , the actual one, the exact value function for , its slope, and the slope's values at and .
What this tests. The full round trip — primal case analysis, dual construction, dual optimisation, recovery — and then the multiplier read as the price of a wall, including the point where the wall stops being worth anything. Plan. Two cases on the primal; then minimise in and separately, substitute, and collect coefficient by coefficient; then two linear equations for the dual optimum; finally differentiate the exact value function.
Show the full solution
Case . Then , and the path gives : All five hold — stationarity ✓, path ✓, fence ✓, ✓, ✓ — so
answers at a glance: (a) , ; , . (b) gives with , rejected; gives , . (c) . (d) , , , eigenvalues : concave. (e) , , , gap , recovered . (f) predicted , actual ; , slope , equal to at and at .
At the optimum the multiplier is the slope of the value function, so tells you what the wall is costing you before you re-solve. Follow that slope far enough and it hits zero, at the moment the wall stops touching the answer — after which relaxing it further buys nothing. The slip is quoting the dual optimum without checking : the dual problem is over , and an unconstrained stationary point with is not the dual answer.
A one-dimensional dataset has two points: with , and with . The largest-margin classifier solves subject to . (a) Write both constraints in standard form and give the Lagrangian with . (b) Give the two stationarity equations and reduce the Lagrangian to a function of a single variable. (c) Maximise : give , , , , the primal value, the gap, the decision boundary, the margin edges, the margin width, and the number of support vectors. (d) A third point with is added: give and say what happens to the classifier. Then, with a point at of class and the point at both binding, derive and as formulas in , and evaluate them, the boundary and the margin at .
What this tests. Every move of the unit chained together — framing, standard form, Lagrangian, dual, solve, recover, read the slackness — on the problem the whole subject is built toward. Plan. Write the two constraints out; differentiate in and in (the -equation is what collapses two multipliers into one); substitute to get a one-variable concave parabola; solve it; then use constraint tight to pin .
Show the full solution
answers at a glance: (a) , ; . (b) , ; . (c) , , , , primal , gap ; boundary , edges , width , support vectors. (d) and the classifier does not move; , ; at , , , boundary , margin .
Complementary slackness is why these classifiers are sparse: means the point sits strictly outside the margin and can be thrown away, while means its constraint is tight and it is holding the boundary up. The multiplier is the answer to "which data matter". The slip is solving for from stationarity — only gives and never mentions ; comes from setting a support vector's constraint to equality.