Slope & Line Calculator
From two points, get the slope, the line equation y = mx + b, the distance, midpoint, angle of inclination, and rise/run.
Point 1
Point 2
y = 2x + 0
Slope (m)
2
Angle
63.43°
Distance
6.7082
Midpoint
(2.5, 5)
Rise (Δy)
6
Run (Δx)
3
How to use
- Enter the x and y coordinates of the first point.
- Enter the x and y coordinates of the second point.
- Read the slope, equation, distance, midpoint, angle and rise/run; copy the equation if you need it.
About this tool
ShowHide
Give it two points and it works out everything the line through them implies: the slope as Δy over Δx, the equation in slope-intercept form, the angle of inclination, the straight-line distance, the midpoint, and the rise and run separately. A vertical line is handled rather than divided by zero — the slope comes back undefined and the equation as x equals a constant, which is correct and is the case most implementations forget.
Slope gets expressed three different ways in practice, and they are easy to confuse because all three sound like percentages of something. As a ratio it is rise over run. As an angle it is the arctangent of that ratio. As a grade it is the ratio times a hundred, and that last one is where the confusion lives: a 100 percent grade is not vertical, it is 45 degrees, because it means rising one unit for every unit travelled horizontally. A 10 percent road sign is 5.7 degrees, and an 8 percent grade is 4.6 — numbers that feel much smaller than the signs suggest.
Roofing uses a fourth convention, rise in inches per twelve inches of run. A 4:12 pitch is 18.4 degrees and a 6:12 is 26.6, which is why a roofer's "six twelve" and a surveyor's "twenty-six and a half degrees" describe the same roof without either of them converting.
The midpoint and distance are worth a note about what they assume. Both treat the plane as flat and the axes as having the same units, which is true on graph paper and not true of latitude and longitude — a degree of longitude is a different distance from a degree of latitude everywhere except the equator, so the distance between two coordinates is not the distance this returns. For geographic work the answer comes from a haversine or a geodesic calculation, not from Pythagoras on the raw degrees.
Frequently asked questions
How is the slope calculated?
Slope m = (y₂ − y₁) / (x₂ − x₁), the change in y divided by the change in x. For example, from (1, 2) to (4, 8) the slope is (8 − 2) / (4 − 1) = 2.
What happens with a vertical line?
If both points share the same x value, the run is zero and the slope is undefined — a vertical line. The equation is shown as x = that value, and the angle is 90°.
What is the angle of inclination?
It's the angle the line makes with the horizontal x-axis, equal to arctan(slope). A slope of 1 is 45°; a horizontal line is 0°.
How is the distance found?
By the distance formula √((x₂ − x₁)² + (y₂ − y₁)²) — the length of the straight segment between the two points.
What is the difference between slope, percent grade and degrees?
They describe the same steepness three ways. Slope is rise over run as a plain ratio, percent grade is that ratio times a hundred, and the angle is its arctangent. They diverge fast: a 100 percent grade is a slope of 1 and only 45 degrees, so a road sign reading 10 percent is about 5.7 degrees, not 10.
Why is a vertical line undefined rather than infinite?
Because the run is zero and dividing by zero has no value, not a very large one. A vertical line has no slope in the y = mx + b sense at all — it cannot be written in that form, only as x equals a constant. That is also why it is the one case a slope-intercept equation cannot express.
Related tools
Linear Regression Calculator
Paste (x, y) pairs and instantly get the best-fit line — slope, intercept, Pearson r, R², and a live prediction — all computed in your browser.
Math & Statistics
Distance & Bearing Between Coordinates (WGS 84)
Distance, bearings and midpoint between two lat/lon points on the WGS 84 ellipsoid, or the destination from a start point, bearing and distance.
Science & Engineering
Time Difference Calculator
Calculate the exact difference between two date-times, broken down into days, hours, minutes, and seconds.
Time
Quadratic Equation Solver
Solve ax² + bx + c = 0 with the quadratic formula — real or complex roots, plus discriminant, vertex, axis of symmetry and sum/product of roots.
Math & Statistics
Polynomial Root Finder (Cubic, Quartic & Beyond)
Find all real and complex roots of a polynomial up to degree 30 — cubic, quartic or higher — with multiplicities, the factored form and a residual check.
Math & Statistics
t-Test Calculator (paired, Welch, one-sample)
One-sample, paired and two-sample t-tests from raw data or summary statistics: t, degrees of freedom, p-value, confidence interval and Cohen's d.
Math & Statistics