Graphical Method Calculator

Solve a two-variable linear programming problem with the graphical method. See the feasible region, every corner point and its objective value, and slide the objective line until it reaches the optimum. Every step is explained, in exact fractions.

  • Interactive objective line
  • Corner-point table
  • Special cases explained

Linear program

Objective function
max z =x1+x2
Subject to
C1x1+x2
C2x1+x2
C3x1+x2

All variables are nonnegative: x1, x2 ≥ 0

Type integers, decimals or fractions (3, -2.5, 3/4). Empty boxes count as 0.

Graph

Drag the slider to move the objective line. Hover a corner to see its value.

C1C2C30123456246810x1x2z improvesA (0, 0), z = 0AB (4, 0), z = 20BC (3, 2), z = 23CD (1, 4), z = 21DE (0, 4), z = 16E
z = 8.05
Feasible regionObjective lineCorner pointOptimum

Result

Optimal solution found
z* = 23

Optimum at corner C (x1, x2) = (3, 2)

Bounded feasible region

Solve with the simplex method

Corner points

Pointx1x2zIntersection of
A000x1 = 0 and x2 = 0
B4020C2 and x2 = 0
COptimal3223C1 and C2
D1421C1 and C3
E0416C3 and x1 = 0

Hover a row to find the point on the graph.

Step-by-step solution

1

Draw each constraint line

Replace each inequality by an equation and draw its line, for example through the points where it meets the axes.

  • C1: the line x1 + x2 = 5 meets the axes at (5, 0) and (0, 5).
  • C2: the line 2 x1 + x2 = 8 meets the axes at (4, 0) and (0, 8).
  • C3: the line x2 = 4 is horizontal, at x₂ = 4.
2

Find the feasible side of each line

Substitute a test point into each inequality. If the inequality holds, the feasible side is the one that contains the test point.

  • C1: at (0, 0), 0 ≤ 5 is true, so the feasible side contains (0, 0).
  • C2: at (0, 0), 0 ≤ 8 is true, so the feasible side contains (0, 0).
  • C3: at (0, 0), 0 ≤ 4 is true, so the feasible side contains (0, 0).
3

Identify the feasible region

The feasible region is the set of points that satisfy every constraint together with x₁, x₂ ≥ 0. It is bounded and has 5 corner points.

4

Find the corner points

Each corner point is where two boundary lines meet; solve their two equations together.

  • A = (0, 0): intersection of x1 = 0 and x2 = 0.
  • B = (4, 0): intersection of C2 and x2 = 0.
  • C = (3, 2): intersection of C1 and C2.
  • D = (1, 4): intersection of C1 and C3.
  • E = (0, 4): intersection of C3 and x1 = 0.
5

Evaluate the objective at each corner

If an optimum exists, it is reached at a corner point. Compute z at every corner and keep the largest value.

  • A: z = 0
  • B: z = 20
  • C: z = 23
  • D: z = 21
  • E: z = 16

The optimal solution is C = (3, 2), with z = 23.

Check with the objective line: draw c₁x₁ + c₂x₂ = z and slide it in the direction that improves z. The last point of the feasible region it touches is the optimum.

About the graphical method

What is the graphical method?

The graphical method solves linear programming problems with two decision variables by drawing them. Each constraint is a half-plane bounded by a straight line; the points that satisfy all of them form the feasible region, a convex polygon. A fundamental theorem of linear programming says that if an optimal solution exists, one is found at a corner point (vertex) of that region.

Corner-point method and objective-line method

There are two ways to finish. The corner-point method computes the objective at every vertex and keeps the best value. The objective-line (iso-profit or iso-cost) method draws the line c₁x₁ + c₂x₂ = z for some value of z and moves it parallel to itself in the direction that improves z; the last vertex it touches is optimal. This page shows both, and the slider lets you move the line yourself.

Special cases

Infeasible: the constraints have no common point, so there is no feasible region. Unbounded: the region extends without limit in a direction that improves z. Alternative optima: the objective line is parallel to an edge of the region, so every point of that edge is optimal. Redundant constraint: a constraint that does not touch the region and can be removed without changing it.

When to use the simplex method

The graphical method only works with two variables (three at most, in a 3D drawing). For larger problems use the simplex method, which moves from corner to corner algebraically. Both methods give the same answer, and the simplex calculator on this site opens any two-variable problem from this page with one click.

Frequently asked questions

Why is the optimum always at a corner point?

The objective is linear, so on any edge of the feasible region its value changes steadily from one end to the other. The best value is therefore reached at an end of an edge, a corner point, unless the whole edge ties, which is the case of alternative optima.

How do I know which side of a line is feasible?

Substitute a test point that is not on the line, usually the origin (0, 0). If it satisfies the inequality, the feasible side is the one containing the test point; otherwise it is the opposite side.

Can it solve minimization problems and ≥ constraints?

Yes. Choose Minimize for cost problems, and use ≤, ≥ or = for each constraint. For minimization the optimum is the corner with the smallest value of z.

What happens with more than two variables?

The graphical method needs a two-dimensional drawing, so it is limited to two variables. Use the simplex method calculator for three or more.

Related on LearnGraphTheory