Graphing Inequalities Calculator

#graphing-inequality-calc-container .input-group { margin-bottom: 20px; } #graphing-inequality-calc-container label { display: block; font-weight: 600; margin-bottom: 8px; font-size: 16px; } #graphing-inequality-calc-container input[type="number"], #graphing-inequality-calc-container select { width: 100%; padding: 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 16px; box-sizing: border-box; } #graphing-inequality-calc-container .calc-btn { background-color: #2563eb; color: white; border: none; padding: 15px 25px; font-size: 18px; border-radius: 6px; cursor: pointer; width: 100%; font-weight: bold; transition: background 0.3s; } #graphing-inequality-calc-container .calc-btn:hover { background-color: #1d4ed8; } #graphing-inequality-calc-container #result-output { margin-top: 25px; padding: 20px; background-color: #f8fafc; border-radius: 8px; border-left: 5px solid #2563eb; display: none; } #graphing-inequality-calc-container .graph-preview { margin-top: 20px; background: #fff; border: 1px solid #eee; border-radius: 4px; padding: 10px; display: flex; justify-content: center; } #graphing-inequality-calc-container h2 { color: #1e293b; margin-top: 0; } #graphing-inequality-calc-container .math-box { background: #eee; padding: 10px; border-radius: 4px; font-family: "Courier New", Courier, monospace; font-weight: bold; }

Graphing Inequalities Calculator

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:

  1. Boundary: The line has a slope (m) of -1 and a y-intercept (b) of 4.
  2. Line Style: Since it is "less than or equal to" (≤), we draw a solid line.
  3. 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"; }

Leave a Comment