Graphing Linear Inequalities Calculator

.calc-container { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; max-width: 800px; margin: 20px auto; padding: 25px; border: 1px solid #ddd; border-radius: 12px; background-color: #ffffff; color: #333; box-shadow: 0 4px 15px rgba(0,0,0,0.1); } .calc-header { text-align: center; margin-bottom: 30px; } .calc-header h1 { color: #2c3e50; margin-bottom: 10px; } .input-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 25px; } .input-group { display: flex; flex-direction: column; } .input-group label { font-weight: 600; margin-bottom: 8px; font-size: 14px; } .input-group input, .input-group select { padding: 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 16px; } .btn-calc { width: 100%; padding: 15px; background-color: #3498db; color: white; border: none; border-radius: 6px; font-size: 18px; font-weight: bold; cursor: pointer; transition: background-color 0.3s; } .btn-calc:hover { background-color: #2980b9; } #graph-area { margin-top: 30px; text-align: center; } canvas { border: 2px solid #2c3e50; background-color: #fff; max-width: 100%; height: auto; } .results-box { margin-top: 25px; padding: 20px; background-color: #f8f9fa; border-radius: 8px; border-left: 5px solid #3498db; } .results-box h3 { margin-top: 0; color: #2c3e50; } .article-section { margin-top: 40px; line-height: 1.6; } .article-section h2 { color: #2c3e50; border-bottom: 2px solid #eee; padding-bottom: 10px; } .formula { background: #eee; padding: 10px; display: block; text-align: center; font-family: "Courier New", Courier, monospace; font-weight: bold; margin: 15px 0; }

Graphing Linear Inequalities Calculator

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:

  1. Slope (m): -0.5 (For every 2 steps right, go 1 step down).
  2. Y-intercept (b): 2 (The line crosses the vertical axis at +2).
  3. Sign: ≤ means a Solid line.
  4. 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(); };

Leave a Comment