Slope Calculator Graph

Slope Calculator & Linear Equation Finder

Enter the coordinates for two points $(x_1, y_1)$ and $(x_2, y_2)$ to calculate the slope, y-intercept, distance, and the equation of the line.

Point 1

Point 2

Calculated Metrics

Slope (m)
Y-Intercept (b)
Line Equation
Distance (d)
Angle of Inclination
function calculateSlope() { var x1 = parseFloat(document.getElementById('x1').value); var y1 = parseFloat(document.getElementById('y1').value); var x2 = parseFloat(document.getElementById('x2').value); var y2 = parseFloat(document.getElementById('y2').value); if (isNaN(x1) || isNaN(y1) || isNaN(x2) || isNaN(y2)) { alert("Please enter valid numbers for all coordinates."); return; } var dx = x2 – x1; var dy = y2 – y1; var slope, intercept, equation, angle, distance; distance = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2)).toFixed(4); if (dx === 0) { slope = "Undefined (Vertical Line)"; intercept = "None"; equation = "x = " + x1; angle = "90°"; } else { var m = dy / dx; var b = y1 – (m * x1); slope = m.toFixed(4); intercept = b.toFixed(4); var sign = b >= 0 ? "+ " : "- "; var absB = Math.abs(b).toFixed(4); equation = "y = " + slope + "x " + sign + absB; var rad = Math.atan(m); angle = (rad * (180 / Math.PI)).toFixed(2) + "°"; } document.getElementById('res-m').innerText = slope; document.getElementById('res-b').innerText = intercept; document.getElementById('res-eq').innerText = equation; document.getElementById('res-dist').innerText = distance; document.getElementById('res-angle').innerText = angle; document.getElementById('slope-results').style.display = 'block'; }

Understanding Slope and Linear Graphs

The slope of a line is a measure of its steepness and direction. In mathematics, specifically algebra and geometry, the slope (often denoted by the letter m) describes how much the 'y' value changes for every unit of change in the 'x' value. This is commonly referred to as the "rise over run."

The Slope Formula

To find the slope between two points, $(x_1, y_1)$ and $(x_2, y_2)$, we use the following formula:

m = (y₂ – y₁) / (x₂ – x₁)

The Slope-Intercept Form

Once the slope (m) is known, you can determine the equation of the line in slope-intercept form:

y = mx + b
  • m: The slope (steepness).
  • b: The y-intercept (where the line crosses the vertical y-axis).

Practical Example

Imagine you have two points on a graph: Point A at (1, 2) and Point B at (3, 8).

  1. Identify Coordinates: x₁=1, y₁=2, x₂=3, y₂=8.
  2. Calculate Rise: y₂ – y₁ = 8 – 2 = 6.
  3. Calculate Run: x₂ – x₁ = 3 – 1 = 2.
  4. Divide: 6 / 2 = 3. The slope (m) is 3.
  5. Find Intercept: Use y = mx + b → 2 = 3(1) + b → b = -1.
  6. Result: The equation is y = 3x – 1.

Types of Slopes

Slope Type Visual Representation
Positive Slope Line goes up from left to right.
Negative Slope Line goes down from left to right.
Zero Slope A perfectly horizontal line.
Undefined Slope A perfectly vertical line.

Leave a Comment