Primal Dual Relationship in Linear Programming (LP): Explained

Last updated: β€’ Sources β€’ Methodology

Primal Dual Relationship in Linear Programming (LP): Dual Form, Weak/Strong Duality, Complementary Slackness, and Shadow Prices

The primal–dual relationship is the reason LP solvers can β€œprove” optimality and report meaningful numbers like shadow prices (dual values) and reduced costs. This guide shows how to write the dual correctly and how to interpret it.

You can verify every worked example using the Linear Programming calculator. If you’re learning LP fundamentals first, start with Linear Programming (LP) β€” Beginner Guide.

On this page

Quick takeaway: The primal dual relationship in linear programming gives you two linked problems: the primal (your original decision model) and the dual (a pricing/bounding model). Weak duality says any dual-feasible solution bounds any primal-feasible solution. Strong duality says that when an optimum exists, primal and dual optimal objective values are equal. When things go wrong, duality also helps explain solver outcomes like infeasible vs unbounded.

Concept bridge: primal, dual, and certificates

Beginner β†’ intermediate

The dual is a β€œbound generator” (and often a pricing interpretation)

Think of the dual as assigning a value (price) to each constraint. If the primal is β€œmaximize profit subject to resource limits,” the dual is β€œminimize total resource cost subject to covering profit coefficients.” Even if you never explicitly write the dual, solvers use dual information to prove optimality and provide sensitivity-like outputs.

In 2-variable problems, you can build intuition from geometry using Graphical Method for LP (2 Variables).

Advanced (simplified)

Duality links solver statuses

A key practical implication:

If the primal is unbounded (maximization), the dual is infeasible.
If the dual is unbounded (minimization), the primal is infeasible.

That’s why β€œunbounded vs infeasible” debugging is often a duality debugging exercise: you’re missing a bound/constraint, or you’ve introduced a contradiction.

How to write the dual (rules table)

Cheat sheet

Most common form (x β‰₯ 0) with sign rules

There are many equivalent conventions. Below is the most common classroom convention with primal variables constrained x β‰₯ 0. If you have equalities, free variables, or mixed signs, use the rule table carefully.

Primal feature Dual feature Memory hook
Primal is max with constraints Ax ≀ b, x β‰₯ 0 Dual is min with constraints Aα΅€y β‰₯ c, y β‰₯ 0 Max/≀ ↔ Min/β‰₯
Primal constraint i is ≀ Dual variable y_i β‰₯ 0 β€œβ‰€ gives nonnegative price”
Primal constraint i is β‰₯ Dual variable y_i ≀ 0 (or rewrite the constraint) Sign flips with direction
Primal constraint i is = Dual variable y_i is free (unrestricted sign) Equality has flexible price
Primal variable x_j β‰₯ 0 Dual constraint j is β‰₯ (in the max/≀ form) Variable sign ↔ dual constraint direction
Primal variable x_j free Dual constraint j is equality Free ↔ equality
If you’re converting constraints for simplex (slack/surplus/artificial), see Slack / Surplus / Artificial Variables.

Weak duality vs strong duality (what they guarantee)

Core theorems (plain English)

Weak duality (bound) and strong duality (equality at optimum)

Consider a primal maximization and its dual minimization.

Weak duality:  for any primal-feasible x and dual-feasible y,
               cα΅€x ≀ bα΅€y

Strong duality: if both problems have optimal solutions,
               max cα΅€x = min bα΅€y

Weak duality explains why the dual objective is a certificate upper bound on the primal maximum. Strong duality is what lets solvers stop and say β€œoptimal” with a proof.

Complementary slackness (the linking rules)

Linking conditions

When a constraint is slack, its dual price must be zero (and vice versa)

Complementary slackness connects primal constraint slacks with dual variables, and primal variables with dual constraint slacks. In a common max/≀ form:

For each primal constraint i:
  y_i Β· (b_i βˆ’ a_iα΅€x) = 0

For each primal variable j:
  x_j Β· ((Aα΅€y)_j βˆ’ c_j) = 0

Interpretation:

  • If a primal constraint has positive slack, its dual variable (price) must be 0.
  • If a dual constraint is not tight, the corresponding primal variable must be 0.

Shadow prices (dual values) and reduced costs (intuition)

Interpretation

What dual variables mean in practice

A dual variable is often interpreted as the shadow price of a constraint: the marginal value of relaxing the RHS by 1 unit (within a valid range where the same basis remains optimal).

This is not β€œalways true for any size change,” but it is a very useful local sensitivity interpretation. Example 3 below shows a clean numeric verification.

Questions people ask about primal–dual relationship in LP (PAA)

People ask

What is the primal dual relationship in linear programming?

It’s the link between an LP (primal) and another LP (dual) where feasible solutions bound each other (weak duality), and optimal objective values match when an optimum exists (strong duality). Dual variables often interpret as shadow prices.

People ask

How do you write the dual of a linear programming problem?

You transform constraints into variables and variables into constraints, with directions/signs determined by whether the primal is max/min and whether constraints are ≀, β‰₯, or =. Use the dual construction table on this page as a checklist.

People ask

What is weak duality in linear programming?

Weak duality says any primal-feasible solution and dual-feasible solution satisfy primal ≀ dual (for primal max / dual min). That means the dual provides a certified bound on the primal objective.

People ask

What is strong duality in linear programming?

Strong duality says that if both problems have optimal solutions, the primal maximum equals the dual minimum. This equality is the β€œproof” behind solver optimality certificates.

People ask

What is complementary slackness and why is it useful?

Complementary slackness links which constraints are binding to which dual variables are nonzero. It helps you reason about the structure of the optimal solution and is often used to solve small LPs without full simplex pivots.

People ask

How are shadow prices related to the dual problem?

Shadow prices are the optimal dual variables associated with constraints. They measure the marginal objective improvement from relaxing a constraint’s RHS, within a local range. If your model is infeasible or unbounded instead, use Unbounded vs Infeasible LP.

Worked examples (fully solved)

Worked examples

Expand only the example you need

Each example below is collapsible (collapsed by default) to keep the page scannable while remaining fully indexable. You can verify each solution in the LP calculator.

Example 1 β€” Primal dual relationship in linear programming (max with ≀): derive the dual and solve both

Primal (P):

maximize   z = 3x1 + 2x2
subject to (1) x1 +  x2 ≀ 4
           (2) x1 + 2x2 ≀ 6
           x1, x2 β‰₯ 0

Step 1: Write the dual

This is a primal max with ≀ constraints and x β‰₯ 0, so dual is min with β‰₯ constraints and y β‰₯ 0. Let y1, y2 correspond to constraints (1) and (2).

minimize   w = 4y1 + 6y2
subject to (x1 column)  y1 +  y2 β‰₯ 3
           (x2 column)  y1 + 2y2 β‰₯ 2
           y1, y2 β‰₯ 0

Step 2: Solve the primal (2-variable corner method)

Corner points:

  • (0,0)
  • (4,0) from constraint (1) with x2=0
  • (0,3) from constraint (2) with x1=0
  • Intersection of (1) and (2): x1+x2=4, x1+2×2=6 β‡’ (2,2)

Objective values:

z(4,0)=12
z(0,3)=6
z(2,2)=10

So primal optimum is (x1,x2)=(4,0) with z*=12.

Step 3: Solve the dual

Try the simplest feasible corners:

  • If y2=0, constraints require y1 β‰₯ 3 and y1 β‰₯ 2 β‡’ y1=3. Then w=4(3)=12.
  • If y1=0, require y2 β‰₯ 3 and 2y2 β‰₯ 2 β‡’ y2=3. Then w=18.

Best is (y1,y2)=(3,0) with w*=12.

Step 4: Verify strong duality + complementary slackness

z* = 12 and w* = 12  β‡’ strong duality holds

Check complementary slackness using primal slacks:

Constraint (1) slack: 4 βˆ’ (4+0) = 0  β‡’ y1 can be > 0 (it is 3)
Constraint (2) slack: 6 βˆ’ (4+0) = 2  β‡’ y2 must be 0 (it is 0)

Result (Example 1): Primal optimum (x1,x2)=(4,0), z*=12. Dual optimum (y1,y2)=(3,0), w*=12. Matching values illustrate strong duality.

Example 2 β€” Primal dual relationship in linear programming (min with β‰₯): derive the dual and solve both

Primal (P) minimization:

minimize   z = 2x1 + x2
subject to (1) x1 +  x2 β‰₯ 2
           (2) x1 + 2x2 β‰₯ 3
           x1, x2 β‰₯ 0

Step 1: Write the dual

For a common classroom convention: primal min with β‰₯ and x β‰₯ 0 gives a dual max with ≀ and y β‰₯ 0. Let dual variables y1, y2 correspond to constraints (1) and (2).

maximize   w = 2y1 + 3y2
subject to (x1 column)  y1 +  y2 ≀ 2
           (x2 column)  y1 + 2y2 ≀ 1
           y1, y2 β‰₯ 0

Step 2: Solve the primal (corner logic)

Check key feasible corners:

  • Intersection of boundaries: x1+x2=2 and x1+2×2=3 β‡’ (1,1) gives z=3
  • Axis point x1=0: then x2β‰₯2 satisfies both β‡’ (0,2) gives z=2
  • Axis point x2=0: then x1β‰₯3 β‡’ (3,0) gives z=6

So primal optimum is (x1,x2)=(0,2) with z*=2.

Step 3: Solve the dual

Since y1 + 2y2 ≀ 1 is tight, it limits values strongly. Try y2=0:

y2 = 0 β‡’ y1 ≀ 1 and y1 ≀ 2 β‡’ y1 = 1
w = 2(1) + 3(0) = 2

Any positive y2 reduces the maximum allowed y1 due to y1 + 2y2 ≀ 1, so (1,0) is optimal.

Step 4: Verify strong duality + complementary slackness

z* = 2 and w* = 2  β‡’ strong duality holds

Check primal constraint slacks at (0,2):

(1): x1+x2 = 2  β‡’ slack = 0  β‡’ y1 can be > 0 (it is 1)
(2): x1+2x2 = 4  β‡’ slack = 1  β‡’ y2 must be 0 (it is 0)

Result (Example 2): Primal optimum (0,2), z*=2. Dual optimum (y1,y2)=(1,0), w*=2. Complementary slackness matches which constraints bind.

Example 3 β€” Shadow price (dual value) example: predict the objective change from RHS +1

Use Example 1, where the dual optimum was (y1,y2)=(3,0). The interpretation is: constraint (1) has shadow price 3 (locally), constraint (2) has shadow price 0.

Original LP (Example 1):

maximize   z = 3x1 + 2x2
subject to x1 +  x2 ≀ 4   (constraint 1)
           x1 + 2x2 ≀ 6   (constraint 2)
           x1, x2 β‰₯ 0

Step 1: Shadow-price prediction

Increase RHS of constraint (1) from 4 to 5 (one extra unit of that resource). With shadow price y1=3, the predicted objective increase is:

Ξ”z β‰ˆ 3 Γ— 1 = 3

Step 2: Re-solve the modified LP (quick corner check)

maximize   z = 3x1 + 2x2
subject to x1 +  x2 ≀ 5
           x1 + 2x2 ≀ 6
           x1, x2 β‰₯ 0

Check corners:

  • (5,0) feasible because 5 ≀ 6 β‡’ z = 15
  • (0,3) β‡’ z = 6
  • Intersection: x1+x2=5 and x1+2×2=6 β‡’ (4,1) β‡’ z = 14

New optimum is z_new = 15. Old optimum was z_old = 12.

Actual Ξ”z = 15 βˆ’ 12 = 3

Shadow price verified: increasing RHS(1) by 1 increased the optimal objective by 3, matching the dual value y1=3 (in this range).

Shadow-price interpretations can change if you move outside the range where the same basis remains optimal. That’s why β€œdual values” are best treated as local sensitivity information, not a universal global rule.

Check your answer (calculator + next guides)

Tooling + learning path

Verify primal and dual side-by-side

You can solve both primal and dual in the Linear Programming calculator and confirm that optimal objective values match (strong duality).

If you see β€œunbounded” or β€œinfeasible,” use Unbounded vs Infeasible LP (Fix Checklist). If your LP has alternate optima, dual values can be non-unique; see Multiple Optimal Solutions in LP.

Troubleshooting table (common dual mistakes)

Troubleshooting

Symptom β†’ likely cause β†’ fix

What you observe Likely mistake Fix
Dual objective doesn’t bound primal (violates weak duality) Sign/direction error in dual constraints or variable signs Rebuild dual using the rules table (constraint direction ↔ dual variable sign)
Dual constraints use wrong β‰₯/≀ direction Mixed up max/≀ vs min/β‰₯ canonical patterns Remember: max with ≀ ↔ min with β‰₯ (in the common convention)
Shadow price interpretation seems β€œwrong” for large RHS changes Shadow prices are local; basis changed Re-solve after changes; treat dual values as local sensitivity
Dual gives multiple solutions / non-unique prices Primal has multiple optima or degeneracy See Multiple Optimal Solutions in LP
Solver reports infeasible/unbounded Model missing bounds or contradictory constraints Use fix checklist and consider adding bounds

Glossary

Glossary

  • Primal: the original LP you want to solve.
  • Dual: a linked LP that provides bounds and often an economic interpretation (prices).
  • Weak duality: any primal-feasible objective is bounded by any dual-feasible objective (direction depends on max/min).
  • Strong duality: primal and dual optimal objective values are equal when an optimum exists.
  • Complementary slackness: conditions linking binding constraints to nonzero dual variables (and vice versa).
  • Shadow price (dual value): marginal objective change from a small change in a constraint RHS.
  • Reduced cost: simplex quantity tied to dual feasibility; indicates objective sensitivity to increasing a nonbasic variable.

Disclaimer

This article and the associated calculators are provided for educational and informational purposes only. Optimization outcomes depend on modeling assumptions and input data and may not reflect real-world constraints unless you encode them correctly. This is not legal, financial, operational, or safety advice. For high-stakes decisions, validate results against domain requirements and consult a qualified professional. For details, read our full disclaimer.

Sources
  1. Medium – Linear Programming: Duality
  2. Primal/Dual LP Problems
  3. Google OR-Tools β€” Linear Programming documentation
  4. COIN-OR CLP β€” LP solver documentation (simplex, dual concepts)
  5. GNU GLPK β€” LP/MIP solver documentation