Enter two points (x1, y1) and (x2, y2) to find the slope of the line through them.
Slope is rise over run: m = (y2 - y1) / (x2 - x1). Subtract the y values to get the rise, subtract the x values to get the run, then divide. Once you have m, the y-intercept is b = y1 - m x x1, which gives the line equation y = mx + b. A positive slope rises left to right, a negative slope falls, a slope of 0 is a flat horizontal line, and when x1 = x2 the line is vertical and the slope is undefined.
| Point 1 | Point 2 | Slope | Line |
|---|---|---|---|
| (1, 2) | (4, 8) | 2 | y = 2x + 0 |
| (0, 0) | (5, 10) | 2 | y = 2x + 0 |
| (-2, 3) | (4, -3) | -1 | y = -1x + 1 |
| (2, 5) | (6, 5) | 0 | y = 0x + 5 |
| (3, 1) | (3, 7) | undefined | x = 3 |
m = (y2 - y1) / (x2 - x1), the change in y divided by the change in x between two points on the line.
Undefined, because the run (x2 - x1) is zero and you cannot divide by zero. A vertical line has the equation x = a number.
Zero. The rise is zero, so m = 0 and the equation is y = a number.
The angle with the x-axis is arctan(m). A slope of 1 is 45 degrees; a slope of 0.5 is about 26.57 degrees.
See also: midpoint calculator · distance between two points · pythagorean theorem calculator · quadratic equation solver · all tools