acalculator

How do I use the simplex method?

Type the objective and the constraints, one per line, and pick maximize or minimize. The simplex method calculator builds the first tableau, shows each pivot and why it was chosen, and reads the optimum from the last tableau.

Your numbers

Goal
Optimal value of z
400

The optimal value is 400, at x = 4, y = 8.

Where it occurs
x = 4, y = 8
Exact optimal value
400
Simplex tableaus
Maximize z = 40x + 30y subject to x + y ≤ 12, 2x + y ≤ 16, all variables ≥ 0. Add slack (≤) and surplus (≥) variables s1 to s2; Tableau 1 (x, y, s1, s2 | RHS): row 1 [1, 1, 1, 0 | 12], row 2 [2, 1, 0, 1 | 16], bottom [−40, −30, 0, 0 | 0]. Pivot column x (bottom entry −40), ratios row 1: 12, row 2: 8, smallest in row 2: pivot on 2; Tableau 2 (x, y, s1, s2 | RHS): row 1 [0, 1/2, 1, −1/2 | 4], row 2 [1, 1/2, 0, 1/2 | 8], bottom [0, −10, 0, 20 | 320]. Pivot column y (bottom entry −10), ratios row 1: 8, row 2: 16, smallest in row 1: pivot on 1/2; Tableau 3 (x, y, s1, s2 | RHS): row 1 [0, 1, 2, −1 | 8], row 2 [1, 0, −1, 1 | 4], bottom [0, 0, 20, 10 | 400]. No negative entry in the bottom row, so this tableau is optimal; Read the answer: x = 4, y = 8, z = 400

Optimal value of z: 400. The optimal value is 400, at x = 4, y = 8.

How it is worked out

How to calculate

Solves a linear programming problem by the simplex method and shows every tableau, pivot column, ratio test and pivot, with the two-phase method for ≥ and = constraints.

Example with the default inputs (Goal Maximize, Objective z = 40x + 30y, Constraints (one per line, or split by ;) x + y <= 12; 2x + y <= 16): The optimal value is 400, at x = 4, y = 8.

Method: Add a slack variable to each ≤ row (and a surplus and an artificial variable to each ≥ row, an artificial to each = row). Pivot on the most negative bottom-row entry and the smallest ratio until no bottom entry is negative; with artificials, first maximize −(sum of artificials).

  • Every variable is at least 0; lines such as x ≥ 0 may be typed but are not needed.
  • A strict < or > is read as ≤ or ≥.
  • Typed decimals and fractions are read exactly, and every tableau is exact.
  • Ties go to the first column, and in the ratio test to the row whose basic variable comes first; after 50 pivots the first negative column is used, so the method cannot cycle.

Machine-readable copies: Markdown, JSON.

Worked examples

Each example is checked against the calculator on every build.

  1. Goal Maximize, Objective z = 40x + 30y, Constraints (one per line, or split by ;) x + y <= 12 2x + y <= 16 gives Optimal value of z 400, Where it occurs x = 4, y = 8.Source: Sekhon and Bloom, Applied Finite Mathematics, §4.2 Maximization By The Simplex Method (Example 4.2.1: maximize Z = 40x₁ + 30x₂ with x₁ + x₂ ≤ 12 and 2x₁ + x₂ ≤ 16; pivot on 2, then on 1/2; x₁ = 4, x₂ = 8, Z = 400), CC BY 4.0, https://math.libretexts.org/Bookshelves/Applied_Mathematics/Applied_Finite_Mathematics_(Sekhon_and_Bloom)/04:_Linear_Programming_The_Simplex_Method/4.02:_Maximization_By_The_Simplex_Method (retrieved 2026-10-05)
  2. Goal Maximize, Objective z = 2x + 3y + 4z, Constraints (one per line, or split by ;) 3x + 2y + z <= 10 2x + 5y + 3z <= 15 gives Optimal value of z 20, Where it occurs x = 0, y = 0, z = 5.
  3. Goal Minimize, Objective z = 60x + 50y, Constraints (one per line, or split by ;) 8x + 16y >= 200 60x + 40y >= 960 2x + 2y >= 40 gives Optimal value of z 1,080, Where it occurs x = 8, y = 12.Source: Sekhon and Bloom, Applied Finite Mathematics, §3.2 Minimization Applications (Example 2: minimize 60x + 50y with 8x + 16y ≥ 200, 60x + 40y ≥ 960, 2x + 2y ≥ 40; the minimum 1080 at (8, 12)), CC BY 4.0, https://math.libretexts.org/Bookshelves/Applied_Mathematics/Applied_Finite_Mathematics_(Sekhon_and_Bloom)/03%3A_Linear_Programming_-_A_Geometric_Approach/3.02%3A_Minimization_Applications (retrieved 2026-10-05)
  4. Goal Maximize, Objective z = x + y, Constraints (one per line, or split by ;) x + 3y <= 4 3x + y <= 4 gives Optimal value of z 2, Where it occurs x = 1, y = 1, Exact optimal value 2.
  5. Goal Maximize, Objective z = x + 2y, Constraints (one per line, or split by ;) 3x + 3y <= 4 gives Optimal value of z 2.666667, Where it occurs x = 0, y = 4/3 ≈ 1.333333333, Exact optimal value 8/3 ≈ 2.666666667.

How it works

The problem: maximize (or minimize) z = c₁x₁ + c₂x₂ + … subject to constraints aᵢ₁x₁ + aᵢ₂x₂ + … (≤, ≥ or =) bᵢ, with every variable ≥ 0.

  1. Standard form. A row with a negative right side is multiplied by −1 (≤ and ≥ swap). Each ≤ row gets a slack variable s (+1), each ≥ row a surplus variable s (−1); the slack and surplus variables are numbered s1, s2, … in row order. Each ≥ and = row also gets an artificial variable a1, a2, …
  2. Tableau. One row per constraint, [coefficients | right side], and a bottom row. The starting basic variables are the slack variable of each ≤ row and the artificial variable of each other row.
  3. Phase 1 (only with artificial variables): the bottom row maximizes −(a1 + a2 + …). It starts with 1 under each artificial column and 0 elsewhere; each artificial row is then subtracted from it, so it reads 0 under the basic variables. Pivot as in step 5 until no bottom entry is negative. If the bottom-right value is not 0, the problem is infeasible. Otherwise any artificial variable still basic (at 0) is pivoted out on the first nonzero entry of its row in a non-artificial column (or its row, now redundant, is dropped), and the artificial columns are removed.
  4. Phase 2 bottom row: −cⱼ under each main variable to maximize z, or +cⱼ to minimize (maximizing −z); then each basic variable's row times its bottom entry is subtracted, so the bottom row reads 0 under the basic variables.
  5. Pivot. The pivot column is the most negative bottom entry (ties: the first column). In that column, each row with a positive entry gives the ratio right side ÷ entry; the smallest ratio picks the pivot row (ties: the row whose basic variable comes first). If the column has no positive entry, the objective has no limit: the problem is unbounded. Divide the pivot row by the pivot, and subtract multiples of it to clear the rest of the column, bottom row included. After 50 pivots in a phase, the first negative bottom entry is used instead, so the method cannot cycle.
  6. Optimal. When no bottom entry is negative, each basic variable equals its row's right side and every other variable is 0. The bottom-right value is the maximum of z (or −z when minimizing, so the minimum is minus that value).

Rules

  • Type the objective as a sum of terms such as 40x, −2.5y, 1/2z or a constant. The words maximize or minimize (or max, min) at the start, or a name such as "P =", may be typed; a typed word sets the goal.
  • One constraint per line (or separated by ;), each with one ≤ (typed <=), ≥ (typed >=) or = sign. A strict < or > is read as ≤ or ≥. Lines such as x ≥ 0 or x, y ≥ 0 are accepted and change nothing.
  • A constant term in the objective (such as the 5 in 2x + 3y + 5) does not move the optimum; it is added to the optimal value.
  • The steps call the objective z, or the first of P, w and Z that is not a variable name.
  • Variable names start with a letter and may hold digits (x1, x₂). The columns are in order of first appearance, objective first. Up to 8 variables and 12 constraints.
  • Numbers may be decimals or fractions a/b; a comma only separates thousands in groups of three (1,200), so 1,5 is refused. A number has at most 15 digits, and scientific notation such as 2e5 is refused (type 200000).
  • An optimal value too large for a double-precision number gives no answer.

Output format. Every tableau entry and ratio is an exact fraction, shown as a whole number or as p/q in lowest terms. Tableaus are numbered within each phase. The optimal value shows to 10 significant figures; each variable shows as a decimal when its decimal ends, or as p/q with its decimal to 10 significant figures. A decimal that ends shows every digit, in the exact optimal value and the working too (1/1024 is 0.0009765625).

Worked examples by hand

Maximize 40x + 30y; x + y ≤ 12, 2x + y ≤ 16. Tableau 1 (x, y, s1, s2 | RHS): [1, 1, 1, 0 | 12], [2, 1, 0, 1 | 16], bottom [−40, −30, 0, 0 | 0]. Pivot column x (−40); ratios 12 and 8, so pivot on the 2 in row 2. Tableau 2: [0, 1/2, 1, −1/2 | 4], [1, 1/2, 0, 1/2 | 8], bottom [0, −10, 0, 20 | 320]. Pivot column y (−10); ratios 8 and 16, so pivot on the 1/2 in row 1. Tableau 3: [0, 1, 2, −1 | 8], [1, 0, −1, 1 | 4], bottom [0, 0, 20, 10 | 400]. No negative entry: x = 4, y = 8, z = 400.

Maximize 2x + 3y + 4z; 3x + 2y + z ≤ 10, 2x + 5y + 3z ≤ 15. The bottom row is [−2, −3, −4, 0, 0 | 0]; the pivot column is z (−4), with ratios 10 and 5, so pivot on the 3 in row 2. The new bottom row is [2/3, 11/3, 0, 0, 4/3 | 20], with no negative entry: x = 0, y = 0, z = 5, value 20.

Minimize 60x + 50y; 8x + 16y ≥ 200, 60x + 40y ≥ 960, 2x + 2y ≥ 40. Three artificial variables; phase 1 reaches 0, and phase 2 ends at x = 8, y = 12, minimum 1080.

Maximize x + y; x + 3y ≤ 4, 3x + y ≤ 4. The corners (0, 4/3), (1, 1) and (4/3, 0) give 4/3, 2 and 4/3, so the maximum is 2 at (1, 1).

Maximize x + 2y; 3x + 3y ≤ 4. y = 4/3 and x = 0, so z = 8/3 ≈ 2.666666667.

Other questions people ask

What is the simplex method?

A step-by-step way to solve a linear programming problem. It starts at a corner of the feasible region (all main variables 0) and moves from corner to corner, raising the objective each time, until no move can raise it further.

How do I choose the pivot column?

Pick the most negative entry in the bottom row. Its variable enters the solution. If no entry is negative, the tableau is optimal.

How do I choose the pivot row?

Divide each right-side value by the positive entry in the pivot column, and pick the row with the smallest ratio. In the first tableau of maximize 40x + 30y with x + y ≤ 12 and 2x + y ≤ 16, the ratios are 12 and 8, so the pivot is the 2 in row 2.

What are slack variables?

A slack variable turns a ≤ constraint into an equation: x + y ≤ 12 becomes x + y + s1 = 12, with s1 ≥ 0 the unused amount. A ≥ constraint gets a surplus variable that is subtracted instead.

How does the simplex method handle ≥ and = constraints?

With the two-phase method. Each ≥ and = row gets an artificial variable. Phase 1 drives the artificial variables to 0, which finds a starting corner; if it cannot, the problem is infeasible. Phase 2 then optimizes the real objective.

How do I minimize with the simplex method?

Maximize −z instead. The page puts z’s coefficients (not their negatives) in the bottom row and reads the minimum as minus the final bottom-right value. Minimizing 60x + 50y under three ≥ constraints gives 1080 at (8, 12).