Slope Equation Calculator

.slope-calc-container { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; max-width: 800px; margin: 20px auto; padding: 25px; border: 1px solid #ddd; border-radius: 12px; background-color: #f9f9f9; color: #333; box-shadow: 0 4px 6px rgba(0,0,0,0.1); } .slope-calc-container h2 { color: #2c3e50; text-align: center; margin-bottom: 25px; } .coordinate-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; } .point-group { background: #fff; padding: 15px; border-radius: 8px; border: 1px solid #eee; } .point-group h3 { margin-top: 0; font-size: 1.1rem; color: #3498db; } .input-row { margin-bottom: 15px; } .input-row label { display: block; font-weight: 600; margin-bottom: 5px; font-size: 0.9rem; } .input-row input { width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; } .calc-button { width: 100%; padding: 15px; background-color: #3498db; color: white; border: none; border-radius: 6px; font-size: 1.1rem; font-weight: bold; cursor: pointer; transition: background-color 0.3s; } .calc-button:hover { background-color: #2980b9; } #slope-result { margin-top: 25px; padding: 20px; background-color: #e8f4fd; border-left: 5px solid #3498db; border-radius: 4px; display: none; } .result-item { margin-bottom: 10px; font-size: 1.05rem; } .result-label { font-weight: bold; color: #2c3e50; } .equation-box { background: #fff; padding: 10px; border: 1px dashed #3498db; margin-top: 10px; font-family: "Courier New", Courier, monospace; font-weight: bold; text-align: center; } .article-section { margin-top: 40px; line-height: 1.6; } .article-section h3 { color: #2c3e50; border-bottom: 2px solid #3498db; padding-bottom: 5px; }

Slope Equation Calculator

Point 1 (x₁, y₁)

Point 2 (x₂, y₂)

Slope (m):
Slope-Intercept Form:
Y-Intercept (b):
Distance Between Points:
Angle of Inclination:

Understanding the Slope Equation

The slope of a line represents its steepness and direction. In coordinate geometry, the slope (often designated by the letter m) tells us how much the y-value changes for every unit change in the x-value. This is commonly referred to as "rise over run."

The Slope Formula

To find the slope between two points (x₁, y₁) and (x₂, y₂), we use the following formula:

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

Slope-Intercept Form

Once you have the slope (m) and the y-intercept (b), you can write the equation of the line in slope-intercept form:

y = mx + b

The y-intercept (b) is the point where the line crosses the y-axis (where x = 0). It can be calculated using the formula: b = y₁ – (m * x₁).

Practical Example

Let's say you have two points: (2, 3) and (6, 11).

  • Step 1: Calculate the change in y (rise): 11 – 3 = 8.
  • Step 2: Calculate the change in x (run): 6 – 2 = 4.
  • Step 3: Divide rise by run: 8 / 4 = 2. The slope (m) is 2.
  • Step 4: Find the y-intercept: 3 = (2 * 2) + b -> 3 = 4 + b -> b = -1.
  • Equation: y = 2x – 1.

Types of Slopes

  • Positive Slope: The line goes up from left to right.
  • Negative Slope: The line goes down from left to right.
  • Zero Slope: A horizontal line (y₂ = y₁).
  • Undefined Slope: A vertical line (x₂ = x₁).
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); var resultDiv = document.getElementById('slope-result'); if (isNaN(x1) || isNaN(y1) || isNaN(x2) || isNaN(y2)) { alert("Please enter valid numerical values for all coordinates."); return; } var dx = x2 – x1; var dy = y2 – y1; var m, b, equation, angle, distance; resultDiv.style.display = 'block'; if (dx === 0) { // Vertical Line m = "Undefined"; b = "None"; equation = "x = " + x1; angle = "90°"; distance = Math.abs(dy).toFixed(4); } else { m = dy / dx; b = y1 – (m * x1); // Formatting m for display var m_display = Number.isInteger(m) ? m : m.toFixed(4); var b_display = Number.isInteger(b) ? b : b.toFixed(4); // Building the equation string var sign = b >= 0 ? " + " : " – "; var absB = Math.abs(b_display); if (m === 0) { equation = "y = " + b_display; } else { var m_part = m === 1 ? "x" : (m === -1 ? "-x" : m_display + "x"); equation = "y = " + m_part + (b === 0 ? "" : sign + absB); } // Distance formula: sqrt((x2-x1)^2 + (y2-y1)^2) distance = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2)).toFixed(4); // Angle of inclination: atan(m) in degrees angle = (Math.atan(m) * (180 / Math.PI)).toFixed(2) + "°"; m = m_display; b = b_display; } document.getElementById('res-m').innerText = m; document.getElementById('res-b').innerText = b; document.getElementById('res-eq').innerText = equation; document.getElementById('res-dist').innerText = distance; document.getElementById('res-angle').innerText = angle; }

Leave a Comment