Convex Optimization
The class of problems where every local optimum is global, convex sets and functions, the first-order optimality condition, and Lagrangian duality with the weak/strong duality gap that underlies robust portfolio construction.
Prerequisites: Linear Algebra for Quants, Positive Semidefinite Matrices
The single most consequential fact in optimization is the divide between convex and non-convex problems. It is not a divide of difficulty in the usual sense, it is the divide between problems you can provably solve to global optimality, efficiently and reliably, and problems where you are forever unsure whether a better solution is hiding somewhere you didn't look. Nearly every well-posed quant problem, mean–variance portfolios, ridge and Lasso regression, SVMs, model calibration, is deliberately formulated to be convex, because convexity is what makes the answer trustworthy. Understanding why is the difference between using a solver and knowing what it guarantees.
Convex sets and convex functions
A set is convex if the line segment between any two of its points stays inside: for and , . Half-spaces, balls, the Positive Semidefinite Matrices cone, and any intersection of these are convex; the feasible region of linear constraints (a polyhedron) is convex.
A function is convex if its graph lies below its chords: Equivalently (for smooth ), the first-order condition , the function sits above every tangent plane, or the second-order condition that the Hessian is positive semidefinite everywhere, . That last test is the operational one and the direct payoff of PSD theory: a quadratic is convex iff . This is why portfolio variance , with necessarily PSD, is automatically a convex objective.
Why convexity matters: local = global
The reason to care is a single theorem with enormous consequences. For a convex objective over a convex feasible set, every local minimum is a global minimum. Proof sketch: if were a local but not global minimum, some feasible has ; convexity along the segment gives for small, contradicting local optimality. So there are no "traps", no spurious local minima, no dependence on the starting point, no wondering if more search would help. Gradient descent, interior-point methods, and their kin converge to the answer. Contrast non-convex optimization (training deep nets, combinatorial problems), where local minima proliferate and global optimality is generally intractable. Convexity is, bluntly, the boundary of what you can solve with confidence, which is why quants invest heavily in reformulating problems to expose hidden convexity.
The first-order optimality condition makes this concrete: for an unconstrained differentiable convex , is optimal iff . Over a convex feasible set , the condition generalizes to for all , the objective cannot decrease in any feasible direction.
The canonical form and duality
A convex optimization problem is with all convex and the equality constraints affine. The Lagrangian absorbs the constraints with multipliers ("prices") and : Minimizing over gives the dual function , and the dual problem is to maximize over . Two results give duality its power:
- Weak duality (always). The best dual value lower-bounds the primal optimum: for any feasible dual point. The gap is the duality gap. This holds even for non-convex problems, so the dual always certifies a bound.
- Strong duality (under convexity + Slater's condition). For a convex problem with a strictly feasible point, the gap closes: . Solving the dual solves the primal, and the optimal multipliers are exactly the Lagrange Multipliers & KKT Conditions that characterize the solution.
The economic content of duality is what makes it indispensable: the multiplier is the shadow price of constraint , the marginal improvement in the objective per unit relaxation of that constraint. In a portfolio problem, the multiplier on a risk budget is the marginal return you forgo per unit of risk limit, i.e. the implied price of risk. Duality also underlies robust optimization (worst-case-over-a-set reformulated as a tractable dual) and regularization (ridge/Lasso as the dual of norm-constrained fits, see Ridge and LASSO Regularization).
Worked example, minimum-variance portfolio
The cleanest convex problem in finance: find fully-invested weights minimizing variance, The objective is convex because ; the constraint is affine, a textbook convex program, so any stationary point is the global optimum. Forming the Lagrangian and setting gives , and normalizing to sum to 1, Because the problem is convex, this closed form is the global minimum-variance portfolio, no local-optimum caveats, no starting-point sensitivity. Add a return target and you get the full MPT (Harry Markowitz) efficient frontier, still convex, still globally solvable. The whole tractability of mean–variance investing rests on being PSD.
Failure modes and subtleties
- Non-convex reformulations sneak in. Cardinality constraints ("hold at most names"), integer lots, and minimum-position thresholds make portfolio problems non-convex (combinatorial); the convex machinery no longer guarantees global optimality, and you need branch-and-bound or convex relaxations.
- Convexity is not robustness. A convex problem is solved exactly, but if and are estimated with error, the exact solution to the wrong problem is confidently wrong, the notorious error-maximizing behavior of Markowitz. Convex solvability and statistical stability are different concerns; the fix is shrinkage, constraints, or robust (still-convex) reformulations.
- Strong duality needs a constraint qualification. Slater's condition (a strictly feasible point) is what closes the gap; degenerate or infeasible problems can have a positive duality gap even when convex.
- Ill-conditioning slows solvers. A near-singular (tiny eigenvalues) makes the problem numerically flat in some directions; the optimum is technically unique but practically unstable, regularize.
- "Convex" depends on formulation. Maximizing the Sharpe ratio is not convex as written but becomes a convex (or quasi-convex) problem after a clever change of variables; recognizing when a disguised problem is secretly convex is the real skill.
In interviews
The headline you must own: for convex problems, local optima are global, and know why (the chord/segment argument). Be able to state the Hessian-PSD test for convexity and connect it to why is convex (Positive Semidefinite Matrices). The minimum-variance derivation via a Lagrangian is a standard whiteboard problem, produce and note the convex problem guarantees it's global. Expect duality questions: weak duality always holds, strong duality needs convexity plus Slater, and the multiplier is a shadow price. A sharp interviewer probes the limits: "is Markowitz convex?" (yes) "then why does it produce crazy weights?" (estimation error, not optimization failure). This flows straight into Lagrange Multipliers & KKT Conditions, which supplies the exact optimality conditions for the constrained case.
Related concepts
Practice in interviews
Further reading
- Boyd & Vandenberghe, Convex Optimization
- Nocedal & Wright, Numerical Optimization
- Bertsekas, Nonlinear Programming