Updated · Built and checked by the PlinzoTools team, formulas tested against published sources
Calculate the slope and equation of a line between two points.
The slope of a line measures how steep it is -- the ratio of vertical change to horizontal change between any two points on the line. This tool calculates both the slope and the full slope-intercept equation (y = mx + b).
Enter the coordinates of two points, (x1, y1) and (x2, y2). The slope and y-intercept appear instantly.
m = (y2 - y1) / (x2 - x1)
The y-intercept is then found by substituting either point into y = mx + b and solving for b.
The calculator returns two numbers: the slope (m) and the y-intercept (b). Together they define the line completely. The slope tells you the rate of change, meaning how many units y moves for every one unit x moves. The y-intercept tells you where the line crosses the vertical axis, which is the value of y when x equals zero. Both are shown to four decimal places, so a slope that looks like 0.3333 is really the fraction one-third.
If you need the equation in your homework or report, round sensibly and keep fractions exact where you can. A slope of 0.3333 is better written as 1/3, and an intercept of 2.5000 is simply 2.5.
Suppose a hypothetical hillside path passes through the points (2, 10) and (8, 4), where x is horizontal distance and y is height. Enter x1 = 2, y1 = 10, x2 = 8, y2 = 4.
m = (4 - 10) / (8 - 2) = -6 / 6 = -1
b = y1 - m × x1 = 10 - (-1)(2) = 12
Equation: y = -1x + 12, or y = 12 - x
The slope of -1 means the height drops one unit for every unit of horizontal distance, a 45-degree descent. The intercept of 12 says that if the line were extended back to x = 0, it would start at a height of 12. Check the answer by substituting the second point: 12 - 8 = 4, which matches y2.
Always attach units to the slope. If y is in dollars and x is in hours, the slope is dollars per hour. A bare number without units is easy to misread.
When y1 equals y2 the slope is zero and the equation is simply y = b, a horizontal line. When x1 equals x2 the line is vertical, the slope is undefined, and the tool cannot give a slope-intercept equation; a vertical line is written as x = a constant instead. Nearly vertical lines, where the x values differ only slightly, give very large slopes, so double-check your inputs for typing errors when a result looks extreme.
Slope shows up in road grade and roof pitch, in the gradient of a trend line, and as the first step toward parallel and perpendicular lines. Two lines are parallel when their slopes are equal, and perpendicular when their slopes multiply to -1 (the negative reciprocal). You can use the tool twice, once per line, and compare the two slopes to test this.
The line is perfectly horizontal -- y doesn't change as x changes.
The line is vertical, and slope is undefined (division by zero) -- a vertical line has no single y = mx + b form.
The line goes downward from left to right -- as x increases, y decreases.
The tool shows decimals to four places. If the slope is 0.3333, recognize it as 1/3 and write y = (1/3)x + b. Verify by substituting one of your points into the equation to make sure both sides match.
No. Swapping point 1 and point 2 flips both the top and bottom of the slope fraction, so the slope and intercept stay the same. It only matters that each point keeps its own x and y together.
Calculate the slope of each line separately. Equal slopes mean the lines are parallel. Slopes whose product is -1 mean they are perpendicular. A horizontal line (slope 0) is perpendicular to a vertical line, which has no defined slope.
You can, but the result only describes the straight line through your two chosen points. For scattered data with many points, a line of best fit from a regression tool gives a more representative slope.
Reference: NIST Weights and Measures