Graphical Method Calculator (2-Variable LP)

Solve and visualize 2-variable linear programming problems with interactive constraint lines, feasible polygon vertices, and optimal solution plotting.

Objective Function (Z)

Z =
x
+
y

Constraints

#1
x
+
y
#2
x
+
y
#3
x
+
y
4.28.312.516.620.824.929.133.237.441.54.69.213.818.423.027.632.236.841.446.0

Optimal Solution

Z = 33.0000
x = 3.0000
y = 12.0000

How it works

The graphical method engine computes every possible intersection between the constraint lines and the axes (x = 0, y = 0).

Each candidate vertex is then strictly tested against the original inequalities. Because the algebraic evaluation uses the original coefficients directly (val = a · x + b · y), it natively handles negative coefficients and flips in inequality directions correctly without requiring any special casing or manual inequality reversals.

Linear Programming & Geometric Optimization

Understanding the 2-Variable Graphical Method: An Academic Guide

Learn how the graphical method identifies feasible polyhedrons, pinpoints boundary vertices, and finds optimal solutions visually.

1. What Problem Does the Graphical Method Solve?

The Graphical Method is a geometric approach to solving Linear Programming (LP) problems restricted to two decision variables (x₁ and x₂). Because two variables can be mapped directly onto a Cartesian coordinate plane, every linear constraint represents a half-plane bounded by a straight line. The intersection of these half-planes forms the feasible region—a convex polygon. The Fundamental Theorem of Linear Programming guarantees that if an optimal solution exists, it occurs at one or more extreme points (vertices) of this polygon.

2. The Step-by-Step Graphical Algorithm

Step 1: Plot Boundary Lines

Convert each inequality constraint into an equality line (e.g., ax₁ + bx₂ = c) by calculating its axial intercepts: set x₁ = 0 to find the x₂-intercept, and set x₂ = 0 to find the x₁-intercept.

Step 2: Identify Half-Planes

Test the origin (0, 0) in the original inequality. If (0, 0) satisfies the condition, shade the half-plane containing the origin; if not, shade the opposite side. Also enforce non-negativity axes (x₁ ≥ 0, x₂ ≥ 0).

Step 3: Define the Feasible Polygon

Find the common overlapping area of all shaded half-planes. If no region satisfies all constraints simultaneously, the problem is infeasible.

Step 4: Compute Vertex Coordinates

Determine the exact coordinates of every vertex of the feasible polygon by algebraically solving the 2×2 linear systems formed by intersecting boundary lines.

Step 5: Evaluate Objective Function (Z)

Calculate Z = c₁x₁ + c₂x₂ at each feasible vertex. The vertex yielding the highest Z (for maximization) or lowest Z (for minimization) is the global optimal solution.

3. Fully Worked Numerical Example

Follow this textbook 2-variable production problem step by step:

Maximize Z = 3x₁ + 2x₂
2x₁ + x₂ ≤ 18 (Constraint 1: Machining time)
2x₁ + 3x₂ ≤ 42 (Constraint 2: Assembly time)
3x₁ + x₂ ≤ 24 (Constraint 3: Finishing time)
x₁ ≥ 0, x₂ ≥ 0 (Non-negativity)

Boundary Line Equations & Intercepts

Line 1 (2x₁ + x₂ = 18) passes through (0, 18) and (9, 0). Line 2 (2x₁ + 3x₂ = 42) passes through (0, 14) and (21, 0). Line 3 (3x₁ + x₂ = 24) passes through (0, 24) and (8, 0).

Feasible Polygon Vertices & Z Evaluation

Solving the intersections that bound the feasible region yields five candidate vertices:

VertexCoordinates (x₁, x₂)Objective Value ZStatus
A (Origin)(0, 0)Z = 3(0) + 2(0) = 0Feasible
B (x₁-axis)(8, 0)Z = 3(8) + 2(0) = 24Feasible (Intersection Line 3 & x₂=0)
C (Line 1 & 3)(6, 6)Z = 3(6) + 2(6) = 30Feasible (2(6)+3(6)=30 ≤ 42)
D (Line 1 & 2)(3, 12)Z = 3(3) + 2(12) = 33Optimal Vertex (3(3)+12=21 ≤ 24)
E (x₂-axis)(0, 14)Z = 3(0) + 2(14) = 28Feasible (Intersection Line 2 & x₁=0)

4. Mathematical Result & Interpretation

The global maximum is reached at vertex D: (x₁*, x₂*) = (3, 12) with optimal value Z* = 33. Constraints 1 and 2 are binding (fully exhausted: 2(3)+12=18 and 2(3)+3(12)=42). Constraint 3 has a slack of 3 units (3(3)+12=21 < 24), meaning 3 finishing hours remain unutilized.

5. Common Student Mistakes in Graphical LP

⚠

Shading the wrong half-plane

Always verify with a test point (such as 0, 0) instead of guessing direction based on whether the coefficient has a positive or negative sign.

⚠

Evaluating infeasible intersections

Points like (9, 0) or (0, 18) are real line intersections, but they violate Constraint 2 or 3 and lie outside the feasible polygon.

⚠

Overlooking unboundedness

When minimizing with ≥ constraints without an upper bound, ensure the region is closed. If isoprofit lines can move infinitely outward, the problem is unbounded.