Enter your equation in slope-intercept form (y = mx + b) to visualize the inequality.
">> (Greater Than)
<option value="< (Less Than)
=">≥ (Greater Than or Equal To)
<option value="≤ (Less Than or Equal To)
Graph Analysis
How to Graph Linear Inequalities
Graphing a linear inequality is the process of visualizing all possible coordinate pairs (x, y) that make the inequality statement true. Unlike a standard linear equation which is a single line, an inequality represents an entire region of the Cartesian plane.
1. Identify the Boundary Line
The first step is to treat the inequality as a regular equation. For example, if you have y > 2x + 1, first plot the line y = 2x + 1.
y = mx + b
2. Determine the Line Style
Dashed Line: Use this for strict inequalities ( ). This indicates that points exactly on the line are not part of the solution set.
Solid Line: Use this for "equal to" inequalities (≤ or ≥). This indicates that points on the boundary line are included in the solution.
3. Shade the Correct Region
Since the inequality covers an area, you must shade one side of the line:
Greater than (> or ≥): Shade the region above the line.
Less than (< or ≤): Shade the region below the line.
Example Calculation
Let's look at the inequality y ≤ -0.5x + 2:
Slope (m): -0.5 (For every 2 steps right, go 1 step down).
Y-intercept (b): 2 (The line crosses the vertical axis at +2).
Sign: ≤ means a Solid line.
Shading: Since it is "less than," shade Below the line.
Points like (0,0) satisfy this equation: 0 ≤ -0.5(0) + 2 → 0 ≤ 2 (True), so (0,0) is in the shaded area.
function calculateAndGraph() {
var m = parseFloat(document.getElementById('slopeM').value);
var b = parseFloat(document.getElementById('interceptB').value);
var sign = document.getElementById('inequalitySign').value;
if (isNaN(m) || isNaN(b)) {
alert("Please enter valid numerical values for slope and intercept.");
return;
}
var canvas = document.getElementById('inequalityCanvas');
var ctx = canvas.getContext('2d');
var width = canvas.width;
var height = canvas.height;
var centerX = width / 2;
var centerY = height / 2;
var scale = 20; // 20 pixels per 1 unit
// Clear canvas
ctx.clearRect(0, 0, width, height);
// 1. Draw Shading
ctx.beginPath();
if (sign === ">" || sign === ">=") {
ctx.fillStyle = "rgba(52, 152, 219, 0.2)";
ctx.moveTo(0, 0);
ctx.lineTo(width, 0);
// Line points at x bounds
var yLeft = centerY – (m * (-centerX / scale) + b) * scale;
var yRight = centerY – (m * (centerX / scale) + b) * scale;
ctx.lineTo(width, yRight);
ctx.lineTo(0, yLeft);
ctx.fill();
} else {
ctx.fillStyle = "rgba(52, 152, 219, 0.2)";
ctx.moveTo(0, height);
ctx.lineTo(width, height);
var yLeft = centerY – (m * (-centerX / scale) + b) * scale;
var yRight = centerY – (m * (centerX / scale) + b) * scale;
ctx.lineTo(width, yRight);
ctx.lineTo(0, yLeft);
ctx.fill();
}
// 2. Draw Grid
ctx.strokeStyle = "#e0e0e0″;
ctx.lineWidth = 1;
for (var i = 0; i " || sign === "<") {
ctx.setLineDash([5, 5]);
} else {
ctx.setLineDash([]);
}
ctx.beginPath();
var xStart = -centerX / scale;
var xEnd = centerX / scale;
var yStart = centerY – (m * xStart + b) * scale;
var yEnd = centerY – (m * xEnd + b) * scale;
ctx.moveTo(0, yStart);
ctx.lineTo(width, yEnd);
ctx.stroke();
ctx.setLineDash([]); // Reset dash
// Display Results
document.getElementById('results').style.display = "block";
document.getElementById('eqnText').innerHTML = "Equation: y " + sign + " " + m + "x + " + b;
var dashText = (sign === ">" || sign === "<") ? "Dashed (boundary not included)" : "Solid (boundary included)";
document.getElementById('lineStyle').innerHTML = "Line Style: " + dashText;
var shadeText = (sign === ">" || sign === ">=") ? "Above the line" : "Below the line";
document.getElementById('shadingStyle').innerHTML = "Shading: " + shadeText;
var xInt = (m !== 0) ? (-b / m).toFixed(2) : "None";
document.getElementById('interceptText').innerHTML = "Intercepts: Y-Intercept: (0, " + b + "), X-Intercept: (" + xInt + ", 0)";
}
// Initialize on load
window.onload = function() {
calculateAndGraph();
};