Advertisement
Advertisement
OPTIMISATION

Linear Programming Calculator — two variables by the corner-point method

Enter an objective function and a set of linear constraints and get every vertex of the feasible region, the objective value at each one, and the optimum with its corner named.

The objective is c₁x + c₂y. Both variables are constrained to be non-negative, which is the standard form.
Four tokens per line: the coefficient of x, the coefficient of y, an operator (<=, >= or =), then the right-hand side. So "3 2 <= 18" means 3x + 2y ≤ 18. Up to eight constraints.
Vertices are found by exact linear solves; this affects display only.
Optimum value of the objective
 
x at the optimum
y at the optimum
Feasible vertices found
Binding constraints
Corner points:
Tip: if two adjacent corners give the same optimal value, every point on the edge between them is also optimal. The tool says so when it happens, because reporting one of them as "the" answer hides a whole line of equally good solutions.
Advertisement

The linear programming calculator above solves a two-variable linear program by the corner-point method. It intersects every pair of constraint boundaries, keeps the intersections that satisfy all the other constraints, evaluates the objective at each surviving vertex, and reports the best one. Because it lists every corner rather than only the winner, you can see the whole feasible region as a table of numbers.

Arb Digital publishes it because the corner-point method is where linear programming is actually understood, before the simplex tableau turns it into bookkeeping. Our system of equations calculator solves systems of equalities with no objective to optimise; this page adds inequalities and something to maximise, which is what makes it a program rather than a system.

What This Linear Programming Calculator Does

It takes an objective c₁x + c₂y to maximise or minimise, and up to eight linear constraints, each of the form ax + by compared with a constant. The non-negativity conditions x ≥ 0 and y ≥ 0 are always applied, because they are part of the standard form and because omitting them changes the geometry completely — without them the feasible region is rarely bounded.

The algorithm is exhaustive rather than clever. With k constraint lines including the two axes there are k choose 2 pairs, and each pair either intersects in a single point or is parallel. Every intersection is tested against every constraint, and those that pass are the vertices of the feasible polygon. For eight constraints that is forty-five solves, which is trivial work for a browser and completely reliable, unlike a hand sketch.

Two failure modes get their own written answers. If no intersection satisfies all the constraints, the feasible region is empty and the problem is infeasible; the tool says so and does not report a number. If the optimum is only achieved by running off to infinity, the problem is unbounded in the direction of improvement; the tool detects this by placing a very large artificial box around the region and checking whether the winning vertex sits on that box.

How to Use It

  1. Enter the objective coefficients and choose maximise or minimise. A coefficient may be negative, which is how you express a cost you want to reduce inside a maximisation.
  2. Write one constraint per line as four tokens: the x coefficient, the y coefficient, the operator, and the right-hand side. Write 3x + 2y ≤ 18 as "3 2 <= 18".
  3. Leave out x ≥ 0 and y ≥ 0. They are applied automatically, so adding them again is harmless but unnecessary.
  4. Read the corner table rather than only the headline. Seeing the objective value at every vertex is what makes the answer convincing.
  5. Watch for the tie message. If two corners share the optimal value the whole edge between them is optimal, and that is usually worth knowing.

The Formula and How It Is Calculated

The feasible region of a linear program is an intersection of half-planes, which makes it a convex polygon, possibly unbounded. A linear objective has no interior maximum on a convex set, so if an optimum exists it is attained at a vertex — or along a whole edge, when the objective happens to be parallel to that edge. Checking every vertex therefore checks everything.

Each vertex comes from solving a 2×2 system. For boundary lines a₁x + b₁y = c₁ and a₂x + b₂y = c₂, the determinant is a₁b₂ − a₂b₁, and if it is non-zero the intersection is x = (c₁b₂ − c₂b₁) ÷ det and y = (a₁c₂ − a₂c₁) ÷ det by Cramer's rule. A zero determinant means the lines are parallel and contribute no vertex.

Work the default through. Maximise 3x + 5y subject to x ≤ 4, 2y ≤ 12, 3x + 2y ≤ 18 and both variables non-negative. The feasible corners are (0,0), (4,0), (4,3), (2,6) and (0,6). The objective at each is 0, 12, 27, 36 and 30. The maximum is 36 at (2,6), where the second and third constraints are both binding. This is the standard worked example in every introductory text, and the tool reproduces it corner for corner.

Advertisement

Why the Optimum Sits at a Corner

Picture the objective as a family of parallel lines, one for each value it might take. Optimising means sliding that family across the feasible region in the improving direction until it is about to leave. The last contact is either a single vertex or, if the objective lines happen to be parallel to a boundary edge, that entire edge. There is no way for the last contact to be an interior point, because from an interior point you can always move further in the improving direction.

Wolfram MathWorld's page on the simplex method describes the algorithm as testing adjacent vertices of the feasible polytope in sequence, improving or holding the objective at each step. That is the same insight scaled up: with many variables you cannot enumerate every vertex, so you walk along edges instead. In two variables enumeration is cheap enough that walking is unnecessary.

The tie case deserves attention because it is where a naive solver misleads. When the objective is parallel to a binding edge, both its endpoints score identically and every point between them does too. A solver that reports one endpoint has told you the truth but not the whole truth, and in a production planning problem the difference matters: there may be a solution on that edge with better properties on some criterion the model never captured.

Infeasible and Unbounded, and How to Tell Them Apart

Infeasible means the constraints contradict each other and no point satisfies them all. Ask for x + y ≤ 2 and x + y ≥ 8 together and there is nothing to optimise over. The tool finds no vertex passing every test and reports that in words. The usual cause in a real model is a minimum requirement and a capacity limit that were set independently and never reconciled.

Unbounded means the feasible region is fine but extends forever in a direction that keeps improving the objective. Maximise x + y subject only to x − y ≤ 1 and you can travel out along the region indefinitely. The tool detects this by imposing a very large artificial box and noticing when the optimum lands on it, which is a reliable test because a genuinely bounded problem never touches a boundary that far out.

An unbounded result in a real model is almost always a missing constraint rather than an infinite profit. Something in the world limits the answer — capacity, budget, demand, raw material — and it was left out of the formulation. Our break-even calculator and profit margin calculator handle the simpler single-product versions of the same planning question.

What This Method Cannot Do

It is limited to two decision variables, because the corner-point method depends on being able to draw and enumerate a plane region. Three variables give a polyhedron whose vertices come from triples of planes, which is still enumerable but no longer visualisable; beyond that the count of candidate vertices explodes and the simplex method or an interior-point method becomes necessary. MathWorld's linear programming page summarises the standard approaches.

It also assumes the variables are continuous. If x and y must be whole numbers — you cannot build 2.4 machines — the problem is an integer program, and rounding the continuous answer is not a valid solution method. The rounded point may be infeasible, and even when feasible it may be far from the best integer point. Integer programming needs branch and bound or cutting planes, which are a different subject.

Finally, everything here is linear. If the objective has a term in xy, or a constraint involves a square, the feasible region stops being a polygon and the optimum can sit in the interior. Our quadratic inequality calculator deals with the single-variable non-linear case, and our matrix calculator handles the linear algebra that underpins the constraint solves here.

Need a solver that shows every candidate?

Arb Digital builds free maths tools that list the working set, not just the winning answer.

Browse All Free Tools Talk To Our Team

Common Mistakes to Avoid

  • Forgetting the non-negativity conditions — without x ≥ 0 and y ≥ 0 most feasible regions are unbounded and the answer changes entirely.
  • Reversing an inequality — a ≥ written as ≤ usually still produces a feasible region, so the error shows up as a wrong answer rather than an error message.
  • Rounding a continuous answer to get integers — the rounded point may violate a constraint, and even when it does not it is often not the best integer solution.
  • Reporting one corner when two are tied — a tie means the whole edge is optimal, and the endpoint you happened to list first is not more correct than the rest of it.
  • Treating unbounded as good news — it means a real limit is missing from the model, not that the objective can genuinely grow forever.

Related Free Tools From Arb Digital

Solve simultaneous equalities with the system of equations calculator, work through the underlying linear algebra with the matrix calculator, find where revenue covers cost with the break-even calculator, check a margin with the profit margin calculator, or solve a non-linear single-variable condition with the quadratic inequality calculator. The full free online tools hub lists every mathematics tool we publish.

Frequently Asked Questions

What is the corner-point method?

It finds every vertex of the feasible region, evaluates the objective at each, and takes the best. It works because a linear objective on a convex polygon attains its optimum at a vertex or along an edge, never strictly inside.

How many variables can this handle?

Two. The method depends on enumerating the vertices of a plane region, and beyond three variables the number of candidate vertices grows too quickly for exhaustive checking to be practical.

What does infeasible mean?

The constraints contradict one another, so no point satisfies them all and there is nothing to optimise over. In a real model it usually means a minimum requirement and a capacity limit were set without reference to each other.

What does unbounded mean?

The feasible region extends forever in a direction that keeps improving the objective. It nearly always signals a missing constraint rather than a genuinely infinite result.

Can two corners give the same optimal value?

Yes, when the objective lines are parallel to a binding edge. Every point along that edge is then equally optimal, and the tool reports the tie rather than picking one arbitrarily.

Are x and y forced to be non-negative?

Yes. Those two conditions are part of the standard form and are always applied, which is why they do not need to appear in the constraint list.

Can I get integer answers?

Not from this method. It solves the continuous relaxation, and rounding its answer is not a valid way to solve an integer program because the rounded point may be infeasible or far from optimal.

What is a binding constraint?

One that holds with equality at the optimum, meaning the solution sits exactly on that boundary. Binding constraints are the ones actually limiting the objective; the rest have slack.

This page explains a standard optimisation method for educational purposes. A model is only as good as its constraints, and a result from any solver describes the formulation it was given rather than the situation that formulation was meant to represent.

Advertisement
Advertisement

Take it further