Slope Calculator
The slope between (1, 2) and (4, 8) is 2, with equation y = 2x + 0. This slope calculator uses two points to find rise, run, slope, line angle, y-intercept, and a slope-intercept equation. Slope is the signed vertical change divided by the signed horizontal change. Positive slope rises from left to right, negative slope falls, and zero slope is horizontal. When both x coordinates match, the run is zero and the slope is undefined, so the calculator reports a vertical equation such as x = 2 instead of y = mx + b. Numeric slope, rise, run, and intercept values use the implementation's display rounding.
Quick answer
The slope measures how steep a line is between two points.
What this tells you
- •The slope measures how steep a line is between two points.
- •It equals the rise (change in y) divided by the run (change in x).
- •A positive slope rises from left to right and a negative slope falls.
- •A horizontal line has slope 0 and an equation displayed like y = 0x + b, while a vertical line has undefined slope and equation x = constant.
- •The y-intercept is b = y1 - mx1 and marks where a nonvertical line crosses the y-axis.
- •The angle is arctangent of slope in degrees, rounded to 2 decimal places and reported from -90 to 90 degrees.
- •Slope, rise, run, and y-intercept are rounded to no more than 4 decimal places for display.
How to Use
- 1Enter the x and y coordinates of the first point (x1, y1).
- 2Enter the x and y coordinates of the second point (x2, y2).
- 3Click Calculate to get the slope, rise, run, angle, y-intercept, and line equation.
- 4Check the signs of rise and run. Reversing both points reverses both signs but leaves their ratio, the slope, unchanged.
- 5For a vertical result, use the x = constant equation and N/A intercept rather than trying to use y = mx + b.
- 6Treat the displayed equation as rounded when coordinates produce a repeating or long decimal slope.
How It Works
Formula
m = (y2 - y1) / (x2 - x1)The slope m is the rise divided by the run. The rise is the vertical change (y2 - y1) and the run is the horizontal change (x2 - x1). When the run is zero the line is vertical and the slope is undefined. When the rise is zero the line is horizontal and the slope is zero.
Calculation note: values are processed in the order shown above, using the current input units.
Worked Examples
Slope from (1, 2) to (4, 8)
The rise is 8 - 2 = 6 and the run is 4 - 1 = 3. Divide the rise by the run to get 6 / 3 = 2, so the slope is 2.
Slope from (0, 4) to (2, 0)
The rise is 0 - 4 = -4 and the run is 2 - 0 = 2. Divide the rise by the run to get -4 / 2 = -2, so the slope is -2 and the line falls from left to right.
Horizontal line through y = 5
The rise is 5 - 5 = 0 and the run is 4. Dividing 0 by 4 gives slope 0. The angle is 0 degrees and the y-intercept is 5.
Vertical line through x = 2
The rise is 6 but the run is 0. Division by zero is undefined, so the calculator reports a 90-degree angle, N/A y-intercept, and vertical equation x = 2.
Negative slope and positive intercept
The rise is -4 and the run is 2, giving slope -2. Since the first point lies on the y-axis at y = 4, the intercept is 4 and the line angle is about -63.43 degrees.
Example Slopes
Common point pairs and the slope of the line between them.
| Point 1 | Point 2 | Slope |
|---|---|---|
| (1, 2) | (4, 8) | 2 |
| (0, 0) | (5, 5) | 1 |
| (0, 5) | (4, 5) | 0 (horizontal) |
| (2, 3) | (2, 9) | Undefined (vertical) |
Reading slope, angle, and line equations
Rise and run depend on point order, but slope does not. From point 1 to point 2, rise is y2 - y1 and run is x2 - x1. Swapping the points changes both signs. Since a negative divided by a negative is positive, their ratio stays the same. This provides a useful check when two calculations use opposite directions.
The y-intercept form y = mx + b works only for nonvertical lines. After finding m, the calculator substitutes the first point into b = y1 - mx1. For the points (0, 4) and (2, 0), m = -2 and b = 4, giving y = -2x + 4. A vertical line cannot be represented by one y value for every x, so it uses x = constant.
Angle gives another description of direction. The calculator uses arctangent of the slope and returns a principal angle between -90 and 90 degrees. A positive slope has a positive angle, a negative slope has a negative angle, a horizontal line returns 0, and the vertical branch returns 90. It does not provide a full compass bearing from 0 to 360 degrees.
Rounded equations can differ slightly from the exact line. The implementation computes with the original coordinates, then rounds slope and intercept to 4 decimals for output and equation text. Substituting a distant x value into that rounded equation can magnify a small rounding difference, so retain exact fractions or more precision when a problem requires it.
Common mistakes
- Dividing the run by the rise instead of the rise by the run. Slope is the change in y divided by the change in x, so keep the y values on top.
- Calling a vertical line slope zero instead of undefined. A vertical line has a run of zero, so the slope is undefined, while a horizontal line has a rise of zero and a slope of zero.
- Sign errors with negative coordinates. When a coordinate is negative, subtracting it adds a positive value, so 2 - (-3) = 5, not -1.
- Assuming a negative rise always means negative slope. If rise and run are both negative, their ratio is positive.
- Using y = mx + b for a vertical line. Vertical lines need x = constant because their slope and y-intercept are undefined.
- Reading the angle as a compass direction. The output is the principal arctangent angle, not a bearing from north.
- Treating a rounded equation as exact. Repeating slopes and intercepts are shortened to 4 decimal places in the displayed equation.
Embed this calculator on your site
Drop this single line where you want the calculator to appear. It is responsive, mobile-friendly, resizes automatically, and is free to use with attribution.
<script src="https://calctide.com/embed.js" data-tool="slope-calculator" async></script>Preview the embed at /embed/slope-calculator/.