{
  "id": "simplex-method",
  "version": "d35229eb7c9b",
  "status": "published",
  "name": "Simplex Method Calculator",
  "question": "How do I use the simplex method?",
  "summary": "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.",
  "category": "math",
  "subcategory": "algebra",
  "url": "https://www.acalculator.org/math/simplex-method-calculator",
  "markdown": "https://www.acalculator.org/math/simplex-method-calculator.md",
  "kind": "function",
  "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).",
  "assumptions": [
    "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."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "goal": {
        "title": "Goal",
        "description": "Whether to find the largest or the smallest value of the objective.",
        "type": "string",
        "enum": [
          "max",
          "min"
        ]
      },
      "obj": {
        "title": "Objective z =",
        "description": "The expression to maximize or minimize, such as 40x + 30y.",
        "type": "string",
        "maxLength": 300
      },
      "st": {
        "title": "Constraints (one per line, or split by ;)",
        "description": "Each constraint on its own line, with ≤ (<=), ≥ (>=) or =, such as x + y <= 12. Every variable is at least 0.",
        "type": "string",
        "maxLength": 1500
      }
    }
  },
  "outputs": {
    "value": {
      "label": "Optimal value of z",
      "description": "The largest (or smallest) value of the objective that meets every constraint.",
      "format": "number"
    },
    "solution": {
      "label": "Where it occurs",
      "description": "The value of each variable at the optimum.",
      "format": "text"
    },
    "exact": {
      "label": "Exact optimal value",
      "description": "The optimal value as a decimal, or as a fraction when its decimal does not end.",
      "format": "text"
    },
    "steps": {
      "label": "Simplex tableaus",
      "description": "Each simplex tableau, the pivot chosen and why, up to the optimal tableau.",
      "format": "text"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "goal": "max",
      "obj": "40x + 30y",
      "st": "x + y <= 12; 2x + y <= 16"
    },
    "outputs": {
      "value": 400,
      "solution": "x = 4, y = 8",
      "exact": "400",
      "steps": "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"
    },
    "text": "The optimal value is 400, at x = 4, y = 8."
  },
  "examples": [
    {
      "given": {
        "goal": "max",
        "obj": "40x + 30y",
        "st": "x + y <= 12\n2x + y <= 16"
      },
      "expect": {
        "value": 400,
        "solution": "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)"
    },
    {
      "given": {
        "goal": "max",
        "obj": "2x + 3y + 4z",
        "st": "3x + 2y + z <= 10\n2x + 5y + 3z <= 15"
      },
      "expect": {
        "value": 20,
        "solution": "x = 0, y = 0, z = 5"
      },
      "source": "hand calculation in content.mdx: one pivot on z in row 2 (ratios 10 and 5) gives z = 5 and a bottom row with no negative entry; checked by listing every corner in Python"
    },
    {
      "given": {
        "goal": "min",
        "obj": "60x + 50y",
        "st": "8x + 16y >= 200\n60x + 40y >= 960\n2x + 2y >= 40"
      },
      "expect": {
        "value": 1080,
        "solution": "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); solved here by the two-phase method"
    },
    {
      "given": {
        "goal": "max",
        "obj": "x + y",
        "st": "x + 3y <= 4\n3x + y <= 4"
      },
      "expect": {
        "value": 2,
        "solution": "x = 1, y = 1",
        "exact": "2"
      },
      "source": "hand calculation in content.mdx: the corners (0, 4/3), (1, 1) and (4/3, 0) give 4/3, 2 and 4/3"
    },
    {
      "given": {
        "goal": "max",
        "obj": "x + 2y",
        "st": "3x + 3y <= 4"
      },
      "expect": {
        "value": 2.6666666666666665,
        "solution": "x = 0, y = 4/3 ≈ 1.333333333",
        "exact": "8/3 ≈ 2.666666667"
      },
      "source": "hand calculation in content.mdx: y = 4/3, z = 8/3"
    }
  ],
  "sources": [
    "Sekhon and Bloom, Applied Finite Mathematics, §4.2 Maximization By The Simplex Method (Example 4.2.1, the tableau and the pivot rules), CC BY 4.0, on Mathematics LibreTexts. 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)",
    "Sekhon and Bloom, Applied Finite Mathematics, §3.2 Minimization Applications (Example 2: minimize 60x + 50y; the minimum 1080 at (8, 12)), CC BY 4.0, on Mathematics LibreTexts. 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)"
  ],
  "related": [
    "linear-programming",
    "rref",
    "matrix",
    "system-of-equations"
  ],
  "changelog": []
}
