Duality and the Dual Problem
Every constrained optimisation problem has a shadow twin, built from the price of relaxing each constraint — solving that twin problem often turns out to be easier, and it always gives a certificate of how close your answer is to optimal.
Prerequisites: Convex Sets and Convex Functions, Lagrange Multipliers & KKT Conditions
You're building a minimum-variance portfolio subject to a target return and full investment. Solve it directly and you get a set of weights. But there's a second question hiding inside the same problem: how much would your minimum achievable risk improve if the return target were loosened by 0.1%? That second question — the sensitivity of the answer to the constraints — turns out to be answerable by solving an entirely different-looking optimisation problem, built out of the original one's constraints. That second problem is the dual, and remarkably, in the well-behaved cases finance cares about, solving it gives you the exact same answer as the original, plus that sensitivity information for free.
The analogy: renting out a factory's spare capacity
You run a factory that makes products under several resource constraints — labour hours, machine time, raw material. The direct question is: what production mix maximises profit? There's a second, seemingly unrelated question a landlord might ask: if I wanted to rent your spare labour hours and machine time from you, what's the minimum price per hour you'd need to be paid to make it not worth using them yourself? That minimum acceptable rental price for each resource is exactly the resource's shadow price — and remarkably, choosing shadow prices to make renting everything out just barely unattractive, and minimising the landlord's total payout, solves an entirely different optimisation problem whose answer matches your original profit-maximising production plan exactly. The production problem is the primal; the shadow-pricing problem is its dual.
Writing it down
Take a primal problem: minimise subject to . Introduce a Lagrange multiplier — a price for violating the constraint — and form the Lagrangian:
In words: instead of forbidding outright, charge a penalty of per unit of violation, folded directly into the objective. The dual function is what you get by minimising the Lagrangian over for a fixed :
In words: for each candidate penalty price , find the best given that price, and see how good the resulting objective is. The dual problem is then to choose the penalty price that gives the best (largest) such guarantee:
In words: find the shadow price that makes the "penalised" problem's best achievable value as large as possible — squeezing the guarantee as tight as it will go.
Two facts tie primal and dual together. Weak duality always holds: for any feasible and any — the dual's answer is always a lower bound on the true minimum, no matter what. Strong duality — the dual's best value exactly equals the primal's best value — holds for convex problems satisfying a mild regularity condition (Slater's condition: there exists a point that strictly satisfies every inequality constraint). When strong duality holds, the gap between primal and dual is exactly zero, and the optimal is literally the shadow price: how much the optimal objective would improve per unit of relaxing the constraint.
Think of the primal feasible region here as the ellipse this transform traces, and the dual as searching over prices for pushing that boundary outward. A convex, well-conditioned region (a round, not too flattened ellipse) is exactly the setting where strong duality reliably holds and the shadow-price interpretation is trustworthy.
Worked example 1: a one-variable problem, entirely by hand
Minimise subject to , written as . By inspection the answer is obvious: , . Now derive it via duality to see the machinery. Lagrangian: . Minimise over : . Plug back in: .
Maximise over : . Then .
The dual's best value is — exactly matching the primal's , confirming strong duality (this is a convex problem, Slater's condition holds trivially). The optimal multiplier is the shadow price: loosen the constraint to for tiny , and the new optimum is approximately — check directly: gives for small . It matches.
Worked example 2: shadow price of a return target, in a two-asset portfolio
Minimise variance subject to hitting a target return , i.e. a linear equality constraint. Solving the constraint directly: . Then , so minimum variance is (portfolio volatility ) at a target return of .
Now perturb the target return down slightly to : solving again, . New variance: . The variance dropped from to , a change of for a change in target return — a shadow price (the Lagrange multiplier on the return constraint) of approximately . In words: relaxing the required return by one percentage point buys back roughly percentage points of variance near this point — exactly the kind of trade-off number a portfolio manager wants when deciding whether a stricter return target is worth its risk cost, and it came directly from the dual variable rather than from resolving the whole problem from scratch at every candidate target.
What this means in practice
- It's how the support vector machine is actually solved. The SVM's dual problem, expressed entirely in terms of dot products between data points, is what makes the kernel trick possible — a computation the primal formulation can't offer directly.
- It gives a stopping certificate for numerical optimisers. The gap between a current primal guess and its corresponding dual bound (weak duality) tells a solver exactly how far it might still be from optimal, without needing to know the true optimum in advance.
- Lagrange multipliers price constraints in risk management. A binding position limit, leverage cap, or sector constraint in a portfolio optimisation has a dual price attached — literally what the desk would pay to have that constraint relaxed by one unit — used routinely to decide which limits are actually costly.
Every constrained optimisation problem has a dual: attach a price to each constraint, minimise the resulting penalised objective, then choose the price that makes that minimum as large as possible. For convex problems satisfying a mild regularity condition, the dual's best value exactly equals the primal's, and the optimal price is the shadow price — how much the optimal objective moves per unit of constraint relaxation.
The classic confusion is assuming strong duality — primal value equals dual value — holds automatically. It does not: it requires the primal problem to be convex, plus a regularity condition like Slater's (a strictly feasible point exists). For non-convex problems, only weak duality is guaranteed, and the dual value can sit strictly below the true primal optimum — a nonzero "duality gap" that no amount of further dual optimisation closes. Practically, this means Lagrange-multiplier "shadow prices" pulled from a non-convex model (many portfolio problems with cardinality constraints, integer constraints, or non-convex risk measures) cannot be trusted as literal per-unit trade-off numbers the way they can in a clean convex mean-variance setup — the gap between the dual bound and the actual achievable optimum needs to be checked, not assumed away.
Related concepts
Practice in interviews
Further reading
- Boyd & Vandenberghe, Convex Optimization (ch. 5)
- Bertsekas, Nonlinear Programming (ch. 5)