$ man slope-calculator
Slope Calculator
NAME
slope-calculator — Slope between two points as an exact fraction and a decimal, with the angle, grade, distance, midpoint and the line in slope-intercept and standard form.
SYNOPSIS
# What is a slope calculator?
A slope calculator works out the slope of the line through two points as the rise divided by the run, m = (y₂ − y₁) / (x₂ − x₁), and reports the line's equation, angle and grade alongside it.
WHY HERE
Maths, science and data tools for developers and analysts: SerpAPIs' technical audience.
Decimals are fine — they are read as exact fractions, so (0.1, 0.3) and (0.4, 0.7) gives a slope of 4/3 rather than 1.3333333333333335.
| x | y |
|---|---|
| -5 | -2 |
| -2 | 0 |
| 1 | 2 |
| 4 | 4 |
| 7 | 6 |
The slope, the fraction, the intercepts and the equations are exact. The angle, the grade and the decimal distance are rounded for display. A vertical line has an undefined slope, not a slope of 0 — and two identical points define no line at all.
// The slope, the fraction, the intercepts and the equations are exact. The angle, the grade and the decimal distance are rounded for display. A vertical line has an undefined slope, not a slope of zero, and two identical points define no line at all — the tool says so rather than printing a number.
USAGE
01 → Enter the first point
Type x₁ and y₁. Keep the pair together: swapping an x for a y is the mistake that quietly gives you the reciprocal of the right answer.
02 → Enter the second point
Type x₂ and y₂. The order of the two points does not matter — (y₂ − y₁) / (x₂ − x₁) gives the same slope either way, because both the top and the bottom flip sign.
03 → Read the slope as a fraction first
The fraction is the exact answer; the decimal is a rounding of it. A slope of 2/3 is 0.667 only to three places, and writing 0.67 into a later step is where marks get lost.
04 → Check for the two special cases
If x₁ = x₂ the line is vertical and the slope is undefined, not zero. If y₁ = y₂ the line is horizontal and the slope is exactly zero. Reporting one for the other is the single most common error on this topic.
05 → Use the equations, not just the number
Slope-intercept form y = mx + b is what you plot; standard form Ax + By = C with whole-number coefficients is what most homework asks you to hand in.
DESCRIPTION
Slope is rise over run: the change in y divided by the change in x. For two points that is m = (y₂ − y₁) / (x₂ − x₁). Subtract in the same order on the top and the bottom and the sign comes out right automatically; mix the order and you get the negative of the slope, which still looks like a plausible answer. This calculator does the subtraction in exact fractions, so (1, 2) and (4, 4) gives you 2/3 rather than 0.6666666666666666.
Two cases break the formula and they break it differently. A vertical line has x₁ = x₂, so the run is zero and the division is undefined — there is no number, and "0" is wrong. A horizontal line has y₁ = y₂, so the rise is zero and the slope is exactly 0, which is a perfectly good number. The tool names which case you are in rather than silently returning something.
The angle and the grade are two different ways of describing the same steepness, and they are not interchangeable. The angle of inclination is arctan(m) measured from the positive x-axis, so a slope of 1 is 45°. The grade on a road or ramp sign is the slope written as a percentage, so a slope of 0.08 is an 8% grade — which is only 4.6°. If a ramp specification says 1:12, that is a run of 12 for a rise of 1, a slope of 1/12 and an 8.33% grade.
Once you have the slope, the rest of the line follows. The y-intercept is b = y₁ − m·x₁, which gives slope-intercept form y = mx + b. Multiplying out and clearing the denominators gives standard form Ax + By = C with whole numbers and A ≥ 0. A parallel line has the same slope; a perpendicular line has the negative reciprocal, so a slope of 3/4 is perpendicular to −4/3. The one exception is a horizontal line, whose perpendicular is vertical and therefore has no slope at all.
FAQ
## How is the slope calculated?
m = (y₂ − y₁) / (x₂ − x₁) — the change in y divided by the change in x. This tool does that subtraction and division in exact fractions and then reduces the result to lowest terms, so you get 3/4 rather than 0.75 unless you want the decimal.
## What is the slope of a vertical line?
Undefined. A vertical line has the same x at both points, so the run is zero and you would be dividing by zero. It is not a slope of zero — that is a horizontal line. A vertical line is written x = 3 and has no slope-intercept form, because it is not a function of x.
## Is slope the same thing as the angle?
No. The slope is a ratio; the angle of inclination is arctan of that ratio. A slope of 1 is a 45° angle, but a slope of 2 is 63.4°, not 90°. The percentage grade you see on road signs is the slope times 100, which is also not the angle: an 8% grade is 4.57°.
## Does it matter which point I call the first one?
No, as long as you are consistent. Swapping both points negates the rise and the run, and the two minus signs cancel. What does change the answer is subtracting y in one order and x in the other — that gives you the negative of the true slope.
## How do I get the equation of the line from two points?
Find the slope first, then put one point into point-slope form y − y₁ = m(x − x₁) and rearrange. This calculator shows point-slope, slope-intercept y = mx + b and standard form Ax + By = C for the points you entered, with whole-number coefficients in the standard form.