Consider a convex optimisation problem with inequality constraints:
minxf(x)subject tohi(x)≤0,i=1,…,m
The Lagrangian combines the objective and the constraints with Lagrange multipliers λi≥0:
L(x,λ)=f(x)+∑i=1mλihi(x)
where λ∈Rm, λ≥0 (elementwise). The multipliers penalise constraint violations: if hi(x)>0, the term λihi(x) adds a positive penalty.
The primal problem can be rewritten as:
minxmaxλ≥0L(x,λ)
If x violates any constraint (hi(x)>0), the inner max drives L→∞ by letting λi→∞. If x is feasible (all hi(x)≤0), the max over λ sets each λi=0 or keeps it at the boundary, recovering f(x). So maxλ≥0L(x,λ) equals f(x) when x is feasible and +∞ otherwise.
The dual function always lower-bounds the primal objective. Maximising g gives the best possible lower bound. The duality gapf(x∗)−g(λ∗) is always nonnegative.
Strong duality: Under certain conditions, f(x∗)=g(λ∗) — the duality gap is zero. For convex problems, Slater's condition is sufficient: if there exists a strictly feasible point (all hi(x)<0), then strong duality holds.
In practice, most convex ML problems satisfy Slater's condition trivially. Strong duality means we can solve either the primal or the dual and get the same answer — whichever is easier.
At the primal-dual optimum (x∗,λ∗) with strong duality:
λi∗hi(x∗)=0for all i
This is complementary slackness. For each constraint:
If hi(x∗)<0 (constraint is inactive/slack), then λi∗=0 (the multiplier for that constraint is zero)
If λi∗>0 (the multiplier is active), then hi(x∗)=0 (the constraint is tight/binding)
Complementary slackness tells us which constraints matter at the optimum. In the 1D example above: h(x∗)=1−1=0 (active), so λ∗ can be nonzero; indeed λ∗=1.
This is a quadratic program in n variables with box constraints. The number of variables is now n (number of examples) instead of d (feature dimension) — a win when d≫n.
Kernel trick preview: The dual depends on the data only through inner products xiTxj. Replacing xiTxj with a kernel K(xi,xj) allows SVMs to learn nonlinear decision boundaries without ever computing features in the kernel space explicitly.
Exercise · Multiple choice
If $h_i(x^*) < 0$ (the constraint is inactive) at the optimum, complementary slackness forces:
$\lambda_i^* = 0$
$\lambda_i^* > 0$
$h_i(x^*) = 0$
The dual to be infeasible
Question 1 of 4
Weak duality states that the dual objective is always ___ the primal objective for feasible points.