Enter the slope (m) and coordinates (x, y) of a point on the line.
Method 2: Using Two Points
Enter the coordinates for two different points on the line.
Understanding the Y-Intercept
In analytical geometry, the y-intercept is the point where the graph of a function or equation crosses the y-axis of the coordinate system. Because the y-axis is located at the position where the horizontal value (x) is zero, the y-intercept always has an x-coordinate of 0.
The Slope-Intercept Equation
The most common way to represent a linear equation is the slope-intercept form:
y = mx + b
y: The dependent variable (vertical coordinate).
m: The slope of the line (the rate of change).
x: The independent variable (horizontal coordinate).
b: The y-intercept (the value of y when x = 0).
How to Calculate the Y-Intercept (b)
If you have the slope and one point, you can rearrange the formula to solve for b:
b = y – mx
Example Calculation
Suppose you have a line with a slope of 3 that passes through the point (2, 10).
Identify the values: m = 3, x = 2, y = 10.
Plug them into the formula: b = 10 – (3 * 2).
Calculate: b = 10 – 6.
The y-intercept is 4.
The full equation is: y = 3x + 4.
Why is the Y-Intercept Important?
In real-world applications, the y-intercept often represents the "starting value" or "initial state." For example, if you are calculating the cost of a taxi ride where there is a flat fee of $5.00 plus $2.00 per mile, the y-intercept is 5. It is the cost you pay even if the distance traveled (x) is zero.
function calculateBySlope() {
var m = parseFloat(document.getElementById('slopeM').value);
var x = parseFloat(document.getElementById('pointX').value);
var y = parseFloat(document.getElementById('pointY').value);
var resDiv = document.getElementById('result1');
if (isNaN(m) || isNaN(x) || isNaN(y)) {
resDiv.style.display = 'block';
resDiv.innerHTML = 'Please enter valid numbers for all fields.';
return;
}
var b = y – (m * x);
var bFixed = b.toLocaleString(undefined, {minimumFractionDigits: 0, maximumFractionDigits: 4});
var mFixed = m.toLocaleString(undefined, {minimumFractionDigits: 0, maximumFractionDigits: 4});
var equation = "y = " + mFixed + "x " + (b >= 0 ? "+ " + bFixed : "- " + Math.abs(bFixed));
resDiv.style.display = 'block';
resDiv.innerHTML = 'Y-Intercept (b): ' + bFixed + " +
'Linear Equation: ' + equation + " +
'Coordinate: (0, ' + bFixed + ')';
}
function calculateByTwoPoints() {
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('result2');
if (isNaN(x1) || isNaN(y1) || isNaN(x2) || isNaN(y2)) {
resDiv.style.display = 'block';
resDiv.innerHTML = 'Please enter valid numbers for all coordinates.';
return;
}
if (x1 === x2) {
resDiv.style.display = 'block';
resDiv.innerHTML = 'Error: x coordinates cannot be the same (vertical line has no y-intercept unless x=0).';
return;
}
var slope = (y2 – y1) / (x2 – x1);
var b = y1 – (slope * x1);
var bFixed = b.toLocaleString(undefined, {minimumFractionDigits: 0, maximumFractionDigits: 4});
var sFixed = slope.toLocaleString(undefined, {minimumFractionDigits: 0, maximumFractionDigits: 4});
var equation = "y = " + sFixed + "x " + (b >= 0 ? "+ " + bFixed : "- " + Math.abs(bFixed));
resDiv.style.display = 'block';
resDiv.innerHTML = 'Calculated Slope (m): ' + sFixed + " +
'Y-Intercept (b): ' + bFixed + " +
'Linear Equation: ' + equation + " +
'Coordinate: (0, ' + bFixed + ')';
}