From (1, 2) to (4, 6)
m = (6 − 2) ÷ (4 − 1) = 4/3
The rise is 4 and the run is 3. Substituting the first point into b = y − mx gives b = 2/3, so y = (4/3)x + 2/3.
Algebra
Enter two points to find their slope, line equation, midpoint, and distance. Keep exact answers alongside decimal values.
Slope — exact
Enter all four coordinates, then select Calculate.
≈ marks a rounded decimal, including a nonzero value that rounds to 0. Distance assumes perpendicular axes with the same units and scale.
Your inputs are processed in your browser and are not sent to a server.
m = (6 − 2) ÷ (4 − 1) = 4/3
The rise is 4 and the run is 3. Substituting the first point into b = y − mx gives b = 2/3, so y = (4/3)x + 2/3.
Midpoint (5/2, 4); distance 5
Average the two x coordinates and the two y coordinates to find the midpoint. The right triangle with legs 3 and 4 has distance √(3² + 4²) = 5.
x = −2 or y = 3
Points (−2, 1) and (−2, 7) form a vertical line: x = −2, with undefined slope. Points (−2, 3) and (5, 3) form a horizontal line: y = 3, with slope 0.
m = 1; distance = √2
The line is y = x and its midpoint is (1/2, 1/2). The exact distance is √2; at six decimal places, it is approximately 1.414214.
For points (x₁, y₁) and (x₂, y₂), Δx = x₂ − x₁ and Δy = y₂ − y₁. If Δx is nonzero, the slope is m = Δy ÷ Δx and the y-intercept is b = y₁ − mx₁. The resulting line is y = mx + b.
The midpoint is ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2). Euclidean distance is √((Δx)² + (Δy)²), assuming a rectangular coordinate plane with compatible axis units.
Further reading: OpenStax, Linear Functions and The Rectangular Coordinate Systems and Graphs.
This calculator calls it undefined, because division by zero does not produce a real-number slope. Two distinct points with the same x coordinate give the line x = that coordinate. If x = 0, the line is the y-axis itself, so it has no single y-intercept.
The distance is 0 and the midpoint is that same point. The slope formula becomes 0 ÷ 0, and infinitely many lines pass through the point. The result therefore says “No unique line” and leaves the slope undefined.
It reverses the signs of both rise and run, so their ratio stays the same. The line, midpoint, and distance are unchanged. Keep the same point order in both coordinate differences.
Entered decimals become exact fractions. Line classification, fractions, and midpoint calculations use integer arithmetic. Square distances remain exact; perfect rational square roots become fractions, and other distances remain radical expressions that are not necessarily simplified. Decimal displays use up to 0, 2, 4, 6, or 10 places, omit trailing zeros, and round halfway values away from zero. Irrational distances use an exact midpoint comparison for rounding. The ≈ sign marks every rounded value, even one displayed as 0.
Enter each coordinate in its own field. Correctly grouped thousands commas, such as −1,234.5, are accepted. Use a decimal point and a leading zero, such as 0.5. Fraction expressions such as 1/3, exponent notation, and whole coordinate pairs are not accepted. Each field allows up to 15 integer digits, 10 decimal places, and 64 characters.
The tool treats every entered digit as exact. It does not estimate measurement uncertainty. A tiny nonzero run still produces a finite slope, even if a rounded display makes the points appear to share an x coordinate. Physical distance requires the same units and scale on both perpendicular axes.