Slope, Distance, Midpoint & Gradient Percentage Calculator
Computes the slope between two points as rise over run, (y₂ − y₁) ÷ (x₂ − x₁), with exact fraction arithmetic, so decimal coordinates leave no rounding noise. From the same points it returns the angle from the horizontal as the arctangent of the slope, the grade as a percentage, the 1 : n ratio used for ramps and older road signs, the distance by the Pythagorean formula, the midpoint, and the line in slope-intercept and standard form.
Enter the coordinates of two points to get the slope as an exact reduced fraction and a decimal, the grade, the angle and the 1 : n ratio, the distance, the midpoint and the equation of the line. The defaults, (2, 3) to (10, 7), give a slope of 1/2 = 0.5, a 50% grade, 26.56505 degrees and a distance of 8.94427.
How the calculation works
Slope is the change in y divided by the change in x between the two points, the "rise over run" of school algebra. The distance and the midpoint come from the same two points:
m = (y2 − y1) ÷ (x2 − x1)
d = √((x2 − x1)2 + (y2 − y1)2)
M = ((x1 + x2) ÷ 2, (y1 + y2) ÷ 2)
Everything else follows from these. The grade is the slope times 100, shown as a percentage. The angle from the horizontal is the arctangent of the slope, so it runs from −90 to 90 degrees, negative when the line falls from left to right. The 1 : n ratio sets the rise to 1 and divides the run by the rise. The y-intercept is b = y1 − mx1, which gives the slope-intercept form y = mx + b, and multiplying out the denominators gives the standard form Ax + By = C with whole-number coefficients that share no common factor.
The arithmetic is exact. Each coordinate is read as a decimal, scaled to a whole number, and the differences are kept as integers, so the calculator reduces the fraction 4/8 to 1/2 rather than dividing two binary floating-point numbers. That matters when the points are close together. Between (1.0000000001, 2) and (1.0000000002, 3) the run is one ten-billionth and the rise is 1, so the slope is exactly 10000000000. Ordinary floating-point division of the same inputs returns about 9,999,999,172.6, because neither x value has an exact binary form and the subtraction magnifies the error. A decimal answer that terminates is shown with an equals sign, as in 1/2 = 0.5; one that repeats is rounded and marked with ≈, as in 1/12 ≈ 0.0833333.
A worked example with the defaults
Take the default points (2, 3) and (10, 7).
- The rise is 7 − 3 = 4 and the run is 10 − 2 = 8, so the slope is 4/8, which reduces to 1/2 = 0.5.
- The grade is 0.5 × 100 = 50%, and the ratio is 1 : 8 ÷ 4 = 1 : 2.
- The angle is the arctangent of 0.5, which is 26.56505 degrees.
- The distance is √(8² + 4²) = √80. Because 80 = 16 × 5, it simplifies to 4√5, which is 8.94427 to five decimal places.
- The midpoint is ((2 + 10) ÷ 2, (3 + 7) ÷ 2) = (6, 5).
- The intercept is 3 − 0.5 × 2 = 2, so the line is y = 0.5x + 2. Clearing the fraction gives the standard form x − 2y = −4.
A 50% grade is far steeper than any ramp, so the ADA comparison reads "Steeper than 1:12".
Grade, ratio and angle side by side
The three ways of stating steepness come from the same slope, but they don't scale together. Grade and ratio are reciprocal views of rise over run, while the angle follows the arctangent and bends away from the grade as the line steepens. These rows come from entering (0, 0) and (n, 1):
| Ratio | Slope | Grade | Angle |
|---|---|---|---|
| 1 : 48 | 1/48 | 2.08% | 1.19° |
| 1 : 20 | 1/20 | 5% | 2.86° |
| 1 : 12 | 1/12 | 8.33% | 4.76° |
| 1 : 10 | 1/10 | 10% | 5.71° |
| 1 : 8 | 1/8 | 12.5% | 7.13° |
| 1 : 5 | 1/5 | 20% | 11.31° |
| 1 : 2 | 1/2 | 50% | 26.57° |
| 1 : 1 | 1 | 100% | 45° |
A 100% grade is 45 degrees, not 90. Doubling the grade from 10% to 20% roughly doubles the angle, but doubling it from 50% to 100% adds only about 18 degrees.
Where slopes are regulated
Building codes and road signs state slope as a ratio or a percentage, and both come straight from rise over run. The 2010 ADA Standards for Accessible Design, which the Department of Justice adopted in regulations published in the Federal Register on September 15, 2010, set the limits that the calculator's ADA line compares against. Section 403.3 says the running slope of walking surfaces shall not be steeper than 1:20, and their cross slope not steeper than 1:48. Section 405.2 says ramp runs shall have a running slope not steeper than 1:12, and section 405.6 caps the rise of any ramp run at 30 inches. In existing buildings where space is short, Table 405.2 allows a slope between 1:12 and 1:10 for a rise of up to 6 inches, and between 1:10 and 1:8 for up to 3 inches; a slope steeper than 1:8 is prohibited. An advisory note to section 405.3 says cross slope is measured the same way as slope, as the rise over the run. Newly built or altered state and local government facilities whose construction starts on or after March 15, 2012 must comply with these standards. The calculator's comparison is geometry only and says nothing about landings, handrails or the other parts of section 405.
British road signs work in percentages. Chapter 4 of the Department for Transport's Traffic Signs Manual, the 2018 edition, says the gradient on steep-hill signs must be expressed as a percentage, and that old signs showing a ratio may stay up until they wear out. It calculates the gradient from the tangent of the angle, which is rise over run, and notes that in practice it makes little difference whether the sine or the tangent is used. The steep-hill-downwards sign should normally be used only where the gradient is 10% or more, rounded to the nearest whole number, so 10.4% is signed as 10% and 10.6% as 11%. The government's sign guide gives the conversion: 10% is equivalent to 1:10, and 20% to 1:5.
How coordinates, slope and m entered mathematics
René Descartes published La Géométrie at Leiden in 1637 as one of three appendices to his Discours de la méthode, and the MacTutor biography calls it by far the most important part of that work. It applies algebra to geometry, the source of what is now called Cartesian geometry. The text itself is less modern than the name suggests. In his solution of a problem posed by Pappus, Descartes picks two lines as the principal ones, names a segment of one x and a segment of the other y, and draws the remaining lines at given angles. Those are lengths, not the perpendicular, numbered axes of a modern graph. Early in the same book, the example Descartes uses to show how to write a square root is the root of a squared plus b squared, the shape the distance formula still takes.
Jeff Miller's record of early uses of mathematical words finds slope in an 1829 treatise on practical surveying. It also quotes an 1857 Mathematical Dictionary and Cyclopedia of Mathematical Science, which says a slope is generally given by its tangent, so that a slope of 1/2 means "the slope is 1 upon 2": rising 1 in passing over a horizontal distance of 2. That is the default line on this page. The earliest known use of the letter m for slope is in Vincenzo Riccati's 1757 memoir, which writes the equation of a line as y = mx + n. Matthew O'Brien wrote y = mx + c in 1842, and George Salmon used y = mx + b in his Treatise on Conic Sections, first published in 1848. It is not known why m was chosen. A suggested link to the French verb monter, to climb, has no evidence behind it, and Descartes himself did not use m. As late as 1924, Harding and Mullins's Analytic Geometry called the slope of a line parallel to the y-axis infinite, where modern textbooks say undefined.
Distance, midpoint and the limits of the tool
The distance formula is the Pythagorean theorem applied to the run and the rise: they are the two legs of a right triangle whose hypotenuse joins the points. The exact form pulls square factors out of the sum of squares, so √80 becomes 4√5. It is shown when that sum, in the scaled whole numbers the calculator uses, stays within 9,007,199,254,740,991, and when a radical stays within 16 characters, such as 30√145 or 0.0001√5. Otherwise only the decimal is shown. The midpoint is the average of the coordinates and always has a terminating decimal, so it is shown in full.
Coordinates can run from −1,000,000,000 to 1,000,000,000, with up to 15 significant digits and 15 decimal places, so a nine-digit whole part leaves room for six decimals. Fifteen digits is the most a decimal keeps on its way through the browser's number field, which stores it as a binary floating-point number before the calculator sees it. A longer entry is usually rounded to a value the calculator flags with an error, but not always: 999999999.000000000000001 arrives as 999999999, so the calculator never sees the extra digits. A vertical line gets an equation of the form x = c and no grade or ratio; a horizontal one gets y = c, a slope of 0 and a grade of 0%.
Frequently asked questions
How do you find the slope between two points?
Subtract the first point's coordinates from the second's, then divide the change in y by the change in x. For (2, 3) and (10, 7) the rise is 7 − 3 = 4 and the run is 10 − 2 = 8, so the slope is 4/8, which reduces to 1/2 = 0.5. Swapping the two points flips the sign of both differences and leaves the slope unchanged.
How do I turn a slope into a grade percentage or a 1:n ratio?
Multiply the slope by 100 for the grade, and divide the run by the rise for the n in 1:n. A slope of 0.5 is a 50% grade and a ratio of 1 : 2. The UK government's sign guide gives the same conversions for road gradients: 10% is equivalent to 1:10 and 20% to 1:5. The ADA ramp limit of 1:12 is a grade of 8.33%.
Is a grade percentage the same as an angle in degrees?
No. The grade is the tangent of the angle times 100, so the two only line up near zero. A 10% grade is 5.71059 degrees, a 50% grade is 26.56505 degrees, and a 100% grade, where the rise equals the run, is 45 degrees. A vertical line has an angle of 90 degrees and no grade at all, because its run is zero.
What is the steepest ramp the ADA allows?
Section 405.2 of the 2010 ADA Standards says ramp runs shall have a running slope not steeper than 1:12, and section 405.6 caps the rise of any single run at 30 inches. A 30-inch rise at 1:12 needs 360 inches of run, a grade of 8.33% and an angle of 4.76364 degrees. Existing buildings short of space may use 1:10 for a rise of up to 6 inches or 1:8 for up to 3 inches, and anything steeper than 1:8 is prohibited.
Why is the slope of a vertical line undefined?
Both points share the same x, so the run is zero and the slope formula would divide by zero. The calculator reports the line as x = c, an angle of 90 degrees and no grade, while the distance and midpoint still work. If both points are identical, there is no line at all and the calculator asks you to move one of them.
How is the distance between two points related to the Pythagorean theorem?
The rise and the run are the two legs of a right triangle, and the straight line between the points is its hypotenuse. For (2, 3) and (10, 7) the legs are 4 and 8, so the distance is the square root of 16 + 64 = 80. That simplifies to 4√5, about 8.94427. The midpoint averages the coordinates and lands at (6, 5).
Sources
- 2010 ADA Standards for Accessible Design, 403.3 Slope and 405 Ramps, U.S. Access Board, 2010
- 2010 ADA Standards for Accessible Design, U.S. Department of Justice, ADA.gov, 2010
- Traffic Signs Manual, Chapter 4: Warning Signs, Department for Transport, GOV.UK, 2018
- Know your traffic signs: warning signs, Department for Transport, GOV.UK
- René Descartes, biography (J. J. O'Connor and E. F. Robertson), MacTutor History of Mathematics, University of St Andrews
- La géométrie (René Descartes, 1637), nouvelle édition, A. Hermann, Paris, Project Gutenberg, 1886
- Earliest Uses of Symbols for Geometry: Slope (Jeff Miller), MacTutor History of Mathematics, University of St Andrews
- Earliest Known Uses of Some of the Words of Mathematics (S): Slope (Jeff Miller), MacTutor History of Mathematics, University of St Andrews
- College Algebra 2e, 2.1 The Rectangular Coordinate Systems and Graphs, OpenStax, Rice University
- College Algebra 2e, 4.1 Linear Functions, OpenStax, Rice University