Linear Equations Calculator

Linear Equations Calculator

Solve for Slope, Intercept, and Coordinate Points

Find Equation from Two Points

Enter two sets of coordinates (x₁, y₁) and (x₂, y₂) to find the slope and equation.

Solve for y (Slope-Intercept Form)

Calculate the value of y using the formula: y = mx + b

Understanding Linear Equations

A linear equation is an algebraic equation in which each term is either a constant or the product of a constant and a single variable. When graphed on a Cartesian plane, a linear equation always results in a straight line.

The Slope-Intercept Form

The most common way to represent a linear equation is the Slope-Intercept Form:

y = mx + b
  • m: The slope (gradient) of the line, which represents the rate of change.
  • b: The y-intercept, which is the point where the line crosses the y-axis.
  • x: The independent variable.
  • y: The dependent variable.

Finding the Slope from Two Points

If you have two points, (x₁, y₁) and (x₂, y₂), you can calculate the slope (m) using the formula:

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

Note: If x₁ equals x₂, the slope is undefined, indicating a vertical line.

Real-World Example

Imagine you are tracking a delivery truck. The truck starts 10 miles away from a depot (b = 10) and travels at a constant speed of 50 miles per hour (m = 50). To find its distance (y) after 3 hours (x):

y = 50(3) + 10
y = 150 + 10 = 160 miles

function calculateTwoPoints() { 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 resDiv = document.getElementById('resultTwoPoints'); if (isNaN(x1) || isNaN(y1) || isNaN(x2) || isNaN(y2)) { resDiv.style.display = 'block'; resDiv.innerHTML = 'Please enter all four coordinate values.'; return; } if (x1 === x2) { resDiv.style.display = 'block'; resDiv.innerHTML = 'Result: Vertical LineEquation: x = ' + x1 + 'Slope is undefined (division by zero).'; return; } var slope = (y2 – y1) / (x2 – x1); var intercept = y1 – (slope * x1); // Round to 4 decimal places for cleanliness slope = Number(Math.round(slope + 'e4') + 'e-4'); intercept = Number(Math.round(intercept + 'e4') + 'e-4'); var equation = "y = " + slope + "x " + (intercept >= 0 ? "+ " + intercept : "- " + Math.abs(intercept)); resDiv.style.display = 'block'; resDiv.innerHTML = '
' + 'Slope (m): ' + slope + " + 'y-intercept (b): ' + intercept + " + 'Equation: ' + equation + '
'; } function calculateYValue() { var m = parseFloat(document.getElementById('slope_m').value); var b = parseFloat(document.getElementById('intercept_b').value); var x = parseFloat(document.getElementById('input_x').value); var resDiv = document.getElementById('resultSlopeIntercept'); if (isNaN(m) || isNaN(b) || isNaN(x)) { resDiv.style.display = 'block'; resDiv.innerHTML = 'Please enter m, b, and x values.'; return; } var y = (m * x) + b; y = Number(Math.round(y + 'e4') + 'e-4'); resDiv.style.display = 'block'; resDiv.innerHTML = '
' + 'Calculation: y = (' + m + ' × ' + x + ') + ' + b + " + 'Result: y = ' + y + '' + '
'; }

Leave a Comment