Optimization Solver

Solve linear programs and find the minimum or maximum of a smooth function. Two-variable problems are solved at the corners of a drawn feasible region, larger ones by the simplex method, and gradient descent traces its path over a heat map of f(x, y).

Calculator Numbers & Math Updated Oct 3, 2026
How to Use
  1. For linear programming, write the objective on the first line — maximize 40x + 30y (or minimize …) — then one constraint per line: 2x + y <= 100, x + y <= 80, x >= 0, y >= 0.
  2. With two variables you get the feasible-region graph: the shaded polygon, every constraint line, the corner points with their objective values, and the optimum marked. The default solves to 2600 at x = 20, y = 60.
  3. With three or more variables the simplex method is used instead; it reports the optimal value of every variable and the objective, with no graph. It assumes every variable is ≥ 0.
  4. For a nonlinear function, open Gradient Descent: type f(x, y), choose Minimize or Maximize, and set the start point, the learning rate and the number of steps (up to 5,000). The path is drawn over a heat map of f.
  5. Read the warnings: unbounded (the objective can grow without limit), infeasible (the constraints contradict each other), or diverged (the learning rate is too large).
Input
Optimum

Feasible region / descent path

Optimum
—
At point
—
Corner points
—
Method
—

Worked Example

Profit: maximize 40x + 30y with 2x + y ≤ 100, x + y ≤ 80, x ≥ 0, y ≥ 0 (the default). The two resource lines cross where 2x + y = 100 and x + y = 80, so x = 20 and y = 60. The feasible corners are (0, 0), (50, 0), (20, 60) and (0, 80), worth 0, 2000, 2600 and 2400, so the best plan is 20 of the first product and 60 of the second.

Cost: minimize 3x + 2y with x + y ≥ 10, x + 3y ≥ 15, x ≥ 0, y ≥ 0. The feasible region is open upwards and to the right, with corners (0, 10), (7.5, 2.5) and (15, 0), costing 20, 27.5 and 45. The minimum is 20 at x = 0, y = 10.

The common mistake: trusting one gradient-descent run. On the wavy surface sin x + cos y + 0.1(x² + y²), starting at (2, 2) with rate 0.15 stops at 0.65066 at (3.83747, 2.59574) with the gradient essentially zero. That is only a local minimum: starting at (−2, 2) instead reaches −0.975481 at (−1.30644, 2.59574) in 94 steps. Gradient descent finds the bottom of the valley it starts in, so try several starts on a bumpy function.

Show Work

Enter a linear program or a function to minimize to see the working.

Formulas

Linear program
maximize or minimize cᵀx subject to Ax ≤ b (or ≥, =)
Corner point
a₁x + b₁y = c₁ and a₂x + b₂y = c₂ ⇒ x = (c₁b₂ − b₁c₂)/(a₁b₂ − b₁a₂)
Simplex ratio test
leaving row = the smallest bᵢ/aᵢⱼ with aᵢⱼ > 0
Big-M
each ≥ or = row gets an artificial variable costing −M in the objective
Gradient descent
xₖ₊₁ = xₖ − η∇f(xₖ) (+η∇f to maximize)
Central-difference gradient
∂f/∂x ≈ (f(x + h, y) − f(x − h, y))/(2h), h = 10⁻⁶

Linear Programming and Gradient Descent

Leonid Kantorovich formulated linear programming in 1939 to plan production in Soviet plywood factories, and Tjalling Koopmans applied it to shipping during the Second World War; the two shared the 1975 Nobel Prize in economics for it. George Dantzig invented the simplex method in 1947 while working on planning problems for the US Air Force, and it remains one of the most widely used algorithms in operations research.

Gradient descent is older: Augustin-Louis Cauchy proposed stepping along the negative gradient in 1847, as a way to solve systems of equations for astronomical orbits. Its stochastic variants are now the standard way to train neural networks, where the learning rate is still the setting that most often decides whether training converges.

About This Tool

The Optimization Solver handles two kinds of problem. Linear programs are typed as plain text, one constraint per line; with two variables every corner is found and drawn, and with more the Big-M simplex method gives the optimum. Smooth nonlinear functions of one or two variables are minimised or maximised by gradient descent, with the whole path drawn so overshooting and local minima are easy to see.

Everything runs in your browser; nothing is uploaded.

Related tools: Linear Algebra Lab, System of Equations Calculator, and Calculus Workbench.

Frequently Asked Questions

Why is the optimum always at a corner?

A linear objective has no peaks or valleys inside the feasible region: moving in the right direction always improves it until a constraint stops you, so the best value is at a corner (vertex). The tool intersects every pair of constraint lines, keeps the feasible points and evaluates the objective at each. For the default, 40x + 30y is 0 at (0, 0), 2000 at (50, 0), 2400 at (0, 80) and 2600 at (20, 60), the maximum.

What about more than two variables?

The simplex method (Big-M form) takes over, with ≤, ≥ and = constraints, and every variable is assumed to be ≥ 0. The 3-variable preset, maximize 3a + 2b + 4c with a + b + 2c ≤ 4, 2a + 3c ≤ 5 and 2a + b + 3c ≤ 7, gives a = 2.5, b = 1.5, c = 0 and a maximum of 10.5.

How does gradient descent find a minimum?

From the start point it repeatedly steps against the gradient, xₖ₊₁ = xₖ − η∇f(xₖ), where η is the learning rate; for Maximize it steps with the gradient. The gradient is estimated by central differences, and the run stops when its length falls below 10⁻⁷ or the step limit is reached. On the bowl (x − 3)² + (y − 2)² with η = 0.1, each step cuts the distance to (3, 2) by 20%, and it converges from (0, 0) in 83 steps.

How do I choose the learning rate?

Small enough not to overshoot along the steepest direction. On x² + 10y², each step multiplies y by 1 − 20η. With η = 0.04 that factor is 0.2 and the descent converges; with η = 0.1 it is −1, so y flips between 5 and −5 for ever and f stays at 250; with η = 0.12 it is −1.4 and the tool reports divergence after 36 steps.

Why does it say unbounded or infeasible?

Unbounded means the feasible region runs off to infinity in a direction that keeps improving the objective, so there is no best value; usually a constraint is missing. Infeasible means no point satisfies every constraint at once, as with x ≤ 1 and x ≥ 5, so there is nothing to optimise.

How do I use the Optimization Solver?

Just type your numbers. The answer shows up right away — there is no button to press. Change anything and it updates by itself.

Does it cost anything or need an account?

No. The tool is completely free, there is no account to create, and it keeps working offline after the page first loads.

Is anything I type uploaded?

No. The tool works entirely on your device, so the values you enter never leave your browser.

Common Use Cases

Product mix

Maximize 5x + 4y with 6x + 4y ≤ 24 and x + 2y ≤ 6: 21 at x = 3, y = 1.5.

Cost minimisation

Minimize 3x + 2y with x + y ≥ 10 and x + 3y ≥ 15: 20 at x = 0, y = 10.

Coursework

Every corner point is listed with its objective value, so a by-hand corner-point table can be checked line by line.

Machine-learning intuition

See a learning rate of 0.04 converge on x² + 10y² and 0.12 blow up.

Local minima

On the wavy surface, starting at (2, 2) finds a valley at 0.65066; starting at (−2, 2) finds the lower one at −0.975481.

Last updated: