Line Equation Calculator
Enter two points and the calculator returns the equation of the straight line through them in slope-intercept form — the slope and the y-intercept together.
Slope and intercept at once
Enter the coordinates of two points and the line equation calculator returns the slope m and the y-intercept b for y = m·x + b together.
Avoid vertical lines
The two points must have different x-values — a vertical line has an undefined slope and no slope-intercept form.
What does the line equation calculator do?
The equation of a line through two points
This line equation calculator takes two points and finds the equation of the straight line that passes through both of them, written in slope-intercept form y = m·x + b. The slope m measures how steeply the line rises or falls between the points, and the y-intercept b is the value of y where the line crosses the y-axis. From two pairs of coordinates — (x₁, y₁) and (x₂, y₂) — it returns both numbers, so you can read off the whole equation at a glance. It is the line behind a trend through two data readings, the path between two map points, and any straight-line relationship you can pin down from a pair of observations.
Enter the coordinates of two points to get the slope and the y-intercept of the line through them instantly.
The slope is the change in y divided by the change in x between the two points, and the y-intercept is found by substituting one point back into y = m·x + b.
m = (y₂ − y₁) / (x₂ − x₁)b = y₁ − m·x₁First find the slope from the rise over the run, then use either point to solve for the intercept. The result is the single equation y = m·x + b that describes the line.
Suppose the line passes through the points (1, 2) and (3, 6).
Find the rise and the run
The change in y is 6 − 2 = 4, and the change in x is 3 − 1 = 2.
Divide to get the slope
m = 4 ÷ 2 = 2 — the line rises 2 units for every 1 unit it moves across.
Solve for the y-intercept
Using the first point, b = 2 − 2 × 1 = 0. The equation is y = 2·x + 0, or simply y = 2·x.
The two outputs together describe the line completely. The slope m tells you the direction and steepness: a positive slope rises from left to right, a negative slope falls, and the larger the magnitude the steeper the line. A slope of 2 means every step right of one unit lifts the line two units; a slope of −0.5 means it drops half a unit per step. The y-intercept b is where the line meets the vertical axis — the value of y when x is zero. Read together, y = m·x + b lets you find the y-value at any x, extend the line beyond your two points, or compare it with another line by its steepness and starting height. A slope of zero gives a flat, horizontal line at height b.
The calculation is exact, but two points are worth keeping in mind.
Vertical lines and other line forms
A vertical line — where the two points share the same x-value (x₂ = x₁) — has an undefined slope and cannot be written in slope-intercept form; it is instead described by x = constant, so the calculator returns no result for it. Slope-intercept form is also just one of several ways to write a line: the point-slope form y − y₁ = m(x − x₁) and the standard form Ax + By = C describe the same line, and one may suit your problem better than another.