How do I solve linear programming?
Type the objective and the constraints, one per line, and pick maximize or minimize. The linear programming calculator finds the optimal value and where it occurs, and lists the objective at every corner point for two variables.
- 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
- Corner points
- 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
Optimal value of z: 400. The optimal value is 400, at x = 4, y = 8.
How it is worked out
How to calculate
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.
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: 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.
- 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.
Worked examples
Each example is checked against the calculator on every build.
- 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, §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))
- Goal Maximize, Objective z = 20x + 30y, Constraints (one per line, or split by ;) x + y <= 7 x + 2y <= 12 2x + y <= 12 gives Optimal value of z 190, Where it occurs 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))
- Goal Maximize, Objective z = 10x + 15y, Constraints (one per line, or split by ;) x + y >= 1 x + 2y <= 6 2x + y <= 6 gives Optimal value of z 50, Where it occurs 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))
- Goal Minimize, Objective z = 15x + 25y, Constraints (one per line, or split by ;) x >= 1 y >= 1 20x + 30y >= 110 gives Optimal value of z 85, Where it occurs 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))
- 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 (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))
How it works
A linear program asks for the largest (maximize) or smallest (minimize) value of z = c₁x₁ + c₂x₂ + … over every point that meets the constraints aᵢ₁x₁ + aᵢ₂x₂ + … (≤, ≥ or =) bᵢ, with every variable ≥ 0.
Corner points (two variables). The page takes every pair of boundary lines (each constraint as an equation, plus x = 0 and y = 0), solves the pair, and keeps the point if it meets every constraint. Those are the corners of the feasible region, listed from left to right (by x, then by y). It shows z at each one; the optimum is the largest (or smallest) of them.
The answer itself comes from the two-phase simplex method (the same steps the simplex method page shows), which also covers three or more variables and tells an unbounded problem from a bounded one:
- Make every right side 0 or more (multiplying a row by −1 flips ≤ and ≥). Add a slack variable to each ≤ row, a surplus variable (subtracted) to each ≥ row, and an artificial variable to each ≥ and = row.
- Phase 1 (only with artificial variables): maximize −(sum of the artificial variables). If the best is not 0, no point meets every constraint: the problem is infeasible. Otherwise drop the artificial variables.
- Phase 2: maximize z (or −z to minimize). Pivot on the most negative entry of the bottom row and, in its column, the row with the smallest ratio of right side to a positive entry. When no bottom entry is negative, the tableau is optimal. A pivot column with no positive entry means the objective has no limit: the problem is unbounded.
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₂). 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.
- Ties in the pivot column go to the first column; ties in the ratio test go to the row whose basic variable comes first. After 50 pivots the first negative column is used, so the method cannot cycle.
Output format. Every value is read and computed exactly as a fraction. The optimal value shows to 10 significant figures; each variable shows as a decimal when its decimal ends, or as a fraction p/q with its decimal to 10 significant figures (4/3 ≈ 1.333333333). 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. Corners (0, 0): 0; (0, 12): 360; (4, 8): 400; (8, 0): 320. Maximum 400 at x = 4, y = 8.
Maximize 20x + 30y; x + y ≤ 7, x + 2y ≤ 12, 2x + y ≤ 12. Corners (0, 0): 0; (0, 6): 180; (2, 5): 190; (5, 2): 160; (6, 0): 120. Maximum 190 at (2, 5).
Maximize 10x + 15y; x + y ≥ 1, x + 2y ≤ 6, 2x + y ≤ 6. Corners (0, 1): 15; (0, 3): 45; (1, 0): 10; (2, 2): 50; (3, 0): 30. Maximum 50 at (2, 2).
Minimize 15x + 25y; x ≥ 1, y ≥ 1, 20x + 30y ≥ 110. The region is unbounded upward, but z only grows there. Corners (1, 3): 90; (4, 1): 85. Minimum 85 at (4, 1).
Minimize 60x + 50y; 8x + 16y ≥ 200, 60x + 40y ≥ 960, 2x + 2y ≥ 40. Corners (0, 24): 1200; (8, 12): 1080; (15, 5): 1150; (25, 0): 1500. Minimum 1080 at (8, 12).
Other questions people ask
What is linear programming?
A way to find the largest or smallest value of a linear objective, such as profit 40x + 30y, when the variables must meet linear constraints, such as x + y ≤ 12 and 2x + y ≤ 16, and cannot be negative.
How does the corner point method work?
The constraints mark out a region of allowed points, the feasible region. The fundamental theorem of linear programming says the best value is at a corner of that region. So list the corners, work out the objective at each, and pick the largest (or smallest).
How do I type the problem?
Type the objective as an expression, such as 40x + 30y. Type each constraint on its own line with <=, >= or =, such as 2x + y <= 16. You may use ≤ and ≥, decimals, fractions such as 1/2, and any variable names. Every variable is taken to be at least 0.
What does an example look like?
Maximize 40x + 30y with x + y ≤ 12 and 2x + y ≤ 16. The corners are (0, 0), (0, 12), (4, 8) and (8, 0), giving 0, 360, 400 and 320, so the maximum is 400 at x = 4, y = 8.
What if there is no answer?
If no point meets every constraint, the problem is infeasible. If the objective can grow (or fall) forever inside the region, it is unbounded and has no maximum (or minimum). The page says which.
Can it solve problems with more than two variables?
Yes, up to 8 variables and 12 constraints. With more than two variables the region cannot be drawn flat, so the page shows the simplex tableaus instead of the corner list.