Coordinate geometry
Equation of the line through two points
Type the coordinates of two points: the line joining them appears at once in slope-intercept and standard form, with the slope, the intercepts and everything the exercise asks for next.
How the line through two points is found
Two distinct points determine exactly one line: it is the first axiom of geometry, and in coordinates it becomes a formula. The slope m is the ratio of the change in y to the change in x, (y₂−y₁)/(x₂−x₁): it says how far the line rises for every unit you move to the right. Once m is known, the intercept q follows from making the line pass through either point, and the equation y = mx + q is complete.
The standard form ax + by + c = 0 looks like a mere rewriting, but it is the one that always holds. A vertical line has no slope — dividing by x₂−x₁ = 0 is not allowed — and yet its equation x = 3 is written without difficulty as x − 3 = 0. That is why this calculator builds the standard form first and reads everything else off it: the special case needs no separate treatment.
The slope is also the key to parallel and perpendicular lines. Two lines are parallel when they share the same m; they are perpendicular when the product of their slopes is −1, that is, when one is the negative reciprocal of the other. The value is reported under the result because it is almost always the next thing the exercise asks for.
Common mistakes
- Swapping numerator and denominator in the slope: it is the difference of the y values on top and of the x values below, not the other way round. The wrong answer is the reciprocal of the right one, and with m = 2 it becomes 0.5 — plausible, and therefore hard to spot.
- Subtracting the coordinates in a different order above and below: (y₂−y₁)/(x₁−x₂) flips the sign of m and mirrors the line. The order of the points can be either way, but it must be the same in both terms.
- Looking for the slope of a vertical line: it does not exist, and that is not a calculation error. The line x = k is perfectly well defined but has infinite steepness, and must be written in that form.
Frequently asked questions
How do you find the equation of a line through two points?
Work out the slope m = (y₂−y₁)/(x₂−x₁), then make the line pass through one of the points using y − y₁ = m(x − x₁). Expanding gives the slope-intercept form y = mx + q. The calculator shows both steps along with the standard form ax + by + c = 0.
What does it mean that the slope is undefined?
It means the line is vertical. In that case x₂ − x₁ is zero and the formula would require dividing by zero. The line certainly exists, but its equation is x = constant and it cannot be written as y = mx + q.
How do I get the line perpendicular to this one?
The perpendicular slope is −1/m and is listed among the results. For the full equation, make it pass through the required point: y − y₀ = (−1/m)(x − x₀). If the original line is horizontal, the perpendicular is vertical and is written x = x₀.
Does the order I enter the two points change the answer?
No. Swapping P₁ and P₂ changes the sign of both the numerator and the denominator of the slope, and the ratio stays the same. The equation of the line is identical.
How this calculation works
Slope: m = (y₂ − y₁)/(x₂ − x₁), defined only when x₁ ≠ x₂. Point-slope form: y − y₁ = m(x − x₁). Slope-intercept form: y = mx + q with q = y₁ − m·x₁. Standard form, valid for vertical lines too: (y₂ − y₁)(x − x₁) − (x₂ − x₁)(y − y₁) = 0, that is ax + by + c = 0 with a = y₂ − y₁, b = −(x₂ − x₁), c = −(a·x₁ + b·y₁). Angle of inclination: α = arctan(m), reported in [0°; 180°). Perpendicular slope: m⊥ = −1/m. Midpoint: M = ((x₁+x₂)/2; (y₁+y₂)/2). Distance: d = √((x₂−x₁)² + (y₂−y₁)²).
Related calculators
Distance and midpoint
Distance between two points in the coordinate plane and coordinates of the midpoint.
Conic sections
Identifies the conic from its general equation and finds centre, foci, axes, eccentricity, asymptotes and canonical form.
Vector mathematics
Dot and cross products, the angle between two vectors, projection and areas.