Line Equation From Two Points Calculator
Get the slope and y-intercept of the straight line through two points, and so its equation in y = mx + b form, from the points' x and y coordinates.
Line Equation From Two Points Calculator
Background.
Two points are enough to pin down a straight line, and once you have its equation you can read off every other point on it. That is why the two-point line turns up far outside algebra homework: converting temperatures, estimating a value between two readings, or splitting a bill into a fixed charge and a rate.
The working is two short steps. The slope, m, is rise over run: the change in y between the points divided by the change in x. It says how far y moves for each one-unit step in x, upward if positive, downward if negative, not at all if zero. The y-intercept, b, is where the line crosses the vertical axis, found by putting either point into y = mx + b and solving for b. Together they give the slope-intercept form.
Celsius and Fahrenheit make a neat test. Water freezes at 0 °C, which is 32 °F, and boils at 100 °C, which is 212 °F. The slope through those two points is 180 ÷ 100 = 1.8 and the intercept is 32, so °F = 1.8 × °C + 32: the familiar conversion, rebuilt from two facts.
The same reasoning works backwards on a fare. If a 10 km ride costs $9 and a 25 km ride $18, the slope of 0.6 is the rate of 60 cents per kilometre, and the intercept of 3 is the $3 you pay before the car moves.
One kind of line has no slope-intercept form: a vertical one, where both points share the same x. Its run is zero, the slope would mean dividing by zero, and the page rejects it, although the line itself is simply x = that value. Results are shown to at most ten decimal places, so a slope such as 1/3 appears as a rounded decimal.
What is line equation from two points calculator?
The equation of the line through two points (x1, y1) and (x2, y2) is the rule y = mx + b that both points satisfy. The slope m = (y2 − y1) ÷ (x2 − x1) measures steepness as vertical change per unit of horizontal change, and the y-intercept b is the value of y where x = 0. Any two points with different x coordinates define exactly one such line, and any other pair of points taken from it yields the same m and b.
How to use this calculator.
- Enter the first point's x and y, then the second point's. Either point can go first: swapping them flips the sign of both the rise and the run, so the slope does not change.
- Keep each axis in a single unit. If x is in kilometres for one point, it must be kilometres for the other too.
- Check that the two x values differ. Equal x values describe a vertical line, written x = constant, which has no slope to report.
- Write the result as y = mx + b using the slope and intercept shown. To find where the line meets the x axis, work out −b ÷ m, provided m is not zero.
The formula.
m = (y2 − y1) ÷ (x2 − x1), then b = y1 − m × x1. The first is rise over run. The second comes from rearranging y1 = m × x1 + b, which must hold because the first point lies on the line; using the second point instead, b = y2 − m × x2, gives the same value. Because the slope is a ratio of differences, it becomes touchy when the two x values are close together: any error in the y values is divided by a small run and grows. The intercept inherits that error multiplied by x1, so when both points sit far from x = 0, b is the less reliable of the two results. If y1 = y2 the slope is 0 and the line is horizontal, y = b.
A worked example.
The two points are (0, 1) and (2, 5). The rise is 5 − 1 = 4 and the run is 2 − 0 = 2, so the slope is 4 ÷ 2 = 2: y climbs two units for every unit of x. The intercept is b = 1 − 2 × 0 = 1, which is no surprise, since the first point already sits on the y axis. The line is y = 2x + 1, and the second point checks out: 2 × 2 + 1 = 5. Any other pair on the same line gives the same answer. Starting from (3, 7) and (−1, −1), the rise is −8 over a run of −4, again a slope of 2, and b = 7 − 2 × 3 = 1. A falling line looks different: (−2, 5) and (4, 2) give a slope of −0.5 and an intercept of 4.
Frequently asked questions.
How do I write the same line in point-slope or standard form?
Why is there no slope for a vertical line?
How do I find where the line crosses the x axis?
What is the slope of a line perpendicular to this one?
Can I use the line to estimate a value between two measurements?
References& sources.
- [1]OpenStax, Rice University. College Algebra 2e, 2021. Algebra and function chapters. Retrieved 2026-08-06.
- [2]OpenStax, Rice University. Precalculus 2e, 2021. Trigonometry and analytic geometry chapters. Retrieved 2026-08-06.
- [3]NIST/SEMATECH. e-Handbook of Statistical Methods, 2012. Chapter 1.3 and Chapter 4. Retrieved 2026-08-06.
How this page was produced
- Published by
- Quanta Calculator
- Overseen by
- Daniel, Quanta Calculator Researcher
- Primary sources
- 3 cited below
- Method
- m=(y2-y1)/(x2-x1); b=y1-mx1
- Published
- Last verified
Built with AI assistance and verified by automated tests against the cited sources — every worked example on this page is computed by the same code that runs the calculator. How we build and check calculators.
In this category
Embed
Quanta Pro
Paid features are coming later.
- All 1560 calculators remain free
- No billing is enabled