Overview
Two points are enough to define a straight line. This calculator finds its equation, slope and intercepts, and the distance between the points.
Vertical lines are handled separately because their slope is undefined.
Worked examples
| Inputs | Result |
|---|---|
| x₁1y₁2x₂4y₂11 | y = 3x − 1Slope: 3y-intercept: -1x-intercept: 0.333333Angle with the x-axis: 71.5651°Distance between points: 9.48683 |
Show 3 more examples
| x₁0y₁0x₂4y₂8 | y = 2x + 0Slope: 2y-intercept: 0x-intercept: 0Angle with the x-axis: 63.4349°Distance between points: 8.94427 |
| x₁-2y₁5x₂3y₂-5 | y = -2x + 1Slope: -2y-intercept: 1x-intercept: 0.5Angle with the x-axis: -63.4349°Distance between points: 11.1803 |
| x₁1y₁1x₂5y₂1 | y = 0x + 1Slope: 0y-intercept: 1x-intercept: noneAngle with the x-axis: 0°Distance between points: 4 |
How it works
The slope is the rise over the run, m = (y₂ − y₁) ÷ (x₂ − x₁). The y-intercept follows from b = y₁ − m·x₁, giving y = mx + b.
The formula
m = (y₂ − y₁) ÷ (x₂ − x₁) · b = y₁ − m × x₁
| m | Slope |
| b | y-intercept |
Practical tips
- Parallel lines have equal slopes; perpendicular lines have slopes that multiply to −1.
- The x-intercept is where y = 0, at x = −b ÷ m.
Frequently asked questions
What is the line through (1, 2) and (3, 6)?
y = 2x.
What if the x-values are equal?
The line is vertical, x = constant, and has no slope.