Slack / Surplus / Artificial Variables (LP): What They Mean and How to Convert ≤, ≥, = Constraints to Standard Form
Slack and surplus variables convert inequalities into equalities. Artificial variables create a starting basis when slack/surplus alone can’t. If you understand these three, the Big‑M method and two‑phase simplex stop feeling like “magic.”
Want to apply this immediately? Convert your constraints to standard form here, then solve the LP in the Linear Programming calculator. For complete tableau runs, see Two Phase Simplex Method (Worked Example) and Big M Method Explained.
On this page
- Quick takeaway
- Definitions: slack vs surplus vs artificial
- Standard form conversions (≤, ≥, =) + sign conventions
- How to interpret slack/surplus in solutions (binding constraints)
- Why artificial variables are needed (basis logic, simplified)
- Questions people ask (PAA)
- Worked examples (collapsible)
- Check your answer (calculator + next guides)
- Troubleshooting checklist
- Glossary
Quick takeaway:
Slack variables measure unused capacity in a ≤ constraint, written as aᵀx + s = b.
Surplus variables measure “excess above a minimum” in a ≥ constraint, written as aᵀx − s = b.
Artificial variables are temporary variables added to create a valid starting basis when you have = or ≥ constraints.
Artificial variables are handled by two‑phase simplex or the Big‑M method.
Definitions: slack vs surplus vs artificial
Beginner
Slack variable (for ≤ constraints)
A slack variable s ≥ 0 converts a “resource limit” constraint into equality:
aᵀx ≤ b ⇔ aᵀx + s = b, s ≥ 0
Meaning: s is the leftover capacity. If s = 0, the constraint is tight (binding).
Beginner
Surplus variable (for ≥ constraints)
A surplus variable s ≥ 0 converts a “minimum requirement” constraint into equality:
aᵀx ≥ b ⇔ aᵀx − s = b, s ≥ 0
Meaning: s is how much you exceed the minimum (since aᵀx = b + s).
The minus sign is what trips people up.
Beginner → intermediate
Artificial variable (for = and ≥ constraints)
An artificial variable a ≥ 0 is added so you can start simplex with an identity basis:
aᵀx = b ⇔ aᵀx + a = b aᵀx ≥ b ⇔ aᵀx − s + a = b
Important: artificials are not part of the original LP. If the LP is feasible, methods like two‑phase and Big‑M drive them to zero.
Standard form conversions (≤, ≥, =) + sign conventions
Cheat sheet
One table you can follow without guesswork
| Original | Equality form | Added variables | Immediate BFS from that row? |
|---|---|---|---|
aᵀx ≤ b |
aᵀx + s = b |
s ≥ 0 (slack) |
Usually yes (slack can be basic) |
aᵀx ≥ b |
aᵀx − s + a = b |
s ≥ 0 (surplus), a ≥ 0 (artificial) |
No; surplus has −1, so add artificial |
aᵀx = b |
aᵀx + a = b |
a ≥ 0 (artificial) |
No; artificial provides starting basis |
≥ 0.
If a variable is “free” (unrestricted sign), you must replace it with the difference of two nonnegative variables
(e.g., x = x⁺ − x⁻), which changes the columns in your tableau.
How to interpret slack/surplus in solutions (binding constraints)
Interpretation
Slack = 0 is the practical definition of a binding constraint
After solving an LP, you can compute slack/surplus directly from the original constraints:
For ≤ constraint i: slack si = bi − (aiᵀx) For ≥ constraint i: surplus si = (aiᵀx) − bi
Interpretation:
- If slack/surplus = 0, the constraint is binding (active at the optimum).
- If slack/surplus > 0, the constraint is non-binding (there is “room”).
Binding constraints are the ones that typically determine the corner point optimum (see Graphical Method for LP for 2-variable intuition).
Why artificial variables are needed (basis logic, simplified)
Simplified linear algebra
Simplex needs an identity matrix in the basic columns
Simplex works with a set of basic variables whose columns form an identity matrix. This makes the basic solution easy to read: set nonbasic variables to 0 and solve for the basic variables.
With a ≤ constraint, slack has a +1 in its row and zeros elsewhere, so it naturally forms part of the identity.
With a ≥ constraint, the surplus column has a −1, which breaks that identity pattern.
Artificial variables are inserted precisely to “patch” the identity so the algorithm can start.
= or ≥, the two most common start methods are
Two‑Phase Simplex and Big‑M.
Questions people ask about slack, surplus, and artificial variables (PAA)
People ask
What is a slack variable in linear programming?
A slack variable is a nonnegative variable added to a ≤ constraint to convert it into an equality.
It represents unused resource (leftover capacity). If slack is zero at the optimum, that constraint is binding.
People ask
What is a surplus variable in linear programming?
A surplus variable is a nonnegative variable subtracted from a ≥ constraint to convert it into an equality.
It represents how much the left-hand side exceeds the required minimum.
People ask
What is the difference between slack and surplus variables?
Slack applies to ≤ constraints and is added (+s). Surplus applies to ≥ constraints and is subtracted (−s).
Conceptually: slack is unused capacity; surplus is excess above a minimum requirement.
People ask
When do you add an artificial variable?
You add an artificial variable for an = constraint and usually for a ≥ constraint (after subtracting surplus),
because otherwise you cannot form an initial identity basis for simplex. Artificial variables are then eliminated by
two-phase simplex or penalized in the Big‑M method.
People ask
Do slack variables affect the optimal solution?
Slack variables do not change the feasible set in terms of the original decision variables; they only rewrite constraints as equalities. However, their values at the optimum provide insight: a slack of 0 means the constraint is binding and “driving” the solution.
People ask
How do you find slack or surplus values after solving an LP?
Plug the optimal x back into each original constraint. For ≤, slack is b − aᵀx.
For ≥, surplus is aᵀx − b. This is a fast way to identify which constraints are binding.
People ask
Why do we need artificial variables in simplex?
Simplex needs a starting basic feasible solution (BFS). When constraints don’t naturally provide basic columns (common with = and ≥),
artificial variables create a temporary BFS so the algorithm can start, then they are driven to zero if the LP is feasible.
Worked examples (collapsible)
Worked examples
Expand only the conversion you need
Each example below is collapsed by default for readability, but fully indexable. After converting, you can verify the resulting LP in the LP calculator.
Example 1 — Slack variable worked example (convert a ≤ constraint to equality)
Constraint:
2x1 + x2 ≤ 8, x1, x2 ≥ 0
Step 1: Add slack
2x1 + x2 + s1 = 8 s1 ≥ 0
Step 2: Interpret slack
If at some solution (x1, x2) = (3, 1), then:
2(3) + 1 = 7 s1 = 8 − 7 = 1
Meaning: you are using 7 out of 8 units; 1 unit is unused capacity.
If s1 = 0, the constraint is binding at that solution.
Result: 2x1 + x2 ≤ 8 becomes 2x1 + x2 + s1 = 8 with s1 ≥ 0 (slack).
Example 2 — Surplus + artificial variables worked example (convert ≥ and = constraints)
Original constraints:
(1) x1 + 2x2 ≥ 6
(2) x1 + x2 = 4
x1, x2 ≥ 0
Step 1: Convert the ≥ constraint (surplus + artificial)
For ≥, subtract surplus s1 ≥ 0. This alone won’t create an identity column, so add artificial a1 ≥ 0:
x1 + 2x2 − s1 + a1 = 6 s1, a1 ≥ 0
Step 2: Convert the = constraint (artificial)
For =, add artificial a2 ≥ 0:
x1 + x2 + a2 = 4 a2 ≥ 0
Step 3: What method uses these artificials?
- Two‑phase simplex: Phase 1 minimizes
w = a1 + a2to forcea1=a2=0if feasible. - Big‑M: penalizes artificials in the objective using a large
M.
Result: the standard-form system is
x1 + 2x2 − s1 + a1 = 6, x1 + x2 + a2 = 4, with s1, a1, a2 ≥ 0.
Example 3 — Interpreting slack at the optimum (binding vs non-binding constraints)
LP (maximize):
maximize z = 5x1 + 4x2
subject to (A) x1 + x2 ≤ 8
(B) 2x1 + x2 ≤ 10
x1, x2 ≥ 0
Step 1: Convert to equality with slacks
x1 + x2 + sA = 8 2x1 + x2 + sB = 10 sA, sB ≥ 0
Step 2: Solve quickly by checking corners (2-variable logic)
Candidate corners come from axes and intersection of the two lines:
Intersection: x1 + x2 = 8 2x1 + x2 = 10 Subtract → x1 = 2, then x2 = 6
Evaluate objective at feasible corners:
- (0,8): z = 32
- (5,0): z = 25 (since 2×1≤10 → x1≤5)
- (2,6): z = 5(2)+4(6)=34 ← best
Step 3: Compute slack values at the optimum
At (x1,x2) = (2,6):
Constraint (A): x1 + x2 = 2 + 6 = 8 ⇒ sA = 8 − 8 = 0 (binding) Constraint (B): 2x1 + x2 = 4 + 6 = 10 ⇒ sB = 10 − 10 = 0 (binding)
Both constraints are binding: the optimum lies at their intersection. If a slack were positive, that constraint would be non-binding (it wouldn’t “pin” the optimum).
Optimal solution: (x1,x2)=(2,6), z*=34, with sA=0 and sB=0 (both constraints binding).
Check your answer (calculator + next guides)
Tooling + learning path
Verify conversions and understand the next method you’ll use
After converting constraints, you can solve the LP directly in the Linear Programming calculator. For 2-variable problems, you can also confirm with the Graphical Method for LP (2 Variables).
Troubleshooting checklist
Troubleshooting
Symptom → likely cause → fix
| What you observe | Likely mistake | Fix |
|---|---|---|
Surplus variable appears with a +1 instead of -1 |
Wrong sign for ≥ conversion | For ≥, use aᵀx − s = b (surplus is subtracted) |
| No valid starting basis after conversion | Missing artificial variable for = or ≥ constraints |
Add artificials and use two‑phase or Big‑M |
| Model suddenly becomes infeasible after changing a constraint | Constraint direction or RHS updated incorrectly | Use infeasible checklist and recompute slacks at a known good solution |
| Solver says “unbounded” unexpectedly | Missing upper bounds or anchoring constraints | See Upper Bounds in Linear Programming |
| Artificial variable remains positive in Big‑M / Phase 1 | Original constraints are infeasible (or entered incorrectly) | Re-check constraints; use Unbounded vs Infeasible LP |
Glossary
Glossary
- Slack variable: nonnegative variable added to a
≤constraint to make an equality; measures unused capacity. - Surplus variable: nonnegative variable subtracted from a
≥constraint to make an equality; measures excess above a minimum. - Artificial variable: temporary variable added to create an initial basis for simplex when slack/surplus cannot.
- Binding constraint: constraint with slack/surplus equal to 0 at the solution.
- Non-binding constraint: constraint with positive slack/surplus at the solution.
- Standard form: LP written with equality constraints and nonnegative variables (common simplex input format).
- Basic feasible solution (BFS): solution obtained by selecting basic variables (identity columns) and setting nonbasic variables to zero.
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.