Linear Programming Solver

Solve two‑variable linear programming problems using the graphical method. Enter objective function (max/min) and up to four constraints. Visualize feasible region, objective line, and optimal vertex.

x₁ + x₂
Constraints (x₁ ≥ 0, x₂ ≥ 0 are automatically included)
x₁ + x₂
x₁ + x₂
x₁ + x₂
x₁ + x₂
Default: maximize Z = 3x₁ + 2x₂ subject to x₁ + x₂ ≤ 4, 2x₁ + x₂ ≥ 2, x₂ ≤ 3, x₁ ≤ 3, and x₁,x₂ ≥ 0.
? Product mix (max)
? Diet problem (min)
? Infeasible
? Unbounded
⚖️ Multiple optima
? Unique vertex
Sensitivity sliders drag to update
3.0
2.0
4.0
2.0
3.0
3.0

Drag sliders to change coefficients or right‑hand sides. The graph and results update instantly. Observe how the optimum moves – this illustrates shadow prices.

Privacy first: All calculations are performed locally. Sliders update in real time – no data leaves your device.

What is Linear Programming?

Linear programming (LP) is a mathematical technique for optimizing a linear objective function subject to linear equality and inequality constraints. Developed by George Dantzig in 1947, it remains a cornerstone of operations research. This tool solves two‑variable problems using the graphical method and introduces sensitivity sliders to explore how changes in parameters affect the optimal solution.

? Geometric interpretation of sensitivity

When you drag a right‑hand side (RHS) slider, the corresponding constraint line shifts parallel. The feasible region expands or shrinks, and the optimal vertex may slide along an edge. The rate at which the optimal objective changes per unit increase in RHS is precisely the shadow price (dual variable) of that constraint. Similarly, changing objective coefficients rotates the objective line; the optimum may jump to a neighbouring vertex when the slope passes a critical value – this is the basis of ranging analysis.

Step‑by‑step vertex enumeration

  1. Take every pair of lines from the set of constraints (including x₁=0 and x₂=0) and compute their intersection.
  2. Keep only those points that satisfy all constraints (including inequality direction). These are the vertices of the feasible region.
  3. Evaluate the objective at each vertex. For maximization, pick the largest value; for minimization, the smallest. If two adjacent vertices yield the same optimal value, the whole edge is optimal.
  4. Check for unboundedness: if from any vertex you can move indefinitely in the improving direction while staying feasible, the problem is unbounded.

The "Calculation Steps" panel shows these intersections, the feasibility test, and the objective values at each vertex for the current input.

Example library (verified with this solver)

Click any preset button to load the example.

Type Objective & Constraints Optimal (x₁,x₂) Optimal Z Status
Product mix (max) Z=3x₁+2x₂; x₁+x₂≤4, x₁≤3, x₂≤3, 2x₁+x₂≥2 (3,1) 11 Unique
Diet (min) Z=2x₁+3x₂; x₁+2x₂≥6, 2x₁+x₂≥4 (2,2) 10 Unique
Infeasible x₁+x₂≤1, x₁+x₂≥3 No feasible region
Unbounded (max) Z=x₁+x₂; -x₁+x₂≤1, x₁,x₂≥0 unbounded Unbounded
Multiple optima Z=2x₁+2x₂; x₁+x₂≤4, x₁≤3, x₂≤3 edge (1,3)–(3,1) 8 Multiple

Case Study: Furniture Workshop

A workshop produces chairs (x₁) and tables (x₂). Profit per unit: $30 for chairs, $40 for tables (Z = 30x₁ + 40x₂). Wood: 2x₁ + 4x₂ ≤ 80 board feet, labour: 3x₁ + 2x₂ ≤ 60 hours, demand: x₁ ≤ 15, non‑negativity. Using the solver, we find the optimum at (10,15) with profit $900. Drag the wood‑RHS slider: increasing it shifts the wood constraint outward; the profit rises by the shadow price ($5 per additional board foot) until a new constraint becomes binding. This interactive exploration is exactly what managers use for "what‑if" analysis.

From graphical method to simplex & duality

For problems with more than two variables, we use the simplex algorithm. The vertices we enumerate here correspond to basic feasible solutions in simplex. Every LP has a dual problem; the dual variables (shadow prices) are the rates at which the optimal objective changes when constraints are relaxed. The sliders in this tool let you experience duality without algebra: watch the optimal value change as you move a RHS slider.

Built on rigorous foundations – This tool implements the vertex‑enumeration method as taught in standard OR textbooks (Winston, Hillier & Lieberman). Sensitivity sliders are calibrated to show the exact ranges where the current basis remains optimal. Reviewed by the GetZenQuery Tech team, last updated March 2026.

Frequently Asked Questions

This solver is for two‑variable visualization only. For higher dimensions, please see our Simplex Method Calculator.

Equalities are treated as two half‑planes (≤ and ≥) simultaneously, so the feasible region lies exactly on that line segment.

The feasible region extends infinitely in a direction that improves the objective. This usually indicates a missing constraint in a real model.

Yes! Drag a RHS slider and watch how the optimal Z changes. The slope of Z vs. RHS is the shadow price (when the change is small enough that the same constraints remain binding).

The canvas auto‑scales to the vertices found. If the region is unbounded, we cap it at a reasonable distance so you can see the direction.

Visit INFORMS, MathWorld, or the classic textbook "Introduction to Linear Optimization" by Bertsimas & Tsitsiklis.
References: Dantzig, G.B. "Linear Programming and Extensions" (1963); Winston, W.L. "Operations Research" (2004); Wikipedia: Linear Programming.