Two points define exactly one straight line. This line equation calculator takes the coordinates of two points and returns the slope, the y-intercept, the x-intercept, the angle with the x-axis, the distance between the points and the midpoint, so you can write the line as y = mx + b.
How the calculation works
- Slope m = (y₂ − y₁) ÷ (x₂ − x₁). It is undefined when x₁ = x₂, which is a vertical line.
- y-intercept b = y₁ − m × x₁, so the equation is y = mx + b.
- x-intercept = −b ÷ m, the point where the line crosses the x-axis.
- Distance = √[(x₂ − x₁)² + (y₂ − y₁)²], midpoint = the average of the coordinates and angle = arctangent of the slope.
Example
Find the line through (2, 3) and (6, 11). The slope is (11 − 3) ÷ (6 − 2) = 2. The y-intercept is 3 − 2 × 2 = −1, so the equation is y = 2x − 1. The line crosses the x-axis at 0.5, makes an angle of 63.43° with it, the points are 8.944 apart and the midpoint is (4, 7).
Why it matters
Finding the line through two points is one of the first skills in algebra and comes back in physics, economics, graphics and data analysis. A straight-line model through two measurements gives a quick prediction, a break-even point, a price-demand relation or the slope of a road. The calculator checks homework and saves the steps.
Good to know
Enter the points in the same units on both axes if you want the angle and the distance to make sense, since the angle depends on the scale of the axes. For real data with more than two points, a regression line is better than a line through two of them. The x-intercept is shown as zero for a horizontal line only because it does not exist, so ignore it in that case. Rounding to four decimals can hide an exact fraction, so convert the slope to a fraction by hand when needed.
Related tools
The triangle calculator solves shapes from sides and angles, the parabola calculator handles curves and the point-line distance calculator measures how far a point is from a line.