{
  "id": "linear-programming",
  "version": "f7e15588235a",
  "status": "published",
  "name": "Linear Programming Calculator",
  "question": "How do I solve linear programming?",
  "summary": "Maximizes or minimizes a linear objective subject to linear constraints (≤, ≥ or =) with every variable at least 0, showing the corner points for two variables and the exact optimum.",
  "category": "math",
  "subcategory": "algebra",
  "url": "https://www.acalculator.org/math/linear-programming-calculator",
  "markdown": "https://www.acalculator.org/math/linear-programming-calculator.md",
  "kind": "function",
  "method": "Every variable ≥ 0. The optimum of a linear objective over the feasible region is at a corner point; the page finds it with the two-phase simplex method in exact fractions and, for two variables, lists every corner with z there.",
  "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 step is exact."
  ],
  "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": "Corner points",
      "description": "The objective at each corner of the feasible region (for two variables), or the simplex tableaus otherwise.",
      "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 with x ≥ 0 and y ≥ 0: the optimum is at a corner of the feasible region; Corner (0, 0): z = 40 × 0 + 30 × 0 = 0; Corner (0, 12): z = 40 × 0 + 30 × 12 = 360; Corner (4, 8): z = 40 × 4 + 30 × 8 = 400; Corner (8, 0): z = 40 × 8 + 30 × 0 = 320; The largest value is 400, at x = 4, y = 8"
    },
    "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, §3.1 Maximization Applications (corner-point method; Examples 1 to 3), 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.01%3A_Maximization_Applications (retrieved 2026-10-05) (Example 1: corners (0, 0), (0, 12), (4, 8), (8, 0); the maximum $400 at (4, 8))"
    },
    {
      "given": {
        "goal": "max",
        "obj": "20x + 30y",
        "st": "x + y <= 7\nx + 2y <= 12\n2x + y <= 12"
      },
      "expect": {
        "value": 190,
        "solution": "x = 2, y = 5"
      },
      "source": "Sekhon and Bloom, Applied Finite Mathematics, §3.1 Maximization Applications (corner-point method; Examples 1 to 3), 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.01%3A_Maximization_Applications (retrieved 2026-10-05) (Example 2: the maximum $190 at (2, 5))"
    },
    {
      "given": {
        "goal": "max",
        "obj": "10x + 15y",
        "st": "x + y >= 1\nx + 2y <= 6\n2x + y <= 6"
      },
      "expect": {
        "value": 50,
        "solution": "x = 2, y = 2"
      },
      "source": "Sekhon and Bloom, Applied Finite Mathematics, §3.1 Maximization Applications (corner-point method; Examples 1 to 3), 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.01%3A_Maximization_Applications (retrieved 2026-10-05) (Example 3, mixed constraints: the maximum 50 at (2, 2))"
    },
    {
      "given": {
        "goal": "min",
        "obj": "15x + 25y",
        "st": "x >= 1\ny >= 1\n20x + 30y >= 110"
      },
      "expect": {
        "value": 85,
        "solution": "x = 4, y = 1"
      },
      "source": "Sekhon and Bloom, Applied Finite Mathematics, §3.2 Minimization Applications (Examples 1 and 2), 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) (Example 1: the minimum $85 at (4, 1))"
    },
    {
      "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 (Examples 1 and 2), 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) (Example 2: the minimum 1080 at (8, 12))"
    }
  ],
  "sources": [
    "Sekhon and Bloom, Applied Finite Mathematics, §3.1 Maximization Applications (the corner-point method and the fundamental theorem of linear programming; Examples 1 to 3), 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.01%3A_Maximization_Applications (retrieved 2026-10-05)",
    "Sekhon and Bloom, Applied Finite Mathematics, §3.2 Minimization Applications (Examples 1 and 2), 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)",
    "Sekhon and Bloom, Applied Finite Mathematics, §4.2 Maximization By The Simplex Method (the tableau, pivot column, ratio test and pivot), 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)"
  ],
  "related": [
    "simplex-method",
    "system-of-equations",
    "rref",
    "matrix"
  ],
  "changelog": []
}
