Line Equation from Two Points Calculator

Enter two points, (x1, y1) and (x2, y2), to get the line's slope and its equation in slope-intercept, point-slope, and standard form.

Quick Facts

Slope formula
m = (y2 − y1) / (x2 − x1)
Rise over run between the two points.
Point-slope form
y − y1 = m(x − x1)
Built directly from the slope and one known point.
Vertical lines
x = x1 (slope undefined)
Occurs when x1 = x2 — the run is zero.

Your Results

Calculated
Slope (m)
-
m = (y2 − y1) / (x2 − x1)
Slope-Intercept Form
-
y = mx + b
Point-Slope Form
-
y − y1 = m(x − x1)
Standard Form
-
Ax + By = C

Ready

Enter two distinct points, then press Calculate.

Formula and Method for Finding a Line Equation from Two Points

Any two distinct points, (x1, y1) and (x2, y2), determine exactly one straight line. The first step is finding the line's slope, m, which measures how much y changes for every unit change in x: m = (y2 − y1) / (x2 − x1). Once you have the slope, you can write the line's equation in point-slope form, slope-intercept form, or standard form — all three describe the same line, just arranged differently.

How the calculation works

The calculator first computes the slope, m = (y2 − y1) / (x2 − x1). If x1 and x2 are equal, the denominator is zero, so the slope is undefined and the line is vertical, with equation x = x1. Otherwise, it substitutes m and either point into point-slope form, y − y1 = m(x − x1), then distributes and isolates y to get slope-intercept form, y = mx + b, where the y-intercept is b = y1 − m·x1. Finally, it clears the fraction and rearranges into standard form, Ax + By = C, using A = (y2 − y1), B = (x1 − x2), and C = A·x1 + B·y1, simplified to the smallest integer coefficients when possible. A special case is a horizontal line (y1 = y2), which has slope m = 0 and the simple equation y = y1.

Common mistakes

  • Swapping the order of subtraction: the numerator and denominator of the slope must use points in the same order — (y2 − y1)/(x2 − x1), not a mix like (y2 − y1)/(x1 − x2), which flips the sign.
  • Dividing by zero: if x1 = x2, the slope formula divides by zero. This does not mean "no line" — it means the line is vertical (x = constant), which has no slope-intercept form.
  • Using identical points: if (x1, y1) and (x2, y2) are the same point, infinitely many lines pass through it, so no unique equation can be determined.

Real-world applications

  • Finding a linear trend line between two known data points, such as predicted growth between two measured years.
  • Physics and engineering problems that model constant-rate relationships, like distance versus time at a fixed speed.
  • Computer graphics and mapping software, which frequently need the equation of a line segment between two coordinates.
  • Algebra and geometry coursework, including graphing lines and converting between equation forms.

Frequently Asked Questions

How do I find the equation of a line from two points?
First find the slope: m = (y2 − y1)/(x2 − x1). Then plug the slope and either point into point-slope form: y − y1 = m(x − x1). Distribute and solve for y to convert it into slope-intercept form, y = mx + b, where b = y1 − m·x1.
What if the two points have the same x-coordinate?
If x1 = x2, the line is vertical and its slope is undefined (division by zero in the slope formula). A vertical line's equation is simply x = x1, since every point on the line shares that same x-coordinate.
What is the difference between slope-intercept, point-slope, and standard form?
Slope-intercept form, y = mx + b, shows the slope and y-intercept directly. Point-slope form, y − y1 = m(x − x1), is built straight from the slope and one known point, useful mid-derivation. Standard form, Ax + By = C, has no fractions and is common for systems of equations; the three forms describe the same line and can be converted into one another with algebra.
What if the two points are identical?
If (x1, y1) and (x2, y2) are the same point, infinitely many lines pass through it and no unique equation exists. You need two distinct points to determine a single line.