Skip to content
LoveToCalc

Linear programming calculator

Type the inequalities and the objective function, choose largest or smallest, and see the region drawn and the corner method worked through line by line.

Inequalities

One inequality per row, in x and y. Type <= for ≤ and >= for ≥. The multiplication sign can be left out: 2x, 3(x + y). Empty rows are left out.

Find
Try:

Drag to move the graph; pinch or scroll to zoom. With the keyboard: arrow keys move, + and − zoom, 0 resets.

Answer and working

Answer

The largest value is z = 20, at (4, 4).

Working

  1. Each inequality is bounded by a line, where its two sides are equal.

    • (1)x = 0
    • (2)y = 0
    • (3)x plus y = 8
    • (4)(2 times x) plus y = 12
  2. Intersect the lines two at a time. A point that satisfies every inequality is a corner of the region.

    • (1) and (2) meet at (0, 0): a corner.
    • (1) and (3) meet at (0, 8): a corner.
    • (1) and (4) meet at (0, 12): not in the region: in (3) 0 plus 12 = 12 > 8
    • (2) and (3) meet at (8, 0): not in the region: in (4) (2 times 8) plus 0 = 16 > 12
    • (2) and (4) meet at (6, 0): a corner.
    • (3) and (4) meet at (4, 4): a corner.
  3. The region is bounded: a polygon with 4 corners. Put each corner into z = (3 times x) plus (2 times y).

    The objective function at each corner
    CornerValue
    (0, 0)z = (3 times 0) plus (2 times 0) = 0
    (6, 0)z = (3 times 6) plus (2 times 0) = 18
    (4, 4)z = (3 times 4) plus (2 times 4) = 20(best)
    (0, 8)z = (3 times 0) plus (2 times 8) = 16

How to use it

The corner method

Each inequality is bounded by a straight line, and the region that satisfies all of them is a polygon, or a region that continues without end. The calculator intersects the boundary lines two at a time. A point where two lines meet and every inequality holds is a corner of the region; a point that breaks one of the inequalities is outside, and the working shows which row it breaks and by how much.

Then the objective function is evaluated at every corner, and the largest or smallest value is the answer. This rests on the corner theorem: on a bounded region, a linear function takes its largest and its smallest value at a corner.

Worked example

x ≥ 0, y ≥ 0, x + y ≤ 8 and 2x + y ≤ 12, largest value of z = 3x + 2y.

The lines x = 0 and x + y = 8 meet at (0, 8), which satisfies 2x + y ≤ 12: a corner. The lines x + y = 8 and 2x + y = 12 meet where x = 4 and y = 4: a corner. The lines y = 0 and 2x + y = 12 meet at (6, 0): a corner. (0, 0) is the fourth. The points (0, 12) and (8, 0) break a row each.

At the corners z is 0, 18, 20 and 16, so the largest value is z = 20, at (4, 4).

When there is no single answer

A tie along an edge. When the objective takes the same value at two neighbouring corners, every point of the edge between them gives that value too. The calculator names both corners.

No largest value. A region that continues without end can let the objective grow forever, as x + y ≥ 4 and x + 3y ≥ 6 do for 2x + 3y. The smallest value still exists there (9, at (3, 1)), and the calculator says in which direction the region runs off.

No region. x + y ≤ 2 and x + y ≥ 4 cannot hold together; no point satisfies every row, and there is nothing to optimise.

Strict inequalities (< and >) leave their boundary line out of the region. When the best corner lies on such a line, the objective comes as close to its value as you like without reaching it.

Last reviewed October 8, 2026 ·How pages are reviewed

The formula behind this

All math calculators

Put this calculator on your site

Copy the code into your page where the calculator should appear. It loads from lovetocalc.com, so it stays current on its own — all we ask is that the credit line comes with it.