Duality

Work in progress. This note is still being written and incomplete.

Every linear program (the primal) has an associated linear program (the dual) built from the same data.

Consider a primal in standard form, with xRnx \in \mathbb{R}^n, an m×nm \times n matrix AA, bRmb \in \mathbb{R}^m, cRnc \in \mathbb{R}^n. It has nn variables and mm constraints.

(primal)maximizecTxs.t.Axbx0\begin{aligned} \text{(primal)} \quad \text{maximize} \quad & c^T x \\ \text{s.t.} \quad & Ax \le b \\ & x \ge 0 \end{aligned}

The dual has mm variables and nn constraints. One variable yiy_i per primal constraint. yRmy \in \mathbb{R}^m:

(dual)minimizebTys.t.ATycy0\begin{aligned} \text{(dual)} \quad \text{minimize} \quad & b^T y \\ \text{s.t.} \quad & A^T y \ge c \\ & y \ge 0 \end{aligned}

By index:

primal:maxj=1ncjxjs.t.j=1naijxjbi  (i=1,,m),xj0\text{primal:} \quad \max \sum_{j=1}^n c_j x_j \quad \text{s.t.} \quad \sum_{j=1}^n a_{ij} x_j \le b_i \ \ (i = 1, \dots, m), \quad x_j \ge 0 dual:mini=1mbiyis.t.i=1maijyicj  (j=1,,n),yi0\text{dual:} \quad \min \sum_{i=1}^m b_i y_i \quad \text{s.t.} \quad \sum_{i=1}^m a_{ij} y_i \ge c_j \ \ (j = 1, \dots, n), \quad y_i \ge 0

Same data (A,b,c)(A, b, c), rearranged: AA transposed, bb and cc exchanged, objective sense flipped, and the constraint and variable counts swapped (nn constraints, mm variables). The correspondence table lists every swap; the direction rules cover constraints that are not \le.

Primal-Dual Correspondence

  • Objective flips
    Maximize primal \leftrightarrow minimize dual (or vice versa).
  • Primal constraint \leftrightarrow dual variable
    1 dual variable per primal constraint.
  • Primal variable \leftrightarrow dual constraint
    1 dual constraint per primal variable.
  • RHS and objective coefficients swap
    Primal RHS becomes dual objective coefficients; primal objective coefficients become dual RHS.
  • Constraint matrix transposes
    Dual constraint coefficients are the transpose of the primal’s.

Constraint Direction Rules

For a maximization primal with non-negative variables:

  • Primal \le constraint \to dual variable 0\ge 0
  • Primal \ge constraint \to dual variable 0\le 0
  • Primal == constraint \to dual variable unrestricted in sign

For a minimization primal with non-negative variables, the two inequality rules swap. The equality rule is unchanged.

  • Primal \ge constraint \to dual variable 0\ge 0
  • Primal \le constraint \to dual variable 0\le 0
  • Primal == constraint \to dual variable unrestricted in sign

The canonical constraint direction, the one giving a non-negative dual variable, is \le for a max primal and \ge for a min primal. A deviation from it forces the opposite sign.

The variable-to-constraint mapping mirrors this. A non-negative primal variable gives a \ge dual constraint for a max primal, a \le dual constraint for a min primal.

Mnemonics

  • MOTS
    Max flips to Min. Objective coefficients swap with RHS. Transpose AA. Sizes swap (mm constraints give mm variables, nn variables give nn constraints).
  • Max is under, min is over
    The canonical constraint direction is \le for a max primal, \ge for a min primal.
  • Same, equal, opposite
    Compare a primal constraint to the canonical direction. Same gives dual variable 0\ge 0. Equality gives it unrestricted. Opposite gives it 0\le 0.
  • Same, equal, opposite (variable side)
    Take the max primal case, where a non-negative variable gives a \ge dual constraint. A free variable gives an == dual constraint. A non-positive variable gives a \le dual constraint. For a min primal every direction flips.
  • Pay only for what you use up
    A non-binding primal constraint has dual value 00. A positive dual value forces its primal constraint to bind. See complementary slackness.

Theorems

Weak Duality Theorem

For a maximization primal and its minimization dual, every primal feasible objective value is \le every dual feasible objective value.

zprimalzdualz_{\text{primal}} \le z_{\text{dual}}

Consequences:

  • If the primal is unbounded, the dual is infeasible, and vice versa.
  • If a primal feasible xx and a dual feasible yy satisfy cTx=bTyc^T x = b^T y, both are optimal.
  • Dual infeasible does not imply primal unbounded; both problems can be infeasible.

Strong Duality Theorem

If the primal has an optimal solution, the dual also has an optimal solution, and their optimal objective values are equal.

zprimal=zdualz_{\text{primal}}^* = z_{\text{dual}}^*

Only four primal-dual outcome pairs are possible:

PrimalDual
optimaloptimal, equal values
unboundedinfeasible
infeasibleunbounded
infeasibleinfeasible

Complementary Slackness

Primal feasible xx and dual feasible yy are both optimal if and only if for every matched pair one side is 0: either a constraint is binding (0 slack/surplus) or its corresponding variable in the other problem is 0, never both non-zero.

Proof sketch: strong duality makes both \le in the weak duality chain equalities; each gap is a sum of non-negative terms equal to 0, so every term is 0.

xj(dual constraint j slack)=0for every primal variable xjx_j \cdot (\text{dual constraint } j \text{ slack}) = 0 \quad \text{for every primal variable } x_j yi(primal constraint i slack)=0for every dual variable yiy_i \cdot (\text{primal constraint } i \text{ slack}) = 0 \quad \text{for every dual variable } y_i

Used to recover one problem’s optimal solution directly from the other’s, without re-solving.

Reading Dual Values from the Primal Optimal Table

The optimal dual variable values appear in the primal’s optimal simplex tableau, in the objective row under the columns of the corresponding primal slack/surplus variables (with sign adjusted for the constraint direction).

Each yiy_i^* is the shadow price of primal constraint ii: the rate zz^* changes per unit increase of bib_i, valid over the range that keeps the current basis optimal.

Worked Example

Primal, the same LP as the simplex worked example:

maximizez=3x1+5x2subject tox142x2123x1+2x218x1,x20\begin{aligned} \text{maximize} \quad & z = 3x_1 + 5x_2 \\ \text{subject to} \quad & x_1 \le 4 \\ & 2x_2 \le 12 \\ & 3x_1 + 2x_2 \le 18 \\ & x_1, x_2 \ge 0 \end{aligned}

3 constraints give 3 dual variables y1,y2,y3y_1, y_2, y_3; 2 primal variables give 2 dual constraints. All primal constraints are \le, so all yi0y_i \ge 0. Transposing the constraint matrix and swapping RHS with objective coefficients:

minimizew=4y1+12y2+18y3subject toy1+3y332y2+2y35y1,y2,y30\begin{aligned} \text{minimize} \quad & w = 4y_1 + 12y_2 + 18y_3 \\ \text{subject to} \quad & y_1 + 3y_3 \ge 3 \\ & 2y_2 + 2y_3 \ge 5 \\ & y_1, y_2, y_3 \ge 0 \end{aligned}

The primal’s final tableau has objective row entries 0,32,10, \tfrac{3}{2}, 1 under s1,s2,s3s_1, s_2, s_3, so y1=0y_1 = 0, y2=32y_2 = \tfrac{3}{2}, y3=1y_3 = 1. Then w=4(0)+12(32)+18(1)=36=zw = 4(0) + 12(\tfrac{3}{2}) + 18(1) = 36 = z^*, confirming strong duality.

Complementary slackness holds at x=(2,6)x^* = (2, 6), y=(0,32,1)y^* = (0, \tfrac{3}{2}, 1):

  • Primal constraint 1 has slack 42=2>04 - 2 = 2 > 0, so y1=0y_1 = 0.
  • y2,y3>0y_2, y_3 > 0, so primal constraints 2 and 3 are binding: 2(6)=122(6) = 12, 3(2)+2(6)=183(2) + 2(6) = 18.
  • x1,x2>0x_1, x_2 > 0, so both dual constraints are binding: 0+3(1)=30 + 3(1) = 3, 2(32)+2(1)=52(\tfrac{3}{2}) + 2(1) = 5.
Written by September 4, 2026 7 min read
Was this helpful?