✖

Equation of a line through two points calculator

Two different points determine exactly one line. The calculator writes it in the slope-intercept form y = mx + b. The slope (gradient) m tells you how far the line rises when you move one unit to the right, and the y-intercept b is where the line crosses the y-axis.

If both points have the same x-coordinate, the line is vertical. It has no slope, and its equation is simply x = x1.

Point A ( , )
Point B ( , )

Slope m = 2, y-intercept b = 1. The equation of the line is y = 2x + 1.

The line through points A and B. The green segment b shows where the line crosses the y-axis. The step at point A: one unit to the right and m units up

How it works

The calculator works out the slope and the y-intercept using these formulas:

m=y2−y1x2−x1,b=y1−m⋅x1

For points A(1, 3) and B(4, 9), first work out the slope. From A to B we move 3 to the right and 6 up:

m=9−34−1=63=2

Work out the y-intercept b from either point, for example A. Substitute into y = mx + b:

3=2⋅1+b/−2b=1

The equation of the line is y = 2x + 1. Check with point B: 2 · 4 + 1 = 9. It works. Other ways of writing a line are described in the article on lines.

Chapters: Quadratic equation calculator, Linear equation calculator, Simultaneous equations calculator, Distance between two points calculator, Midpoint of a line segment calculator, Equation of a line through two points calculator, Rounding calculator, Standard form calculator, Mixed number and fraction calculator