Visualize linear inequalities in the form y [sign] mx + b
">Greater Than (>)
=">Greater Than or Equal (≥)
<option value="Less Than (<)
<option value="Less Than or Equal (≤)
Results & Visualization
Equation:
Boundary Line:
Shading Region:
(Graph displays range from -10 to 10 on both axes)
How to Graph Linear Inequalities
Graphing a linear inequality is a three-step process that allows you to visualize all the possible solutions for a math problem. Unlike a standard equation (y = mx + b) which represents a single line, an inequality represents an entire region of the coordinate plane.
1. Identify the Boundary Line
Start by treating the inequality as an equation. For example, if you have y > 2x + 1, first consider the line y = 2x + 1. This is your "boundary." Determine whether the line should be solid or dashed:
Dashed Line (—): Used for < or > (Strict inequalities). This means points exactly on the line are not solutions.
Solid Line (___): Used for ≤ or ≥. This means points on the line are part of the solution set.
2. Determine the Shading Direction
Because an inequality represents a range of values, you must shade the area of the graph that satisfies the condition:
y > or y ≥: Shade above the boundary line.
y < or y ≤: Shade below the boundary line.
Practical Example
Let's graph y ≤ -x + 4:
Boundary: The line has a slope (m) of -1 and a y-intercept (b) of 4.
Line Style: Since it is "less than or equal to" (≤), we draw a solid line.
Shading: Since it is "less than" (<), we shade the area below the line.
Pro Tip: The Test Point Method
If you're unsure which side to shade, pick a test point not on the line—the origin (0,0) is usually the easiest. Plug 0 for x and 0 for y. If the inequality remains true (e.g., 0 < 5), shade the side containing (0,0). If false, shade the opposite side.
function calculateInequality() {
var m = parseFloat(document.getElementById('slope_m').value);
var b = parseFloat(document.getElementById('intercept_b').value);
var sign = document.getElementById('inequality_sign').value;
var resultBox = document.getElementById('result-output');
if (isNaN(m) || isNaN(b)) {
alert("Please enter valid numeric values for slope and intercept.");
return;
}
// Text Outputs
var eqStr = "y " + sign + " " + m + "x " + (b >= 0 ? "+ " + b : "- " + Math.abs(b));
document.getElementById('eq-text').innerText = eqStr;
var isSolid = (sign === '>=' || sign === " || sign === '>=');
document.getElementById('shading-text').innerText = isAbove ? "Above the line" : "Below the line";
// SVG Logic
// Mapping math coordinates (-10 to 10) to SVG viewbox (0 to 200)
// Math X -10 -> SVG 0, Math X 10 -> SVG 200
// Math Y 10 -> SVG 0, Math Y -10 -> SVG 200
function mapX(x) { return 100 + (x * 10); }
function mapY(y) { return 100 – (y * 10); }
var xStart = -10;
var yStart = m * xStart + b;
var xEnd = 10;
var yEnd = m * xEnd + b;
var boundary = document.getElementById('boundary-line');
boundary.setAttribute('x1', mapX(xStart));
boundary.setAttribute('y1', mapY(yStart));
boundary.setAttribute('x2', mapX(xEnd));
boundary.setAttribute('y2', mapY(yEnd));
boundary.setAttribute('stroke-dasharray', isSolid ? "0" : "5,5");
// Shading Polygon
var shading = document.getElementById('shading-path');
var pathPoints = "";
if (isAbove) {
// Shade to top of SVG
pathPoints = "M " + mapX(xStart) + " " + mapY(yStart) + " " +
"L " + mapX(xEnd) + " " + mapY(yEnd) + " " +
"L 200 0 L 0 0 Z";
} else {
// Shade to bottom of SVG
pathPoints = "M " + mapX(xStart) + " " + mapY(yStart) + " " +
"L " + mapX(xEnd) + " " + mapY(yEnd) + " " +
"L 200 200 L 0 200 Z";
}
shading.setAttribute('d', pathPoints);
resultBox.style.display = "block";
}