Home › Calculators › Linear Programming Solver

Linear Programming Solver

Type an objective function and constraints in plain notation like 3x + 5y and 2x + y ≤ 18. The solver finds the exact optimum with the two-phase simplex method, shows every tableau with the pivot highlighted, and for two-variable problems draws the feasible region with its corner points.

Last updated:

Write terms like 3x, -0.5y, 2/3 x1. Variables can be any names (x, y, x1, chairs). Write x >= 0 lines yourself if you untick non-negativity.

Advertisement
Advertisement

How to use the Linear Programming Solver

  1. Choose Maximize or Minimize and type the objective, for example 3x + 5y.
  2. Enter the constraints, one per line, such as 3x + 2y <= 18 or x + y >= 4.
  3. Leave “All variables ≥ 0” ticked for the usual non-negativity conditions, or untick it for free variables.
  4. Press Solve to see the optimal value, the variable values and which constraints are binding.
  5. Read the tableau steps below, and for two variables check the graph and corner point table.

Standard form and the simplex tableau

A linear program in this tool has the form maximize (or minimize) z = c₁x₁ + c₂x₂ + … + cₙxₙ subject to constraints aᵢ₁x₁ + … + aᵢₙxₙ (≤, ≥ or =) bᵢ, usually with every xⱼ ≥ 0. To start the simplex method each constraint becomes an equation:

Constraint typeBecomesStarting basic variable
3x + 2y ≤ 183x + 2y + s₁ = 18slack s₁ = 18
x + y ≥ 4x + y − e₂ + a₂ = 4artificial a₂ = 4 (removed in phase 1)
x + y = 10x + y + a₃ = 10artificial a₃ = 10 (removed in phase 1)
negative right side, e.g. x − y ≥ −2multiply by −1: −x + y ≤ 2slack

The objective row of the tableau holds z − c·x = 0, so its entries start as the negatives of the objective coefficients. Each pivot divides the pivot row by the pivot element and clears the rest of the pivot column, exactly like Gauss–Jordan elimination.

Worked example

Maximize z = 3x + 5y subject to x ≤ 4, 2y ≤ 12 and 3x + 2y ≤ 18 with x, y ≥ 0 (the default problem above).

  1. The most negative entry in the objective row is −5, so y enters. Ratios: row 2 gives 12 ÷ 2 = 6, row 3 gives 18 ÷ 2 = 9, so s₂ leaves.
  2. After pivoting, x has −3 in the objective row, so x enters. Ratios: row 1 gives 4, row 3 gives 6 ÷ 3 = 2, so s₃ leaves.
  3. No negative entries remain: the optimum is x = 2, y = 6, z = 36. Constraints 2 and 3 are binding; constraint 1 has slack 2.

The graph confirms it: the corner points are (0, 0), (4, 0), (4, 3), (2, 6) and (0, 6), with z values 0, 12, 27, 36 and 30.

Tips for setting up word problems

  • Define the variables first: "x = number of chairs, y = number of tables". You can even type the names (chairs, tables).
  • One resource, one constraint: hours of labor, kilograms of material, budget. Coefficients are how much of the resource each unit uses.
  • "At least" means ≥, "at most" or "no more than" means ≤.
  • Check units: every term in a constraint must be in the same unit as its right-hand side.

Frequently asked questions

What is linear programming?

Linear programming finds the best value (largest profit, smallest cost) of a linear objective such as z = 3x + 5y when the variables must satisfy linear constraints like 3x + 2y ≤ 18. The set of points that satisfy every constraint is the feasible region, and the optimum, when it exists, is at a corner of that region.

How does the simplex method work?

It starts at a corner of the feasible region and repeatedly moves to an adjacent corner that improves the objective. In the tableau, the entering variable is the one with the most negative entry in the objective row, and the leaving variable is chosen by the minimum ratio test (right-hand side ÷ positive column entry). When no negative entries remain, the current corner is optimal.

What are slack, surplus and artificial variables?

A slack variable turns a ≤ constraint into an equation (3x + 2y + s = 18) and measures unused capacity. A surplus variable is subtracted from a ≥ constraint. Artificial variables are temporary helpers for ≥ and = rows so the simplex has a starting point; phase 1 removes them, and if it cannot, the problem is infeasible.

How is a minimization problem solved?

Minimizing z is the same as maximizing −z, so the solver negates the objective, runs the same simplex steps and reports the minimum as the negative of the final value. The tableau notes say when this conversion is used.

What does unbounded or infeasible mean?

Infeasible means no point satisfies all constraints together, for example x + y ≤ 4 and x + y ≥ 6. Unbounded means the objective can improve forever because the feasible region is open in that direction; in a real model this usually means a constraint is missing.

When is the graphical method shown?

The feasible region is drawn whenever the problem has exactly two variables. The first variable is on the horizontal axis. The corner point table lists every vertex of the region with its objective value, which is the classic graphical method taught alongside the simplex method.

Can I use more than two variables?

Yes. The simplex solver handles up to 12 variables and 20 constraints with exact fractions. Only the graph is limited to two variables; the tableau steps work for any size.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

Matrix CalculatorAdd, multiply, invert and row-reduce matrices up to 5×5 with exact fractions and steps.Linear Interpolation CalculatorInterpolate or extrapolate y for any x from two points or a data table, with steps and a plot.Factor Tree GeneratorDraw the prime factor tree of any number as a printable diagram, with exponent form and steps.Graphing CalculatorPlot multiple functions with zoom, pan, intersections and a value table.Exponent CalculatorRaise any number to a power, including negative and fractional exponents.Logarithm CalculatorCalculate log in any base, ln, log10, log2 and antilog with change-of-base steps.Quadratic Equation SolverSolve ax² + bx + c = 0 with exact roots, steps, vertex and a parabola graph.Prime Number CheckerCheck if a number is prime, factor it with a factor tree and list primes in a range.GCF and LCM CalculatorFind the GCF and LCM of two or more numbers with Euclid steps and prime factorization.Cubic Yard CalculatorConvert length, width and depth in any unit to cubic yards, cubic feet, m³ and material weight.Factorial CalculatorExact n! up to 5000! with digit count, trailing zeros and double factorial.Prime Factorization CalculatorFind prime factors in exponent form with a factor tree, divisor count and divisors list.Modulo CalculatorCalculate a mod n and the quotient, with floored, truncated and Euclidean rules.Exponential Growth CalculatorExponential growth and decay: final amount, rate or time, discrete or continuous.Linear Regression CalculatorLeast-squares line of best fit: slope, intercept, r, r², predictions and a scatter plot.System of Equations SolverSolve 2×2, 3×3 and 4×4 linear systems with exact fractions and step-by-step working.Cubic Equation SolverSolve ax³ + bx² + cx + d = 0 for real and complex roots with steps and a graph.Summation CalculatorEvaluate sigma notation: sum any expression in n from a to b with partial sums and a chart.Arithmetic Sequence CalculatorFind the n-th term, sum and full list of an arithmetic sequence, or d from two terms.Geometric Sequence CalculatorFind the n-th term, sum and infinite sum of a geometric sequence, or r from two terms.Fibonacci CalculatorExact n-th Fibonacci number (BigInt), sequence lists, Fibonacci check and golden ratio.Factors CalculatorAll factors and factor pairs of a number, prime factors, divisor count and perfect check.Depth of Field CalculatorNear and far focus limits, depth of field and hyperfocal distance for any camera or lens.Crop Factor CalculatorCrop factor, full-frame equivalent focal length and aperture, and field of view for any sensor.Completing the Square CalculatorRewrite ax² + bx + c in vertex form a(x − h)² + k step by step and solve it.Derivative CalculatorSymbolic derivative of any f(x) up to 5th order, with steps, slope at a point and a graph.Exposure Value CalculatorEV from aperture, shutter and ISO, or solve any missing setting with sunny 16 presets.Factoring Trinomials CalculatorFactor trinomials and polynomials: GCF, ac method, difference of squares, cubes, with steps.Integral CalculatorDefinite integral of f(x) from a to b with adaptive Simpson, area graph and antiderivative.Least Common Denominator CalculatorFind the LCD of two or more fractions and rewrite them as equivalent fractions, with steps.Limiting Reactant CalculatorFind the limiting reactant, theoretical yield and leftover excess from an equation.Parabola CalculatorVertex, focus, directrix, axis, intercepts and graph of a parabola from its equation.Polynomial Root FinderFind all real and complex roots of a polynomial up to degree 10, with the factored form.Prime Number List GeneratorList all primes in a range or the first N primes with a fast sieve; copy or download the list.Quadratic Regression CalculatorFit y = ax² + bx + c (or up to degree 6) to x, y data with R², predictions and a graph.Scatter Plot MakerPaste X,Y pairs for a scatter plot with trendline, equation, r and R². Download PNG.Synthetic Division CalculatorDivide polynomials by x − c (synthetic table) or any polynomial (long division) with steps.3D Graphing CalculatorPlot z = f(x, y) surfaces and 3D parametric curves; rotate, zoom, add contours, save PNG.Set CalculatorUnion, intersection, difference and complement of up to 4 sets, with a Venn diagram and counts.Table of Values CalculatorMake an x/y table for any function with a start, end and step, then plot it or copy CSV.Algebra CalculatorSimplify, expand and factor algebraic expressions with exact answers and step-by-step working.Determinant CalculatorDeterminant of a 2×2 to 8×8 matrix with exact fractions and cofactor or row-reduction steps.Differential Equation SolverSolve first- and second-order ODEs step by step, with initial conditions, an RK4 check and a graph.Domain and Range CalculatorFind the domain and range of a function in interval notation, with steps and a graph.Eigenvalue and Eigenvector CalculatorEigenvalues (real or complex), eigenvectors and the characteristic polynomial of a square matrix.Equation SolverSolve any equation for x: exact roots, complex roots, numeric answers, steps and a graph.Inequality CalculatorSolve linear, quadratic, rational and absolute value inequalities with steps and a number line.Inverse Function CalculatorFind the inverse f⁻¹(x) of a function with steps, domain restrictions and a graph.Laplace Transform CalculatorLaplace transform of f(t) with the table rule used for each term and the region of convergence.Limit CalculatorEvaluate limits at a point or at infinity, one-sided or two-sided, with steps, table and graph.Matrix Inverse CalculatorFind the inverse of a 2×2 to 8×8 matrix in exact fractions with Gauss–Jordan or adjugate steps.Partial Derivative CalculatorPartial derivatives ∂/∂x, ∂/∂y, second and mixed orders with steps, gradient and Hessian.RREF CalculatorRow reduce any matrix to RREF with exact fractions, every row operation, pivots and rank.Stem and Leaf Plot MakerMake stem-and-leaf plots (standard, split stems or back-to-back) with a key; copy or save PNG.Taylor Series CalculatorTaylor and Maclaurin polynomials of any f(x) to order n, with exact coefficients and a graph.Antilog CalculatorInverse logarithm (antilog) in base 10, e, 2 or any base, with steps and scientific notation.Asymptote CalculatorFind vertical, horizontal and slant asymptotes and holes of a function, with graph and reasoning.Cramer's Rule CalculatorSolve 2x2 and 3x3 linear systems by Cramer's rule with every determinant shown step by step.Dot Plot MakerMake a dot plot or line plot from data or a frequency table; download PNG or SVG.Exponential Regression CalculatorFit y = a·bˣ or y = a·e^(kx) to data with r², predictions, residuals and a plot.Extended Euclidean Algorithm CalculatorFind gcd(a, b) and Bézout coefficients x, y with the full step-by-step division table.Function Composition CalculatorFind f(g(x)), g(f(x)), f + g, f · g and f / g with values at a point and domains.X and Y Intercept CalculatorFind the x- and y-intercepts of lines, curves and functions with steps and a graph.Line Intersection CalculatorFind where two lines cross from equations, points or slopes, with parallel checks and a graph.Modular Exponentiation CalculatorCompute a^b mod m for huge numbers with square-and-multiply steps (BigInt).Modular Inverse CalculatorFind a⁻¹ mod m with the extended Euclidean algorithm, step by step, for huge numbers too.Nth Term CalculatorFind the nth term formula of a sequence: arithmetic, geometric, quadratic or cubic.Partial Fraction Decomposition CalculatorSplit a rational function into partial fractions with the setup, equations and solution.
See all 74 Algebra & Calculus Calculators →