The slope-intercept calculator turns any linear-equation input into a complete result set — equation, slope, y-intercept, angle, distance, midpoint, perpendicular slope, and a live SVG line diagram — all calculated locally in your browser with no data uploaded anywhere.
What is slope-intercept form?
A straight line in the plane can be written in several equivalent ways. The most useful is slope-intercept form:
y = mx + b
where m is the slope (rise ÷ run — how steeply the line climbs or falls) and b is the y-intercept (the y-coordinate where the line crosses the vertical axis). Once you know m and b you can immediately answer three questions: how steep is the line, where does it cross the y-axis, and what is y for any given x?
How the calculator works
The tool offers five modes so it covers every starting point you might have:
Two points → equation. Given P1 = (x1, y1) and P2 = (x2, y2) the slope is computed as m = (y2 - y1) / (x2 - x1), then the intercept follows from b = y1 - m * x1. From the same two points the tool also calculates the Euclidean distance sqrt((x2-x1)^2 + (y2-y1)^2), the midpoint ((x1+x2)/2, (y1+y2)/2), and the angle in degrees via arctan(dy/dx). If x1 = x2 the line is vertical and slope is undefined (x = constant).
m and b → equation. Supply the slope and y-intercept directly and the tool builds the full equation plus the angle and perpendicular slope.
Point + slope → equation. Given a known point (x0, y0) and slope m, the y-intercept is b = y0 - m * x0. The point-slope form y - y0 = m(x - x0) is also displayed alongside the standard form.
Solve for y. Given m, b and an x-value, the tool evaluates y = mx + b and shows the arithmetic working step by step.
Solve for x. Given m, b and a y-value, the tool rearranges to x = (y - b) / m (undefined when m = 0) and shows the working.
The SVG diagram plots the line across the visible data range, marks P1 and P2, draws the right-angle rise/run triangle when the two points are far enough apart to be legible, and overlays coordinate axes wherever they pass through the visible window.
Worked example
Suppose you have the points (1, 2) and (4, 8).
- Rise = 8 - 2 = 6; Run = 4 - 1 = 3.
- Slope m = 6 / 3 = 2.
- Intercept b = 2 - 2 * 1 = 0.
- Equation: y = 2x.
- Angle: arctan(2) = 63.43°.
- Distance: sqrt(3^2 + 6^2) = sqrt(45) ≈ 6.708.
- Midpoint: ((1+4)/2, (2+8)/2) = (2.5, 5).
- Perpendicular slope: -1/2 = -0.5.
Enter x = 10 into “Solve for y”: y = 2 * 10 + 0 = 20. Enter y = 14 into “Solve for x”: x = (14 - 0) / 2 = 7.
Formula reference
| Quantity | Formula |
|---|---|
| Slope | m = (y2 - y1) / (x2 - x1) |
| Y-intercept | b = y1 - m * x1 |
| Line equation | y = mx + b |
| Solve for y | y = mx + b |
| Solve for x | x = (y - b) / m |
| Distance | sqrt((x2-x1)^2 + (y2-y1)^2) |
| Midpoint | ((x1+x2)/2, (y1+y2)/2) |
| Angle | arctan(m) in degrees |
| Perpendicular slope | -1/m |
All calculations run entirely client-side — no numbers leave your device.