Enter your linear inequalities below. This calculator will help you find the feasible region where all inequalities are satisfied simultaneously. It's a fundamental tool for optimization problems and understanding constraints.
<input type="text" id="inequality4" placeholder="e.g., x
Results
Enter inequalities to see results
Solution Region Defined By:N/A
Key Vertices (Approximate):N/A
Number of Inequalities Entered:0
Feasible Region Visualization
Vertex
X-coordinate
Y-coordinate
No vertices calculated yet.
Intersection Points (Vertices)
How it works: This calculator graphs each inequality on a 2D plane, shading the region that satisfies it. The solution to the system is the overlapping shaded region (the feasible region) that satisfies all inequalities simultaneously. Vertices are found by solving pairs of boundary lines.
What is a System of Inequalities Calculator?
A system of inequalities calculator is a powerful online tool designed to help users visualize and determine the solution set for multiple linear inequalities simultaneously. In mathematics, a system of inequalities involves two or more inequalities that are considered together. The solution to such a system is the set of all points (x, y) that satisfy every inequality in the system. This calculator simplifies the process of finding this common solution region, often referred to as the "feasible region," which is crucial in various mathematical applications, including linear programming, optimization, and economics.
Who Should Use This Calculator?
This system of inequalities calculator is invaluable for a wide range of users:
Students: High school and college students learning algebra, pre-calculus, and calculus can use it to check their work, understand graphical representations, and solve homework problems more efficiently.
Mathematicians and Researchers: Professionals working in fields like operations research, economics, and engineering often need to define constraints and identify optimal solutions within a set of conditions.
Data Analysts: When modeling real-world scenarios with multiple constraints, this tool can help identify the possible range of values.
Anyone learning about linear programming: Understanding the feasible region is the first step in solving optimization problems.
Common Misconceptions
Several common misconceptions surround systems of inequalities:
Confusing inequalities with equations: An equation typically has a single solution point (or line/plane), while inequalities represent regions. The boundaries of these regions are defined by the corresponding equations.
Ignoring the inequality sign: The direction of the inequality sign (<, >, ≤, ≥) dictates which side of the boundary line is shaded. Likewise, dashed vs. solid lines indicate whether the boundary is included (≤, ≥) or excluded (<, >).
Assuming a single point solution: Unlike systems of equations, systems of inequalities usually have an infinite number of solutions, represented by a shaded region.
Overlapping regions are always contiguous: While often the case with linear inequalities, complex systems or disconnected regions are possible, though less common in introductory examples.
System of Inequalities Calculator Formula and Mathematical Explanation
The core idea behind solving a system of linear inequalities is to find the intersection of the solution sets of each individual inequality. For a system involving two variables, say $x$ and $y$, each linear inequality defines a half-plane in the Cartesian coordinate system. The boundary of this half-plane is a straight line defined by the corresponding equation (e.g., $ax + by = c$).
Steps to Solve Graphically:
Rewrite each inequality: Express each inequality in a standard form, often as $y = mx + b$ or similar, to easily identify slope and intercept, or in the form $Ax + By \le C$.
Graph the boundary line: For each inequality, graph the corresponding equation. Use a solid line if the inequality includes "or equal to" ($\le, \ge$) and a dashed line if it does not (<, >).
Test a point: Choose a test point (usually the origin, (0,0), if it's not on the boundary line) and substitute its coordinates into the inequality.
Shade the correct region: If the test point satisfies the inequality, shade the half-plane containing the test point. If it does not satisfy the inequality, shade the other half-plane.
Identify the feasible region: The solution to the system of inequalities is the region where all shaded areas overlap. This overlapping region is the feasible region.
Find the vertices: The vertices (corner points) of the feasible region are found by solving the systems of equations formed by pairs of intersecting boundary lines.
Mathematical Representation
Consider a system of two linear inequalities:
Inequality 1: $a_1x + b_1y \le c_1$
Inequality 2: $a_2x + b_2y \ge c_2$
The calculator visually represents these. For instance, to find a vertex, we solve the system of equations:
$a_1x + b_1y = c_1$
$a_2x + b_2y = c_2$
This can be solved using methods like substitution or elimination.
Variable Table
Variable
Meaning
Unit
Typical Range
$x$, $y$
Coordinate variables representing values on the horizontal and vertical axes.
Real numbers
Typically defined by the problem's context or visible graphing window. Can be any real number.
$a, b, c$
Coefficients and constant in the linear inequality $ax + by \le c$ (or variations).
Depends on the context; often unitless coefficients for variables, units for constants if they represent quantities.
Varies widely based on the problem. Coefficients can be positive, negative, or zero. Constants can be any real number.
Slope ($m$)
Rate of change of y with respect to x for a boundary line ($y = mx + b$).
Units of y / Units of x
Any real number. Vertical lines have undefined slope.
Y-intercept ($b$)
The y-coordinate where the boundary line crosses the y-axis ($y = mx + b$).
Units of y
Any real number.
Variables in Linear Inequalities
Practical Examples (Real-World Use Cases)
Example 1: Production Constraints
A small furniture workshop produces two types of tables: Standard and Deluxe. Each Standard table requires 2 hours of carpentry and 1 hour of finishing. Each Deluxe table requires 3 hours of carpentry and 2 hours of finishing. The workshop has a maximum of 120 hours of carpentry available and 70 hours of finishing available per week.
Let $x$ be the number of Standard tables and $y$ be the number of Deluxe tables.
Carpentry Constraint: $2x + 3y \le 120$
Finishing Constraint: $x + 2y \le 70$
Non-negativity: $x \ge 0, y \ge 0$ (cannot produce negative tables)
Using the calculator: Inputting these inequalities ($2x + 3y \le 120$, $x + 2y \le 70$, $x \ge 0$, $y \ge 0$) would yield a feasible region representing all possible combinations of Standard and Deluxe tables that can be produced given the resource constraints. The vertices would indicate the production levels that fully utilize certain resources or represent boundary conditions.
Solution Region Summary: The area bounded by the x-axis, y-axis, and the lines $2x+3y=120$ and $x+2y=70$.
Interpretation: The workshop can produce any combination of tables $(x, y)$ within this feasible region. For example, producing 6 Standard tables and 38 Deluxe tables would utilize the available carpentry and finishing hours efficiently, as indicated by one of the vertices. This helps in deciding production targets.
Example 2: Budgeting with Multiple Spending Categories
Sarah has a budget for her monthly expenses. She wants to spend no more than $500 on entertainment ($x$) and dining out ($y$) combined. Additionally, she wants to ensure her spending on dining out ($y$) is at least half of her entertainment spending ($x$).
Total Spending Constraint: $x + y \le 500$
Dining vs. Entertainment: $y \ge 0.5x$
Non-negativity: $x \ge 0, y \ge 0$
Using the calculator: Entering $x+y \le 500$, $y \ge 0.5x$, $x \ge 0$, and $y \ge 0$ will show the valid spending combinations Sarah can choose.
Solution Region Summary: The region bounded by the x-axis, the line $x+y=500$, and the line $y=0.5x$.
Interpretation: Sarah can spend within the calculated region. For instance, spending $300 on entertainment ($x=300$) and $150$ on dining ($y=150$) is a valid combination ($300+150=450 \le 500$ and $150 \ge 0.5 \times 300$). Spending $400$ on entertainment and $200$ on dining is not valid because the total ($600$) exceeds the budget, even though $200 \ge 0.5 \times 400$.
How to Use This System of Inequalities Calculator
Our system of inequalities calculator is designed for ease of use. Follow these simple steps to get accurate results:
Step-by-Step Guide:
Input Inequalities: In the provided input fields ("Inequality 1", "Inequality 2", etc.), enter each linear inequality you wish to solve. Use standard mathematical notation. For example:
`2x + 3y <= 10` for $2x + 3y \le 10$
`x – y > 5` for $x – y > 5$
`y >= 2x` for $y \ge 2x$
`x < 7` for $x < 7$
Note: Use `x` and `y` as your variables. Standard operators like `+`, `-`, `*`, `/` are supported. Inequality symbols are `=`, ".
Add Optional Inequalities: You can add up to four inequalities. For systems with fewer than four, simply leave the extra fields blank.
Calculate: Click the "Solve System" button. The calculator will process your input.
View Results: The results section will update dynamically:
Primary Result: A confirmation that the feasible region has been identified.
Solution Region Defined By: A summary of the boundary lines forming the feasible region.
Key Vertices: The approximate coordinates of the corner points of the feasible region.
Number of Inequalities Entered: A count of the valid inequalities you provided.
Graph: A visual representation (chart) of the inequalities and their overlapping feasible region.
Table: A structured table listing the calculated vertices.
Interpret the Graph and Table: The graph visually shows the solution space. The vertices table provides precise points where boundary lines intersect within the feasible region.
Copy Results: Use the "Copy Results" button to copy all calculated information (summary, vertices, assumptions) to your clipboard for easy sharing or documentation.
Reset: Click "Reset" to clear all fields and return to the default state.
How to Read Results
The primary result indicates that a feasible region has been found. The 'Solution Region Defined By' tells you which boundary lines constrain the solution. The 'Key Vertices' are critical points, especially in optimization problems, as the optimal solution often occurs at one of these vertices. The chart provides an intuitive visual understanding of the inequalities' constraints.
Decision-Making Guidance
In practical applications like resource allocation or budgeting, the feasible region represents all possible valid scenarios. Vertices are often points of interest: they might represent maximum production levels, minimum costs, or other boundary conditions. Analyzing these points helps in making informed decisions under constraints.
Key Factors That Affect System of Inequalities Results
While the mathematical process of solving systems of inequalities is standard, several factors influence the interpretation and application of the results:
Number of Inequalities: More inequalities generally lead to a smaller, more constrained feasible region, or potentially no solution at all if inequalities contradict each other.
Coefficients and Constants: The values within the inequalities ($a, b, c$ in $ax+by \le c$) directly determine the slope and intercepts of the boundary lines, thereby shaping the feasible region. Small changes can significantly alter the solution space.
Inequality Direction (<, >, ≤, ≥): This determines which side of the boundary line is included and whether the boundary itself is part of the solution (solid line) or not (dashed line). Incorrect signs lead to the wrong region.
Variable Definitions: In real-world applications, ensuring $x$ and $y$ represent the correct quantities (e.g., units produced, hours spent, money allocated) is crucial for meaningful interpretation.
Non-negativity Constraints: In practical scenarios (like production or resource allocation), variables often cannot be negative ($x \ge 0, y \ge 0$). These constraints limit the feasible region to the first quadrant, significantly impacting the solution.
Interdependence of Constraints: The boundaries of the feasible region are formed by the intersection of constraint lines. The specific combination of lines that form the vertices and boundaries depends on how they intersect each other. One constraint might render another partially or wholly irrelevant within the feasible region.
Linearity Assumption: This calculator assumes linear inequalities. Many real-world problems might involve non-linear relationships, which require different, more complex solution methods.
Contextual Interpretation: The mathematical solution (the feasible region) must be translated back into the context of the problem. For example, if the variables represent discrete items (like cars), fractional solutions at vertices might need rounding or further analysis.
Frequently Asked Questions (FAQ)
Q1: What is the feasible region?
A: The feasible region is the area on a graph where the solution sets of all inequalities in a system overlap. It represents all possible combinations of variables that satisfy every condition simultaneously.
Q2: Can a system of inequalities have no solution?
A: Yes. If the shaded regions for the inequalities do not overlap at all, the system has no solution. This happens when the constraints are contradictory.
Q3: How do I handle inequalities with only one variable (e.g., x > 5)?
A: An inequality like $x > 5$ represents a vertical line at $x=5$. You would shade to the right of this dashed line. If you also have $y \ge 0$, it restricts the region to the upper half-plane to the right of $x=5$.
Q4: What does a dashed line mean in the graph?
A: A dashed line indicates that the points on the boundary line itself are *not* included in the solution set. This corresponds to strict inequalities like < or >.
Q5: How are the vertices calculated?
A: Vertices are the corner points of the feasible region. They are found by taking pairs of boundary lines (equations corresponding to the inequalities) and solving the resulting system of two linear equations for their intersection point. Not all intersection points will necessarily be vertices of the final feasible region.
Q6: Can this calculator handle non-linear inequalities?
A: No, this specific calculator is designed only for systems of *linear* inequalities involving two variables ($x$ and $y$). Non-linear inequalities require different graphical methods or software.
Q7: What if my inequality is in the form Ax + By >= C?
A: Enter it directly as `Ax + By >= C`. The calculator parses these forms to determine the boundary line and the correct region to shade.
Q8: Why is the solution often presented as a region and not a single point?
A: Inequalities define a range or set of possible values, not a single fixed value like equations often do. When multiple inequalities are combined, their common valid range forms the solution region. Optimization problems often seek the *best* point within this region, but the region itself represents all possibilities.
Related Tools and Internal Resources
Linear Equations Solver: Solve systems of linear equations simultaneously to find exact intersection points.
Slope-Intercept Calculator: Convert linear equations into slope-intercept form ($y=mx+b$) for easier graphing and analysis.
Online Graphing Calculator: Visualize functions and equations, including linear ones, to better understand mathematical concepts.
Linear Programming Optimizer: Find the optimal solution (maximum or minimum) within a feasible region defined by a system of inequalities.
Distance Formula Calculator: Calculate the distance between two points, useful for analyzing lengths within geometric solutions.
Midpoint Calculator: Find the midpoint between two points, helpful for geometric interpretations.
// Utility function to parse inequality strings
function parseInequality(inequalityStr) {
inequalityStr = inequalityStr.toLowerCase().replace(/\s+/g, "); // Clean and normalize
var regex = /^(.*)(=|) (.*)$/;
var match = inequalityStr.match(regex);
if (!match) return null;
var lhs = match[1]; // Left hand side
var operator = match[2]; // Operator
var rhs = match[3]; // Right hand side
// Basic check for valid variable usage (x and y)
if (lhs.includes('y') && !lhs.includes('x')) { // If only y is on LHS
if (!/^[+-]?\d*y$/.test(lhs)) return null; // Allow only coefficients of y
} else if (lhs.includes('x') && !lhs.includes('y')) { // If only x is on LHS
if (!/^[+-]?\d*x$/.test(lhs)) return null; // Allow only coefficients of x
} else if (lhs && !lhs.includes('x') && !lhs.includes('y')) { // LHS is just a number or invalid
return null;
}
// Similar checks for RHS if it contains variables (it usually shouldn't directly)
if (rhs.includes('x') || rhs.includes('y')) return null;
return { lhs: lhs, operator: operator, rhs: rhs };
}
// Function to solve a pair of linear equations (Ax + By = C)
// Returns {x: value, y: value} or null if parallel/coincident
function solveLinearSystem(eq1, eq2) {
var a1 = parseFloat(eq1.lhs.replace('x', '1').replace('y', ")) || 0; // Handle cases like '-y' or '3x'
var b1 = parseFloat(eq1.lhs.replace('y', '1').replace('x', ")) || 0;
var c1 = parseFloat(eq1.rhs);
var a2 = parseFloat(eq2.lhs.replace('x', '1').replace('y', ")) || 0;
var b2 = parseFloat(eq2.lhs.replace('y', '1').replace('x', ")) || 0;
var c2 = parseFloat(eq2.rhs);
// Adjust coefficients based on simplified form (e.g., 2x + 3y = 6)
var match1 = eq1.lhs.match(/([+-]?\d*\.?\d*)x|([+-]?\d*\.?\d*)y/g);
var match2 = eq2.lhs.match(/([+-]?\d*\.?\d*)x|([+-]?\d*\.?\d*)y/g);
var coeff1 = { x: 0, y: 0 };
var coeff2 = { x: 0, y: 0 };
if (match1) {
match1.forEach(function(term) {
if (term.includes('x')) {
var val = term.replace('x', ");
if (val === " || val === '+') coeff1.x = 1;
else if (val === '-') coeff1.x = -1;
else coeff1.x = parseFloat(val);
} else if (term.includes('y')) {
var val = term.replace('y', ");
if (val === " || val === '+') coeff1.y = 1;
else if (val === '-') coeff1.y = -1;
else coeff1.y = parseFloat(val);
}
});
}
if (match2) {
match2.forEach(function(term) {
if (term.includes('x')) {
var val = term.replace('x', ");
if (val === " || val === '+') coeff2.x = 1;
else if (val === '-') coeff2.x = -1;
else coeff2.x = parseFloat(val);
} else if (term.includes('y')) {
var val = term.replace('y', ");
if (val === " || val === '+') coeff2.y = 1;
else if (val === '-') coeff2.y = -1;
else coeff2.y = parseFloat(val);
}
});
}
a1 = coeff1.x; b1 = coeff1.y;
a2 = coeff2.x; b2 = coeff2.y;
var determinant = a1 * b2 – a2 * b1;
if (determinant === 0) {
// Lines are parallel or coincident, no unique intersection point
return null;
}
var x = (b2 * c1 – b1 * c2) / determinant;
var y = (a1 * c2 – a2 * c1) / determinant;
// Check for NaN results
if (isNaN(x) || isNaN(y)) {
return null;
}
return { x: x, y: y };
}
// Function to check if a point satisfies an inequality
function satisfiesInequality(point, inequality) {
var x = point.x;
var y = point.y;
var lhsStr = inequality.lhs.replace(/x/g, '(' + x + ')').replace(/y/g, '(' + y + ')');
var rhsStr = inequality.rhs;
// Evaluate LHS safely
try {
var lhsVal = eval(lhsStr);
var rhsVal = eval(rhsStr); // RHS is usually a constant, but could be an expression
if (isNaN(lhsVal) || isNaN(rhsVal)) return false;
if (inequality.operator === '<=') return lhsVal =') return lhsVal >= rhsVal;
if (inequality.operator === '<') return lhsVal ') return lhsVal > rhsVal;
} catch (e) {
console.error("Evaluation error:", e);
return false; // Error during evaluation
}
return false;
}
// Function to convert inequality to Ax + By = C form for graphing
function getLineEquation(inequality) {
var lhs = inequality.lhs;
var operator = inequality.operator;
var rhs = inequality.rhs;
var eq = { A: 0, B: 0, C: 0 };
// Normalize LHS to be in terms of x and y
var xTerm = lhs.match(/([+-]?\d*\.?\d*)x/);
var yTerm = lhs.match(/([+-]?\d*\.?\d*)y/);
// Extract coefficients, handling implicit 1s and signs
var xCoeff = xTerm ? parseFloat(xTerm[1] === " || xTerm[1] === '+' ? '1' : (xTerm[1] === '-' ? '-1' : xTerm[1])) : 0;
var yCoeff = yTerm ? parseFloat(yTerm[1] === " || yTerm[1] === '+' ? '1' : (yTerm[1] === '-' ? '-1' : yTerm[1])) : 0;
// Move variable terms to LHS, constant to RHS
eq.A = xCoeff;
eq.B = yCoeff;
eq.C = parseFloat(rhs);
// Handle cases where variables were on RHS initially or complex LHS
// This requires more robust parsing, for now assume simple Ax + By format on LHS
var processedLhs = lhs.replace(/([+-]?\d*\.?\d*)x/g, ").replace(/([+-]?\d*\.?\d*)y/g, ").trim();
if (processedLhs && processedLhs !== '+' && processedLhs !== '-') {
eq.C = parseFloat(processedLhs) – parseFloat(rhs); // Move constant term
} else {
eq.C = parseFloat(rhs); // Constant is directly on RHS
}
// A simplified parsing: look for x, y, and numbers
var numRegex = /[+-]?\d*\.?\d+/g;
var vars = {};
var constants = [];
lhs.split(/([+-])/).filter(Boolean).forEach(function(part, index, arr) {
if (part.includes('x')) {
var coeffStr = arr[index-1] === '-' ? '-' : (arr[index-1] === '+' || index === 0 ? " : arr[index-1]);
var val = coeffStr + part.replace('x', ");
vars['x'] = (val === " || val === '+') ? 1 : (val === '-' ? -1 : parseFloat(val));
} else if (part.includes('y')) {
var coeffStr = arr[index-1] === '-' ? '-' : (arr[index-1] === '+' || index === 0 ? " : arr[index-1]);
var val = coeffStr + part.replace('y', ");
vars['y'] = (val === " || val === '+') ? 1 : (val === '-' ? -1 : parseFloat(val));
} else if (!isNaN(parseFloat(part))) {
constants.push(parseFloat(part));
}
});
eq.A = vars['x'] || 0;
eq.B = vars['y'] || 0;
var lhsConstantSum = constants.reduce(function(sum, val) { return sum + val; }, 0);
if (lhs.includes('+') || lhs.includes('-')) { // check if constants were part of LHS terms
if (lhs.includes('+') && !lhs.includes('x') && !lhs.includes('y')) lhsConstantSum = parseFloat(lhs);
else if (lhs.includes('-') && !lhs.includes('x') && !lhs.includes('y')) lhsConstantSum = parseFloat(lhs);
else if (lhs.match(/^[+-]?\d*\.?\d+$/)) lhsConstantSum = parseFloat(lhs); // direct number
else { // complex case, try eval but it's risky
try {
var tempLhs = lhs.replace(/x/g, '0').replace(/y/g, '0');
lhsConstantSum = eval(tempLhs);
} catch(e) { lhsConstantSum = 0;}
}
} else if (lhs.replace(/x/g, ").replace(/y/g, ").trim() === ") { // only variables on LHS
lhsConstantSum = 0;
} else if (!isNaN(parseFloat(lhs))) { // single number on LHS
lhsConstantSum = parseFloat(lhs);
}
eq.C = parseFloat(rhs) – lhsConstantSum; // Move constant to RHS
return eq;
}
function calculateSystem() {
var inequalities = [];
var inputIds = ["inequality1", "inequality2", "inequality3", "inequality4"];
var errorIds = ["errorInequality1", "errorInequality2", "errorInequality3", "errorInequality4"];
var validInequalities = [];
var boundaryLines = [];
var potentialVertices = [];
var feasibleRegionVertices = [];
var numValid = 0;
// Clear previous errors and results
for (var i = 0; i < errorIds.length; i++) {
document.getElementById(errorIds[i]).textContent = '';
}
document.getElementById("primaryResult").textContent = "Calculating…";
document.getElementById("regionSummary").textContent = "N/A";
document.getElementById("vertices").textContent = "N/A";
document.getElementById("numInequalities").textContent = "0";
document.getElementById("vertexTable").getElementsByTagName("tbody")[0].innerHTML = '
Calculating vertices…
';
var ctx = document.getElementById('inequalityChart').getContext('2d');
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height); // Clear canvas
document.getElementById('chartLegend').innerHTML = ";
// 1. Parse and validate inputs
for (var i = 0; i =')) {
if (!inputVal.includes('x>=0') && !inputVal.includes('x>0')) {
// Assume x>=0 if not specified and x is present
var impliedInequality = { lhs: 'x', operator: '>=', rhs: '0' };
validInequalities.push(impliedInequality);
inequalities.push({ original: inputVal, parsed: parsed, derived: impliedInequality });
numValid++;
} else {
validInequalities.push(parsed);
inequalities.push({ original: inputVal, parsed: parsed });
numValid++;
}
} else if (inputVal.includes('y') && !inputVal.includes('>=')) {
if (!inputVal.includes('y>=0') && !inputVal.includes('y>0')) {
// Assume y>=0 if not specified and y is present
var impliedInequality = { lhs: 'y', operator: '>=', rhs: '0' };
validInequalities.push(impliedInequality);
inequalities.push({ original: inputVal, parsed: parsed, derived: impliedInequality });
numValid++;
} else {
validInequalities.push(parsed);
inequalities.push({ original: inputVal, parsed: parsed });
numValid++;
}
}
else {
validInequalities.push(parsed);
inequalities.push({ original: inputVal, parsed: parsed });
numValid++;
}
} else {
document.getElementById(errorIds[i]).textContent = 'Invalid format. Use e.g., "2x + 3y ineq.parsed.lhs.includes('x'));
var usesY = inequalities.some(ineq => ineq.parsed.lhs.includes('y'));
var hasXConstraint = inequalities.some(ineq => ineq.parsed.lhs.startsWith('x'));
var hasYConstraint = inequalities.some(ineq => ineq.parsed.lhs.startsWith('y'));
if (usesX && !hasXConstraint) {
var xNonNeg = { lhs: 'x', operator: '>=', rhs: '0' };
if (!validInequalities.some(ineq => ineq.lhs === 'x' && ineq.operator === '>=' && ineq.rhs === '0')) {
validInequalities.push(xNonNeg);
inequalities.push({ original: "Implied x >= 0", derived: xNonNeg });
numValid++;
}
}
if (usesY && !hasYConstraint) {
var yNonNeg = { lhs: 'y', operator: '>=', rhs: '0' };
if (!validInequalities.some(ineq => ineq.lhs === 'y' && ineq.operator === '>=' && ineq.rhs === '0')) {
validInequalities.push(yNonNeg);
inequalities.push({ original: "Implied y >= 0", derived: yNonNeg });
numValid++;
}
}
document.getElementById("numInequalities").textContent = numValid;
if (validInequalities.length < 1) {
document.getElementById("primaryResult").textContent = "Please enter at least one inequality.";
document.getElementById("vertexTable").getElementsByTagName("tbody")[0].innerHTML = '
No valid inequalities entered.
';
return;
}
// Convert valid inequalities to Ax + By = C form for solving intersections
for (var i = 0; i < validInequalities.length; i++) {
var eq = getLineEquation(validInequalities[i]);
if(eq) {
boundaryLines.push({ inequality: validInequalities[i], equation: eq });
}
}
// 2. Find potential vertices by solving pairs of boundary lines
for (var i = 0; i < boundaryLines.length; i++) {
for (var j = i + 1; j < boundaryLines.length; j++) {
var intersection = solveLinearSystem(boundaryLines[i].equation, boundaryLines[j].equation);
if (intersection) {
// Check if this intersection point satisfies ALL inequalities
var satisfiesAll = true;
for (var k = 0; k < validInequalities.length; k++) {
if (!satisfiesInequality(intersection, validInequalities[k])) {
satisfiesAll = false;
break;
}
}
if (satisfiesAll) {
// Avoid duplicate vertices (within a small tolerance)
var isDuplicate = false;
for(var v=0; v < feasibleRegionVertices.length; v++) {
if (Math.abs(feasibleRegionVertices[v].x – intersection.x) < 0.001 && Math.abs(feasibleRegionVertices[v].y – intersection.y) 0) {
// Calculate centroid to sort points around it
var centroidX = feasibleRegionVertices.reduce(function(sum, v) { return sum + v.x; }, 0) / feasibleRegionVertices.length;
var centroidY = feasibleRegionVertices.reduce(function(sum, v) { return sum + v.y; }, 0) / feasibleRegionVertices.length;
feasibleRegionVertices.sort(function(a, b) {
var angleA = Math.atan2(a.y – centroidY, a.x – centroidX);
var angleB = Math.atan2(b.y – centroidY, b.x – centroidX);
return angleA – angleB;
});
}
// 3. Prepare results display
var regionSummary = [];
var vertexDisplay = [];
var tableHtml = ";
if (feasibleRegionVertices.length > 0) {
document.getElementById("primaryResult").textContent = "Feasible Region Found!";
document.getElementById("primaryResult").style.color = "var(–success-color)";
for (var i = 0; i = 0″);
if (usesY && !hasYConstraint) regionSummary.push("y >= 0");
document.getElementById("regionSummary").textContent = regionSummary.join(', ');
for (var i = 0; i < feasibleRegionVertices.length; i++) {
vertexDisplay.push(`(${feasibleRegionVertices[i].x.toFixed(2)}, ${feasibleRegionVertices[i].y.toFixed(2)})`);
tableHtml += `
V${i+1}
${feasibleRegionVertices[i].x.toFixed(2)}
${feasibleRegionVertices[i].y.toFixed(2)}
`;
}
document.getElementById("vertices").textContent = vertexDisplay.join(', ');
document.getElementById("vertexTable").getElementsByTagName("tbody")[0].innerHTML = tableHtml;
} else {
// Check if there are constraints but no overlap
if (validInequalities.length > 0) {
document.getElementById("primaryResult").textContent = "No Feasible Region Found (Contradictory Constraints)";
document.getElementById("primaryResult").style.color = "var(–error-color)";
document.getElementById("regionSummary").textContent = "None";
document.getElementById("vertices").textContent = "None";
document.getElementById("vertexTable").getElementsByTagName("tbody")[0].innerHTML = '