Finds the slope a and the intercept b of the line y = ax + b through the two points (x₁, y₁) and (x₂, y₂).
Explanation
Two points determine exactly one line. This finds the slope a and the intercept b that describe it as y=ax+b.
a=x2−x1y2−y1,b=y1−ax1 - (x1,y1), (x2,y2) — the two points on the line
- a — the slope: how far y climbs for every 1 that x moves right
- b — the intercept: the y coordinate where the line crosses the y axis, which is the value of y when x=0
Slope is rise over run. Once you have it, substituting either point gives the intercept.
Example
Take the line through (1,2) and (3,8).
a=3−18−2=26=3 The intercept is b=2−3×1=−1, so the line is y=3x−1. Checking against the other point, 3×3−1=8, which is indeed (3,8).
Notes
- If x1=x2 the denominator is zero and there is no slope. The line through those points is vertical; it cannot be written as y=ax+b at all, only as x=x1. The calculator flags this.
- A positive slope rises to the right, a negative one falls, and a slope of 0 is a horizontal line.
- Two identical points determine nothing. Infinitely many lines pass through a single point.
- The intercept also comes from b=y2−ax2. Either point gives the same value, which makes it a handy check.