Linear Programming Calculator
Solve a two-variable linear program graphically: enter the objective coefficients and constraints to get the optimal vertex and objective value.
Linear Programming Calculator
Calculator
Adjust values & calculateEnter your values below. Every result is computed in your browser โ no data is sent to any server.
Formula: Maximize Z = cx subject to Ax โค b, x โฅ 0
Additional inputs: Constraint 3: x coeff, Constraint 3: y coeff, Constraint 3: โค RHS.
Worked example โ Optimal Z = 36 at x = 2, y = 6 | Binding: x + 2y <= 14 and x + y <= 8 | Slack of 2 on 3x + y <= 14
Formula
Maximize Z = cx subject to Ax โค b, x โฅ 0
Solves 2-variable LP graphically by evaluating the objective at each vertex of the feasible region.
Worked Examples
Example 1: Three-constraint maximisation
Problem:Maximise Z = 3x + 5y subject to x + 2y <= 14, 3x + y <= 14, x + y <= 8, with x >= 0 and y >= 0.
Solution:By the Fundamental Theorem of Linear Programming the optimum sits at a corner, so list every corner of the feasible region and evaluate Z at each. (0, 0): Z = 0 (14/3, 0) from 3x + y = 14 with y = 0: Z = 3(4.667) = 14.00 (0, 7) from x + 2y = 14 with x = 0: Z = 5(7) = 35 x + y = 8 meets 3x + y = 14: subtracting gives 2x = 6, so (3, 5) and Z = 9 + 25 = 34 x + 2y = 14 meets x + y = 8: subtracting gives y = 6, so (2, 6) and Z = 6 + 30 = 36 Check (2, 6) against every constraint: 2 + 12 = 14 (binding), 6 + 6 = 12 <= 14 (slack 2), 2 + 6 = 8 (binding).
Result:Optimal Z = 36 at x = 2, y = 6 | Binding: x + 2y <= 14 and x + y <= 8 | Slack of 2 on 3x + y <= 14
Example 2: Production mix with a non-binding constraint
Problem:A workshop earns $40 per chair and $30 per stool. Each chair uses 4 hours of labour and 2 board-feet of oak; each stool uses 2 hours and 3 board-feet. There are 40 labour hours and 42 board-feet available. Maximise profit.
Solution:Let x = chairs and y = stools. Maximise Z = 40x + 30y subject to 4x + 2y <= 40 and 2x + 3y <= 42. Corners: (0, 0): Z = 0 (10, 0) from 4x = 40: check 2(10) = 20 <= 42, feasible. Z = 400 (0, 14) from 3y = 42: check 2(14) = 28 <= 40, feasible. Z = 420 Intersection of 4x + 2y = 40 and 2x + 3y = 42: multiply the first by 1.5 to get 6x + 3y = 60, subtract the second to get 4x = 18, so x = 4.5 and y = (40 - 18)/2 = 11. Z = 180 + 330 = 510 Both constraints are binding at (4.5, 11), so both resources are fully used.
Result:Optimal Z = $510 at 4.5 chairs and 11 stools | Both labour and oak are binding | Whole units require integer programming
Frequently Asked Questions
What is linear programming and where is it used?
Linear programming (LP) is a mathematical optimization technique that finds the maximum or minimum of a linear objective function subject to linear inequality constraints. It is widely used in manufacturing (production planning), logistics (transportation routing), finance (portfolio optimization), and workforce scheduling to allocate limited resources efficiently.
How do you interpret the optimal solution of a linear program?
The optimal solution is the point within the feasible region that maximizes or minimizes the objective function Z. By the Fundamental Theorem of Linear Programming, if an optimal solution exists it will always occur at a corner (vertex) of the feasible region. The coordinates give the optimal values of the decision variables, and Z gives the best achievable objective value.
What is the difference between linear programming and the simplex method?
Linear programming is the mathematical framework โ defining the objective and constraints. The simplex method is a specific algorithm used to solve LP problems. The simplex method starts at a vertex of the feasible region and iteratively moves to adjacent vertices that improve the objective until no further improvement is possible or unboundedness is detected.
What are the key assumptions of linear programming models?
LP models assume proportionality (contribution of each variable is proportional to its value), additivity (total objective and constraint values are sums of individual contributions), divisibility (decision variables can take non-integer values), and certainty (all coefficients are known constants). When divisibility is violated, integer programming must be used instead.
How do I minimise an objective with a tool that maximises?
Negate the objective coefficients and maximise instead, since minimising Z = 3x + 5y is the same problem as maximising -3x - 5y. Enter -3 and -5, read off the optimal x and y, then flip the sign of the reported Z to recover the true minimum. The optimal vertex itself is unchanged. Be aware that with all constraints of the less-than-or-equal form and both variables non-negative, a minimisation often lands trivially at the origin.
What are slack, binding and non-binding constraints?
For a constraint ax + by <= r, the slack at any feasible point is r - (ax + by), the unused amount of that resource. A constraint with zero slack at the optimum is binding: the solution sits exactly on that line and the resource is fully consumed. A constraint with positive slack is non-binding and could be loosened or tightened slightly without moving the optimum. Identifying which constraints bind tells you where extra capacity would actually pay off.
What is a shadow price and how is it read?
The shadow price of a constraint is the amount by which the optimal objective value would improve if that constraint's right-hand side rose by one unit. Non-binding constraints have a shadow price of zero, because spare capacity is worth nothing. Binding constraints usually have a positive shadow price, and it holds only over a range of right-hand-side values, up to the point where the set of binding constraints changes and the optimal vertex jumps elsewhere.
What makes a linear program infeasible or unbounded?
An infeasible program has constraints that contradict one another, so no point satisfies them all and the feasible region is empty. An unbounded program has a feasible region that stretches to infinity in a direction along which the objective keeps improving, so no finite optimum exists. With every constraint of the less-than-or-equal type and both variables non-negative, as assumed here, the region is bounded only when the constraints together cap growth in every direction; a lone constraint such as x - y <= 5 caps neither variable, so read the corner list rather than assuming.
When does a linear program have more than one optimal solution?
When the objective function's contour line is parallel to a binding constraint edge, every point along that edge, including both of its end vertices, gives the same value of Z. Algebraically this happens when the objective coefficients are proportional to that constraint's coefficients, for example maximising 2x + 4y when a binding constraint reads x + 2y <= 14. The vertex reported is then just one of infinitely many optima, all equally good.
How do I express a greater-than-or-equal or an equality constraint?
Every linear constraint here is read in less-than-or-equal form, so multiply a greater-than-or-equal constraint through by -1 to flip its direction: 2x + 3y >= 12 becomes -2x - 3y <= -12. An equality is entered as a matched pair of linear inequalities, the constraint itself and its negation, which together pin the feasible region onto that line, though with only three constraint slots that pair consumes two of them. The non-negativity conditions x >= 0 and y >= 0 are always applied to the feasible region and need not be typed in. Because a greater-than-or-equal constraint cuts away the area near the origin, adding one often moves the optimal vertex of the objective function well away from (0, 0), so re-read which corner the maximize step actually selected.
References
Reviewed for accuracy by Manoj Kumar, Mathematics Educator ยท Editorial policy
Related Calculators
๐งฎLinear Regression Calculator
Calculate linear regression with inputs, formulas, and instant results.
๐งฎLinear Interpolation Calculator
Calculate linear interpolation with inputs, formulas, and instant results.
๐งฎLinear Combination Calculator
Calculate linear combination with inputs, formulas, and instant results.
๐งฎLinear Independence Calculator
Calculate linear independence with inputs, formulas, and instant results.
๐งฎSum of a Linear Number Sequence Calculator
Calculate sum of alinear number sequence with inputs, formulas, and instant results.
๐งฎEquation Solver
Solve linear, quadratic, cubic, and polynomial equations with step-by-step solutions.
๐งฎCramer Rule Calculator
Solve systems of linear equations using Cramer rule with determinant calculations shown.