MathLabs

Applied and computational mathematics

Convex optimization

Minimizing convex functions over convex sets: why every local minimum is global, the KKT conditions that certify optimality, and the duality that turns a hard search into an easier one.

IntuitionWhy shape matters: convex versus non-convex

Imagine searching for the lowest point in a landscape by always stepping downhill. In a landscape shaped like a single bowl, this greedy strategy always finds the true lowest point, no matter where you start. In a landscape with several dips, ridges, and saddle-shaped passes, the same strategy can get stuck at a dip that is not the lowest point at all. Convex optimization studies exactly the "single bowl" case — and explains, precisely, why it is so much easier.

A 3D bowl-shaped surface (paraboloid) opening upward, with a single lowest point at the origin; the surface curves up in every direction from that point.
z=x2+y2z = x^2 + y^2: a paraboloid. Every direction curves upward, so there is exactly one lowest point.
A 3D saddle-shaped surface that curves upward along one horizontal axis and downward along the perpendicular axis, crossing at a flat point in the middle that is a critical point but not a minimum.
z=x2−y2z = x^2 - y^2: a saddle. The surface curves up along one axis and down along the other, so the flat point at the origin is neither a minimum nor a maximum.

A 1-D version of the same trap: a cubic curve can have a valley (local minimum) that is not the lowest point overall, because the curve keeps descending further out. Convexity is exactly the property that rules this out.

The cubic curve y = x cubed minus 3x, rising from bottom left, reaching a local maximum near x = -1, dipping to a local minimum near x = 1, then rising again; an inflection point is marked at the origin.
y=x3−3xy = x^3 - 3x. The marked points are a local maximum, a local minimum, and an inflection point — the local minimum is not the global minimum, since the curve goes to −∞-\infty as x→−∞x \to -\infty.

UndergraduateConvex sets and convex functions

Definition: Convex set

A set C⊆RnC \subseteq \mathbb{R}^n is convex if for every x,y∈Cx, y \in C and every θ∈[0,1]\theta \in [0,1], the point θx+(1−θ)y\theta x + (1-\theta) y also lies in CC: the whole segment between any two points of CC stays inside CC.

Definition: Convex function

A function f:C→Rf : C \to \mathbb{R} on a convex set CC is convex if for every x,y∈Cx, y \in C and θ∈[0,1]\theta \in [0,1], f(θx+(1−θ)y)≤θf(x)+(1−θ)f(y)f(\theta x + (1-\theta) y) \le \theta f(x) + (1-\theta) f(y): the graph of ff never lies above the segment joining any two of its points.

f(θx+(1−θ)y)≤θf(x)+(1−θ)f(y),θ∈[0,1]f(\theta x + (1-\theta) y) \le \theta f(x) + (1-\theta) f(y), \qquad \theta \in [0,1]

When ff is twice differentiable, this is equivalent to the Hessian ∇2f(x)\nabla^2 f(x) being positive semidefinite at every point of CC — the multivariable analogue of f′′≥0f'' \ge 0. A convex optimization problem minimizes a convex ff over a convex feasible set CC (for example, C={x:gi(x)≤0,hj(x)=0}C = \{x : g_i(x) \le 0, h_j(x) = 0\} with each gig_i convex and each hjh_j affine).

If ff is convex on a convex set CC and x⋆x^\star is a local minimum of ff on CC, then x⋆x^\star is a global minimum of ff on CC.

Why is it true?

Suppose x⋆x^\star is only a local minimum and some y∈Cy \in C has f(y)<f(x⋆)f(y) < f(x^\star). Convexity forces ff to lie below the segment from x⋆x^\star to yy arbitrarily close to x⋆x^\star: for small θ>0\theta > 0, f(θy+(1−θ)x⋆)≤θf(y)+(1−θ)f(x⋆)<f(x⋆)f(\theta y + (1-\theta) x^\star) \le \theta f(y) + (1-\theta) f(x^\star) < f(x^\star). That contradicts x⋆x^\star being a local minimum, since points θy+(1−θ)x⋆\theta y + (1-\theta)x^\star come arbitrarily close to x⋆x^\star.

Proof

Suppose x⋆∈Cx^\star \in C is a local minimum, so there exists a radius r>0r > 0 such that f(z)≥f(x⋆)f(z) \ge f(x^\star) for all z∈Cz \in C satisfying ∥z−x⋆∥≤r\|z - x^\star\| \le r. Assume for contradiction that there exists a point y∈Cy \in C with f(y)<f(x⋆)f(y) < f(x^\star).

For any θ∈(0,1)\theta \in (0, 1), convexity of the set and function ensures zθ=θy+(1−θ)x⋆∈Cz_\theta = \theta y + (1 - \theta)x^\star \in C and f(zθ)≤θf(y)+(1−θ)f(x⋆)=f(x⋆)+θ(f(y)−f(x⋆))<f(x⋆)f(z_\theta) \le \theta f(y) + (1 - \theta)f(x^\star) = f(x^\star) + \theta(f(y) - f(x^\star)) < f(x^\star).

Since ∥zθ−x⋆∥=θ∥y−x⋆∥\|z_\theta - x^\star\| = \theta \|y - x^\star\|, choosing 0<θ≤r∥y−x⋆∥0 < \theta \le \dfrac{r}{\|y - x^\star\|} guarantees ∥zθ−x⋆∥≤r\|z_\theta - x^\star\| \le r while f(zθ)<f(x⋆)f(z_\theta) < f(x^\star), contradicting that the point is a local minimum.

UndergraduateConstrained problems and the KKT conditions

For an unconstrained differentiable convex ff, x⋆x^\star is a global minimum if and only if ∇f(x⋆)=0\nabla f(x^\star) = 0. When there are constraints — minimize f(x)f(x) subject to gi(x)≤0g_i(x) \le 0 (i=1,…,mi=1,\dots,m) and hj(x)=0h_j(x) = 0 (j=1,…,pj=1,\dots,p) — we introduce the Lagrangian by attaching a nonnegative multiplier λi≥0\lambda_i \ge 0 to each inequality and a free multiplier νj∈R\nu_j \in \mathbb{R} to each equality:

L(x,λ,ν)=f(x)+∑i=1mλi gi(x)+∑j=1pνj hj(x)\mathcal{L}(x,\lambda,\nu) = f(x) + \sum_{i=1}^m \lambda_i\, g_i(x) + \sum_{j=1}^p \nu_j\, h_j(x)

For a differentiable convex problem satisfying a regularity condition (such as Slater's condition: there exists a point where all gi(x)<0g_i(x) < 0 and hj(x)=0h_j(x) = 0), a point x⋆x^\star is optimal if and only if there exist multipliers λ⋆,ν⋆\lambda^\star, \nu^\star such that: (1) stationarity ∇xL(x⋆,λ⋆,ν⋆)=0\nabla_x \mathcal{L}(x^\star, \lambda^\star, \nu^\star) = 0; (2) primal feasibility gi(x⋆)≤0g_i(x^\star) \le 0, hj(x⋆)=0h_j(x^\star) = 0; (3) dual feasibility λi⋆≥0\lambda_i^\star \ge 0; and (4) complementary slackness λi⋆gi(x⋆)=0\lambda_i^\star g_i(x^\star) = 0 for all ii.

Why is it true?

Complementary slackness says that an inequality constraint gi(x)≤0g_i(x) \le 0 either is inactive at x⋆x^\star (gi(x⋆)<0g_i(x^\star) < 0, so the boundary is not pushing on x⋆x^\star and its multiplier λi⋆=0\lambda_i^\star = 0) or is active (gi(x⋆)=0g_i(x^\star) = 0, so the wall can push back with force λi⋆≥0\lambda_i^\star \ge 0). Stationarity then states that −∇f(x⋆)-\nabla f(x^\star) is balanced by a nonnegative combination of the outward normals ∇gi(x⋆)\nabla g_i(x^\star) of the active walls.

Proof

First, suppose (x⋆,λ⋆,ν⋆)(x^\star, \lambda^\star, \nu^\star) satisfies the KKT conditions. Because λi⋆≥0\lambda_i^\star \ge 0 and the constraint functions are convex or affine, the Lagrangian x↦L(x,λ⋆,ν⋆)x \mapsto \mathcal{L}(x, \lambda^\star, \nu^\star) is convex, so stationarity ∇xL(x⋆,λ⋆,ν⋆)=0\nabla_x \mathcal{L}(x^\star, \lambda^\star, \nu^\star) = 0 implies that the candidate point minimizes the Lagrangian over all vectors.

For any feasible xx with gi(x)≤0g_i(x) \le 0 and hj(x)=0h_j(x) = 0, complementary slackness λi⋆gi(x⋆)=0\lambda_i^\star g_i(x^\star) = 0 gives the chain f(x⋆)=L(x⋆,λ⋆,ν⋆)≤L(x,λ⋆,ν⋆)=f(x)+∑i=1mλi⋆gi(x)+∑j=1pνj⋆hj(x)≤f(x)f(x^\star) = \mathcal{L}(x^\star, \lambda^\star, \nu^\star) \le \mathcal{L}(x, \lambda^\star, \nu^\star) = f(x) + \sum_{i=1}^m \lambda_i^\star g_i(x) + \sum_{j=1}^p \nu_j^\star h_j(x) \le f(x), proving global optimality.

Conversely, under Slater's condition, strong duality provides dual optimal multipliers such that f(x⋆)=g(λ⋆,ν⋆)=inf⁡xL(x,λ⋆,ν⋆)≤L(x⋆,λ⋆,ν⋆)=f(x⋆)+∑i=1mλi⋆gi(x⋆)≤f(x⋆)f(x^\star) = g(\lambda^\star, \nu^\star) = \inf_x \mathcal{L}(x, \lambda^\star, \nu^\star) \le \mathcal{L}(x^\star, \lambda^\star, \nu^\star) = f(x^\star) + \sum_{i=1}^m \lambda_i^\star g_i(x^\star) \le f(x^\star). Both inequalities in this chain must be equalities, which forces stationarity and complementary slackness for every constraint.

Example: Closest point on a line to the origin

Minimize f(x,y)=x2+y2f(x,y) = x^2 + y^2 subject to x+y=1x + y = 1.

Solution

Both ff (paraboloid) and the equality h(x,y)=x+y−1=0h(x,y) = x + y - 1 = 0 (affine) define a convex problem. The Lagrangian is L(x,y,ν)=x2+y2+ν(x+y−1)\mathcal{L}(x,y,\nu) = x^2 + y^2 + \nu(x + y - 1). Stationarity gives 2x+ν=02x + \nu = 0 and 2y+ν=02y + \nu = 0, so x=yx = y. Substituting into x+y=1x + y = 1 gives x⋆=y⋆=12x^\star = y^\star = \tfrac{1}{2} with minimum value f(x⋆,y⋆)=12f(x^\star, y^\star) = \tfrac{1}{2}. Because the problem is convex, this KKT point is automatically the global minimum.

Example: Active inequality constraint via complementary slackness

Minimize f(x)=(x−3)2f(x) = (x - 3)^2 subject to the inequality constraint g(x)=x−1≤0g(x) = x - 1 \le 0.

Solution

Form the Lagrangian L(x,λ)=(x−3)2+λ(x−1)\mathcal{L}(x, \lambda) = (x - 3)^2 + \lambda(x - 1). Because the objective is strictly convex and the constraint is affine, the KKT conditions are necessary and sufficient: stationarity ∂L∂x=2(x−3)+λ=0\dfrac{\partial \mathcal{L}}{\partial x} = 2(x - 3) + \lambda = 0, primal feasibility x−1≤0x - 1 \le 0, dual feasibility λ≥0\lambda \ge 0, and complementary slackness λ(x−1)=0\lambda(x - 1) = 0.

Test the two cases from complementary slackness: if λ=0\lambda = 0, stationarity gives x=3x = 3, which violates x−1≤0x - 1 \le 0.

Therefore the constraint must be active, giving x⋆=1x^\star = 1 and λ⋆=2(3−1)=4>0\lambda^\star = 2(3 - 1) = 4 > 0, which satisfies λ≥0\lambda \ge 0. The unique global minimum is x⋆=1x^\star = 1 with optimal value f(1)=4f(1) = 4.

AdvancedDuality and global optimization beyond convexity

Minimizing L(x,λ,ν)\mathcal{L}(x,\lambda,\nu) over xx (without constraints!) defines the Lagrange dual function g(λ,ν)=inf⁡xL(x,λ,ν)g(\lambda,\nu) = \inf_x \mathcal{L}(x,\lambda,\nu). Because gg is the pointwise infimum of affine functions of (λ,ν)(\lambda,\nu), gg is always concave, even if the original problem is not convex. For any λ≥0\lambda \ge 0 and any feasible xx, every term λigi(x)≤0\lambda_i g_i(x) \le 0 and νjhj(x)=0\nu_j h_j(x) = 0, so g(λ,ν)≤f(x)g(\lambda,\nu) \le f(x). Maximizing g(λ,ν)g(\lambda,\nu) over λ≥0\lambda \ge 0 gives the dual problem, whose optimal value d⋆d^\star always satisfies weak duality: d⋆≤p⋆d^\star \le p^\star (the primal optimal value). When d⋆=p⋆d^\star = p^\star, we say strong duality holds and the duality gap p⋆−d⋆p^\star - d^\star is zero.

If a primal linear program min⁡{c⊤x:Ax=b,  x≥0}\min\{c^\top x : Ax = b,\; x \ge 0\} has an optimal solution x⋆x^\star, then its dual max⁡{b⊤y:A⊤y≤c}\max\{b^\top y : A^\top y \le c\} also has an optimal solution y⋆y^\star, and the optimal values are equal: c⊤x⋆=b⊤y⋆c^\top x^\star = b^\top y^\star.

Why is it true?

Linear programs are convex problems with polyhedral feasible sets; for polyhedral constraints no interior-point assumption is needed, and the separating-hyperplane theorem (Farkas' lemma) guarantees a dual multiplier y⋆y^\star with zero duality gap. For general convex programs, strong duality holds whenever Slater's condition is satisfied.

Proof

For any primal feasible vector satisfying Ax=bAx = b, x≥0x \ge 0 and any dual feasible vector satisfying A⊤y≤cA^\top y \le c, taking inner products gives weak duality: b⊤y=(Ax)⊤y=x⊤(A⊤y)≤x⊤c=c⊤xb^\top y = (Ax)^\top y = x^\top(A^\top y) \le x^\top c = c^\top x.

Form the Lagrangian L(x,y,s)=c⊤x+y⊤(b−Ax)−s⊤x=b⊤y+(c−A⊤y−s)⊤x\mathcal{L}(x, y, s) = c^\top x + y^\top(b - Ax) - s^\top x = b^\top y + (c - A^\top y - s)^\top x with multiplier s≥0s \ge 0. Taking the infimum over unconstrained primal variables yields a finite dual value only when c−A⊤y−s=0c - A^\top y - s = 0, which recovers the dual constraint and dual objective g(y,s)=b⊤yg(y, s) = b^\top y.

If x⋆x^\star is primal optimal with value p⋆=c⊤x⋆p^\star = c^\top x^\star, Farkas' lemma (hyperplane separation for polyhedral cones) guarantees a vector y⋆y^\star satisfying A⊤y⋆≤cA^\top y^\star \le c and b⊤y⋆≥p⋆b^\top y^\star \ge p^\star. Combining this with weak duality forces b⊤y⋆=c⊤x⋆b^\top y^\star = c^\top x^\star.

Three families of algorithms for smooth convex optimization in Rn\mathbb{R}^n
Method familyInformation per stepCost per stepAccuracy ε\varepsilon in
Gradient / accelerated gradient (Nesterov)First-order (∇f\nabla f)O(n)O(n)O(1/ε)O(1/\varepsilon) or O(1/ε)O(1/\sqrt{\varepsilon})
Newton's methodSecond-order (∇f,∇2f\nabla f, \nabla^2 f)O(n3)O(n^3) (linear system)O(log⁡log⁡(1/ε))O(\log\log(1/\varepsilon)) locally
Interior-point (barrier)Second-order on −∑ln⁡(−gi)-\sum \ln(-g_i)O(n3)O(n^3) per Newton stepO(m log⁡(1/ε))O(\sqrt{m}\,\log(1/\varepsilon))

Which function is convex on all of R\mathbb{R}?

In a convex optimization problem, a point that is a local minimum is

In the KKT conditions, complementary slackness λi⋆gi(x⋆)=0\lambda_i^\star g_i(x^\star) = 0 means

For a linear program with a feasible, bounded optimum, strong duality tells us that

References

  1. Stephen Boyd, Lieven Vandenberghe (2004). Convex Optimization
  2. Yurii Nesterov (2004). Introductory Lectures on Convex Optimization: A Basic Course
  3. Harold W. Kuhn, Albert W. Tucker (1951). Nonlinear Programming · DOI:10.1006/hmat.2000.2289
  4. Sébastien Bubeck (2015). Convex Optimization: Algorithms and Complexity · arXiv:1405.4980