Linear programming: why the optimum sits at a corner
The question
Inside a five-corner polygon of allowed points, which point makes 3x + 2y largest, and how can you be sure without checking every point?
You pick; the page pushes a level line across the polygon to check.
- 1 SeePick the best point for four goals.
- 2 TryTurn the goal and watch the winner.
- 3 ProveBuild the averaging argument line by line.
- 4 ApplyProblems to check yourself.
Before you start · 3 quick checks on the side of a line, where two lines cross and a point on a segment, about 3 min
Two ideas before you start
2 ideasEach limit keeps one side of a line
Figure: the part of the plane kept by the chosen limit, shaded, with its boundary line dashed; with all five limits, the polygon P. It needs JavaScript.
Only the points that pass all five tests remain: the polygon P with corners A = (0, 0), B = (6, 0), C = (4, 4), D = (3, 5) and E = (0, 6).
A linear inequality such as 2x + y ≤ 12 keeps the points on one side of the line 2x + y = 12. The allowed points are the points that pass every test: an intersection of half-planes, here a polygon.
Exact definition
Linear program. A linear program in two variables asks for the largest (or smallest) value of a linear function \(f(x, y) = c_1 x + c_2 y\) over the set \(P\) of points that satisfy finitely many linear inequalities \(a_{i1}x + a_{i2}y \le b_i\). The vector \(c = (c_1, c_2)\) is fixed, \(P\) is the feasible set, and a point of \(P\) where \(f\) takes its largest value is a maximizer.
On this page \(P\) is the set of points with \(2x + y \le 12\), \(x + y \le 8\), \(x + 3y \le 18\), \(x \ge 0\) and \(y \ge 0\), a polygon with corners \(A = (0, 0)\), \(B = (6, 0)\), \(C = (4, 4)\), \(D = (3, 5)\) and \(E = (0, 6)\). An inequality \(a \cdot x \ge b\) is the same as \(-a \cdot x \le -b\).
A linear goal is level along parallel lines
Figure: three parallel level lines of f = x + 2y, the chosen one dashed, and an arrow in the direction c = (1, 2). It needs JavaScript.
Level line: x + 2y = 4
Every point on the dashed line has x + 2y = 4, for example (4, 0) and (0, 2). A larger k slides the line, without turning it, in the direction of the arrow c = (1, 2).
The points where f = c₁x + c₂y takes one value k form a straight line, a level line. Lines for different k are parallel, and f grows in the direction of the vector c, which is perpendicular to them.
Exact definition
Level lines. For a vector \(c \ne 0\) and a number \(k\), the level line of \(f(x) = c \cdot x\) at height \(k\) is the set of points \(x\) with \(c \cdot x = k\). Any two level lines are parallel, and each is perpendicular to \(c\): if \(c \cdot x = c \cdot x' = k\), then \(c \cdot (x' - x) = 0\).
A step from \(x\) in the direction \(c\) raises \(f\): \(f(x + tc) = f(x) + t\,|c|^2\), which is larger than \(f(x)\) for every \(t \gt 0\).
Fine print: corners, edges and weighted averages
A corner (vertex) of the polygon \(P\) is a point of \(P\) where two boundary lines with different directions cross. An edge is the part of \(P\) on one boundary line, a segment between two neighboring corners. Corners are found by solving two boundary equations at a time, as in the lesson on linear systems, and keeping the solutions that satisfy every limit.
\(P\) is convex: each half-plane is convex, and an intersection of convex sets is convex (see convex sets and convex functions). \(P\) is bounded here: it fits inside a disk. The region \(x \ge 0\), \(y \ge 0\) alone is not bounded.
Fact. Every point \(x\) of a bounded polygon with corners \(v_1, \dots, v_k\) is a weighted average of them: \(x = \lambda_1 v_1 + \dots + \lambda_k v_k\) with every \(\lambda_j \ge 0\) and \(\lambda_1 + \dots + \lambda_k = 1\). Reason: the segments from \(v_1\) to the other corners cut \(P\) into triangles, and a point of a triangle is a weighted average of its three corners. Stage 3 uses this fact.
Pick the best point for four goals
- Each round gives a goal f = c₁x + c₂y to make as large as possible on the polygon, and draws its direction c as an arrow.
- Pick where f is largest: only at one corner, or along a whole edge. Then press Check.
- The page then pushes the level line of f across the polygon, in the direction of c, and shows where it leaves.
How the page decides
The page computes \(f\) at the five corners with exact arithmetic. For a goal with \(c \ne 0\), as in every round here, stage 3 proves that the largest value of \(f\) on the whole polygon is the largest corner value, and that a point other than a corner reaches it only when two neighboring corners tie, along the edge between them.
Each round has one answer and then ends. There are four rounds; a table then compares your answers with the right ones. Start over clears everything.
| Round | Goal | Your answer | Right answer | Match |
|---|
Turn the goal and watch the winner
A maximizer is a point of the polygon where f takes its largest value. Two quick questions first; the explorer below them opens once both are answered.
The explorer and its goals open after you answer both questions.
Explorer: choose the direction c
Set the two weights of \(f = c_1 x + c_2 y\) with the sliders. The page draws the arrow \(c\), pushes the level line as far as the polygon allows, and marks where \(f\) is largest.
Goals
How the page finds the largest value
For whole-number weights from \(-4\) to \(6\) the page computes the five corner values exactly and takes the largest. When two neighboring corners share it, the whole edge between them is marked; when \(c = (0, 0)\), every point is.
Why no point beats the best corner
Assumptions. \(P\) is a nonempty bounded polygon in the plane, the set of points that satisfy finitely many linear inequalities, with corners \(v_1, \dots, v_k\) (\(k \ge 3\)). The vector \(c\) is fixed, possibly \(0\), and \(f(x) = c \cdot x\). Let \(M = \max_j f(v_j)\), the largest corner value, reached at a best corner \(v_{j^*}\).
Fact used (Start tab, fine print). Every \(x \in P\) is a weighted average of the corners: \(x = \sum_j \lambda_j v_j\) with every \(\lambda_j \ge 0\) and \(\sum_j \lambda_j = 1\). Here \(\sum_j\) adds over \(j = 1, \dots, k\).
Conclusion. \(f(x) \le M\) for every \(x \in P\), so the largest value of \(f\) on \(P\) is \(M\), reached at the corner \(v_{j^*}\). If \(x\) is a maximizer, then in its weighted average every corner with \(\lambda_j \gt 0\) has \(f(v_j) = M\).
Each option is one step about the \(P\), \(c\), \(f\), \(M\), \(x\) and weights \(\lambda_j\) of the theorem. Pick the one that is true for every polygon, vector and point the theorem covers.
- A corner or an edge. By line 4 a maximizer mixes best corners only. Suppose \(c \ne 0\). If the best corners did not all lie on one edge, their average would be a maximizer inside \(P\), off the boundary, and a short step from it in the direction \(c\) would stay in \(P\) and raise \(f\) by \(t\,|c|^2 \gt 0\). So for \(c \ne 0\) the maximizers are one corner, or one whole edge when its two ends tie, as the explorer showed.
- Smallest values. The smallest value of \(f\) is minus the largest value of \(-f\), so it too is a corner value: the smallest one.
- Unbounded regions. The Fact fails there, and a largest value may not exist, as in the quick guess of stage 2. When a best value does exist, it has to be justified another way, as in problem P4.
- More variables. The same proof gives the same result in \(\mathbb{R}^n\) for a nonempty bounded set cut out by finitely many linear inequalities, once the Fact is known there (it holds, with a longer proof). The simplex method builds on it: it moves from corner to corner along edges on which \(f\) does not decrease, and stops at a corner from which no edge leads uphill; for a linear program such a corner is a maximizer.
- Curved limits. On a curve such as \(x^2 + y^2 = 4\), as in the lesson on Lagrange multipliers, there are no corners, and the best point is where a level line touches the curve. On a polygon, the level line through the best corner keeps all of \(P\) on one side: it is a supporting line, as in the lesson on separating hyperplanes.
Problems
Each problem has hints and a full solution. Answers can be typed as a decimal or a fraction; amounts in dollars may include a dollar sign and commas.
Related lessons: Convex sets explains why an intersection of half-planes is convex. Lagrange multipliers finds the best point on a curved constraint, where no corners exist. Separating hyperplanes studies lines that keep a convex set on one side, like the level line through the best corner.
Further reading
- D. Bertsimas and J. N. Tsitsiklis, Introduction to Linear Optimization, chapter 2, “The geometry of linear programming.”
- S. Boyd and L. Vandenberghe, Convex Optimization, section 4.3, “Linear optimization problems.”