Understanding the line equation from two points — concept and principle
Two distinct points determine exactly one straight line. This calculator turns two points into the line's equation in slope-intercept form (y = mx + b) and in standard form (Ax + By = C), and also gives the slope, the line's direction angle and the slope of any perpendicular line. It is used in algebra and analytic geometry, for linear interpolation between two data points, for straight-line trends and for road or ramp gradients.
How it is calculated
- Slope: m = (y₂ − y₁) ÷ (x₂ − x₁).
- Intercept: b = y₁ − m × x₁, giving y = mx + b.
- Standard form: (y₂ − y₁)x − (x₂ − x₁)y = (y₂ − y₁)x₁ − (x₂ − x₁)y₁. The calculator divides out common factors and makes A ≥ 0.
- Angle: the line's inclination from the positive x-axis, 0° to 180°, the same whichever point comes first.
- Perpendicular slope: −1 ÷ m.
If x₁ = x₂, the line is vertical and its equation is x = x₁.
The principle
On a straight line, the ratio of vertical change to horizontal change is the same between any two of its points. That constant ratio is the slope. Once you know m, any known point fixes where the line sits: substituting (x₁, y₁) into y = mx + b gives b. The standard form comes from cross-multiplying the two-point form (y − y₁)(x₂ − x₁) = (x − x₁)(y₂ − y₁), which also works for vertical lines. The slope equals tan θ, so the angle is its arctangent. Two non-vertical lines are perpendicular when the product of their slopes is −1, because rotating a direction (Δx, Δy) by 90° gives (−Δy, Δx).
Worked example
- Inputs: (x₁, y₁) = (1, 3), (x₂, y₂) = (4, 9).
- Slope: (9 − 3) ÷ (4 − 1) = 6 ÷ 3 = 2.
- Intercept: 3 − 2 × 1 = 1, so y = 2x + 1.
- Standard form: cross-multiplying gives 6x − 3y = −3; dividing by 3 gives 2x − y = -1.
- Angle: arctan(2) ≈ 63.43494882°; perpendicular slope: −1 ÷ 2 = -0.5.
How to read the result
A slope of 2 means y rises 2 for every 1 unit of x. As a gradient, slope × 100 is the percent grade, so 2 is a 200% grade, about 63.4°. The intercept 1 is where the line crosses the y-axis. You can check the equation by substituting both points: 2 × 4 + 1 = 9.
Common mistakes
- Mixing the order of subtraction: (y₂ − y₁) ÷ (x₁ − x₂) flips the sign.
- Forgetting that the perpendicular slope is the negative reciprocal, not just the negative.
- Thinking a different-looking standard form is wrong; 6x − 3y = −3 and the reduced 2x − y = −1 describe the same line.
Frequently asked questions
How do I write the line in point-slope form?
Use y − y₁ = m(x − x₁). For the example, y − 3 = 2(x − 1).
How do I find the x-intercept?
Set y = 0: x = −b ÷ m. For y = 2x + 1, x = −0.5.
How do I tell if two lines are parallel?
Non-vertical lines are parallel when their slopes are equal and their intercepts differ.
Sources: R. Descartes, La Géométrie (1637), foundation of analytic geometry · J. Stewart, L. Redlin and S. Watson, Precalculus: Mathematics for Calculus, Cengage, chapter on lines