How the simplex method works
What is the simplex method?
The simplex method, published by George Dantzig in 1947, is the classic algorithm for linear programming: maximizing or minimizing a linear objective subject to linear constraints. The feasible solutions form a convex polygon (a polytope in higher dimensions), and when an optimal solution exists, one is always found at a corner point. The simplex method starts at a corner and moves along an edge to an adjacent corner that improves the objective, until no neighbouring corner is better.
How to read a simplex tableau
Each row of the tableau is one constraint written as an equation. The first column names the basic variable of the row, and its value is in the RHS column; every nonbasic variable is 0. Row 0 is the objective written as z − c₁x₁ − … − cₙxₙ = 0, so its entries are the Zj − Cj values and its right-hand side is the current value of z. In a maximization problem, a negative entry in row 0 means that increasing that variable increases z.
One iteration: entering variable, ratio test and pivot
In a maximization problem the entering variable has the most negative coefficient in row 0 (in a minimization problem, the most positive). The minimum ratio test divides each right-hand side by the positive entry of the entering column: the row with the smallest ratio is the first constraint to become tight, so its basic variable leaves. Row operations then turn the entering column into a unit column, which gives the next tableau.
Slack, surplus and artificial variables
A ≤ constraint becomes an equation by adding a slack variable (s), the unused capacity. A ≥ constraint subtracts a surplus variable (e) and, because −e cannot start in the basis, also adds an artificial variable (a). An = constraint gets an artificial variable only. Artificial variables mean nothing in the original problem: they must reach zero before the solution is valid.
Big M or Two-Phase?
Both methods remove the artificial variables. Big M puts them in the objective with a huge penalty M, so the simplex method pushes them out while it optimizes. This calculator keeps M as a symbol, so tableaus show entries such as 3M − 2 exactly instead of a rounded large number.
The Two-Phase method first minimizes r, the sum of the artificial variables (Phase I). If the minimum is 0, it drops the artificial columns and optimizes the real objective from that feasible basis (Phase II); if the minimum is positive, the problem is infeasible. Both methods reach the same optimal value.
Special cases
Degeneracy: a basic variable equals 0, and a pivot may leave the objective unchanged. In rare cases the method can cycle; this calculator detects a repeated basis and switches to Bland’s rule, which always terminates.
Unbounded problem: the entering column has no positive entry, so the objective can improve forever. Infeasible problem: an artificial variable stays positive at the end. Alternative optima: a nonbasic variable has 0 in row 0 of the optimal tableau, so another optimal corner exists.
Sensitivity analysis and duality
After the optimal tableau, the calculator runs a sensitivity analysis. The shadow price of a constraint is how much the optimal value z* changes per unit increase of its right-hand side; the reduced cost of a variable is how much z changes per unit of that variable forced into the solution. The ranges tell you how far one coefficient or right-hand side can move, all others fixed, before the optimal basis changes.
Every linear program also has a dual problem, with one variable per constraint. Its optimal solution is exactly the vector of shadow prices, and by strong duality both problems have the same optimal value. Complementary slackness links the two: a constraint with slack has a shadow price of 0, and a positive variable makes its dual constraint tight.
Frequently asked questions
Can the calculator solve minimization problems?
Yes. Choose Minimize. The entering variable is then the one with the most positive coefficient in row 0, and the tableau is optimal when no coefficient in row 0 is positive.
Why are the numbers shown as fractions?
The calculator uses exact rational arithmetic, so every tableau matches what you get by hand and no rounding error can change a pivot. You can switch to decimals at any time; decimals are rounded to 4 places for display only.
What if a right-hand side is negative?
The simplex method needs nonnegative right-hand sides, so that constraint is first multiplied by −1 and its inequality is reversed (≤ becomes ≥). The step-by-step solution shows this conversion.
How large can the problem be?
Up to 8 variables and 8 constraints, which covers textbook and exam problems while keeping every tableau readable. All variables are assumed to be nonnegative.
Does it solve integer programming problems?
No. It solves the linear programming problem, so optimal values can be fractional. Integer programs need methods such as branch and bound, which solve a sequence of linear programs like this one.
What is a shadow price in linear programming?
The shadow price of a constraint is the change in the optimal objective value per unit increase of its right-hand side, as long as the change stays within the allowable range. A constraint with slack has a shadow price of 0. The calculator lists every shadow price with its range of feasibility and shows how each one is read from the final tableau.
Does the calculator find the dual problem?
Yes. Below the solution it writes the dual problem with the correct sign for each dual variable, gives its optimal solution (the shadow prices) and checks strong duality and complementary slackness. When every dual variable is nonnegative, you can open the dual in the calculator and solve it step by step.