How to use the slope calculator
- Enter the X and Y coordinates of your first point (X₁, Y₁).
- Enter the X and Y coordinates of your second point (X₂, Y₂).
- Read the slope (m), which is the rise divided by the run.
- Check the distance, angle and line equation that update automatically.
How the slope is calculated
The slope of a line measures its steepness and direction. It is defined as the change in the vertical axis (rise) divided by the change in the horizontal axis (run). The formula is:
m = (Y₂ - Y₁) / (X₂ - X₁)
For example, if your two points are (1, 2) and (4, 6), the calculation is (6 - 2) / (4 - 1) = 4 / 3, which gives a slope of approximately 1.333. A positive slope means the line rises from left to right, while a negative slope means it falls.
How to find slope from two points: step by step
To find the slope of a line through two points, subtract the y-values to get the rise, subtract the x-values to get the run, and divide rise by run. Use the same point first in both subtractions.
Example 1, positive slope: points (2, 3) and (6, 11). Rise = 11 - 3 = 8, run = 6 - 2 = 4, so m = 8 / 4 = 2. The line goes up 2 for every 1 step right.
Example 2, negative slope: points (1, 5) and (4, 2). Rise = 2 - 5 = -3, run = 4 - 1 = 3, so m = -3 / 3 = -1. The line falls 1 for every 1 step right. The same result comes from (17, 18) and (18, 17).
Example 3, a fraction: points (1, 3) and (9, 6). Rise = 3, run = 8, so m = 3/8 = 0.375, which is the decimal this calculator shows. The y-intercept is b = 3 - 0.375 x 1 = 2.625, so y = 0.375x + 2.625.
Finding the line equation
Once you have the slope, this slope calculator builds the equation of the line using the slope-intercept form: y = mx + b. The y-intercept (b) is found by rearranging the formula to b = Y₁ - m × X₁.
Using the same points (1, 2) and (4, 6) with a slope of 4/3: b = 2 - (4/3 × 1) = 2/3. So the full equation is y = 1.333x + 0.667. If the line is perfectly vertical, the slope is undefined and the equation takes the form x = c instead.
Slope-intercept form and point-slope form
Slope-intercept form is y = mx + b, where m is the slope and b is the y-value where the line crosses the y-axis. This is the equation the calculator returns. To use it by hand, find m, then solve b = y1 - m x x1 with either point.
Point-slope form is y - y1 = m(x - x1). It needs only the slope and one point. For the points (2, 3) and (6, 11), m = 2, so the point-slope form is y - 3 = 2(x - 2). Expanding gives y = 2x - 4 + 3 = 2x - 1, which matches slope-intercept form with b = -1.
To work from an equation instead of points, use the slope intercept form calculator. For a line written as Ax + By = C, the slope is -A / B.
Distance and angle of inclination
The straight-line distance between two points uses the Pythagorean theorem: d = √((X₂ - X₁)² + (Y₂ - Y₁)²). For points (1, 2) and (4, 6), the differences are 3 and 4, so the distance is √(9 + 16) = √25 = 5.
The angle of inclination is the angle the line makes with the positive x-axis, measured counterclockwise. It is computed as θ = arctan(m) and converted from radians to degrees. A horizontal line has an angle of 0 degrees, and a line rising at a 45-degree angle has a slope of exactly 1.
Slope as a percent grade or an angle
Slope and percent grade differ only by a factor of 100: grade = slope x 100. A slope of 0.0833 (1 rise per 12 run, the 1:12 ramp ratio) is a grade of 8.33%, and its angle is arctan(1/12), about 4.76 degrees. A slope of 1 is a 100% grade and 45 degrees.
Common slope values reference
This table shows how different slopes translate to angles and line behavior. Use it to quickly check your results from the slope calculator.
| Slope (m) | Angle (degrees) | Line direction |
|---|---|---|
| 0 | 0 | Horizontal |
| 0.5 | 26.565 | Gentle rise |
| 1 | 45 | Equal rise and run |
| 2 | 63.435 | Steep rise |
| Undefined | 90 | Vertical |
| -1 | -45 (or 135) | Equal fall |
Positive, negative, zero and undefined slope
The sign of the slope tells you the direction of the line when you read it from left to right.
| Slope | What the line does | Example points | Equation |
|---|---|---|---|
| Positive (m > 0) | Rises | (2, 3) and (6, 11), m = 2 | y = 2x - 1 |
| Negative (m < 0) | Falls | (1, 5) and (4, 2), m = -1 | y = -x + 6 |
| Zero (m = 0) | Horizontal | (2, 4) and (7, 4), m = 0 | y = 4 |
| Undefined | Vertical | (3, 1) and (3, 8), run = 0 | x = 3 |
A horizontal line has rise 0, so its slope is 0. A vertical line has run 0, and dividing by zero is not defined, so its slope is undefined and the equation is x = a constant.
Practical uses for finding the slope
Calculating the gradient between two points is common in many fields. In construction and civil engineering, the slope determines drainage gradients, roof pitches and ramp accessibility. A wheelchair ramp, for instance, often requires a maximum slope of 1:12, meaning one unit of rise for every twelve units of run.
In finance and data analysis, the slope of a trend line represents the rate of change. If you plot revenue over time, the slope tells you how fast revenue is growing per period. In physics, the slope of a position-time graph gives velocity, and the slope of a velocity-time graph gives acceleration. For more complex linear algebra tasks, you might also use a linear equation solver or a matrix calculator.
Edge cases and common mistakes
The most frequent error when computing a slope manually is mixing up the order of subtraction. You must subtract the first point's coordinates from the second point's coordinates consistently in both the numerator and denominator. Swapping the order for only one axis will flip the sign of the result.
Another edge case is a vertical line where X₁ = X₂. Because the run is zero, dividing by zero makes the slope mathematically undefined. This slope calculator detects that condition and reports the line equation as x = X₁ rather than attempting an invalid division. Similarly, if both points are identical, there is no unique line, and the tool will flag the input as invalid.
Worked examples
| Example | Input | Result |
|---|---|---|
| Simple positive slope | X₁ (first point): 0; Y₁ (first point): 0; X₂ (second point): 3; Y₂ (second point): 6 | Slope (m): 2; Distance: 6.7082039325; Angle: 63.4349488229°; Equation: y = 2x |
| Negative slope | X₁ (first point): -2; Y₁ (first point): 5; X₂ (second point): 3; Y₂ (second point): -5 | Slope (m): -2; Distance: 11.1803398875; Angle: -63.4349488229°; Equation: y = -2x + 1 |
| Horizontal line | X₁ (first point): 1; Y₁ (first point): 4; X₂ (second point): 7; Y₂ (second point): 4 | Slope (m): 0; Distance: 6; Angle: 0°; Equation: y = 4 |
| Decimal coordinates | X₁ (first point): 1.5; Y₁ (first point): 2.5; X₂ (second point): 3.5; Y₂ (second point): 7.5 | Slope (m): 2.5; Distance: 5.38516480713; Angle: 68.1985905136°; Equation: y = 2.5x - 1.25 |
FAQ
What is the formula for slope?
The formula is m = (Y₂ - Y₁) / (X₂ - X₁). You subtract the y-coordinates to find the rise, subtract the x-coordinates to find the run, and divide the rise by the run.
What does an undefined slope mean?
An undefined slope occurs when the two points share the same x-coordinate, creating a perfectly vertical line. Because the horizontal change is zero, the division is undefined.
Can the slope be negative?
Yes. A negative slope means the line descends from left to right. The y-values decrease as the x-values increase.
How do I find the y-intercept from two points?
First calculate the slope m. Then substitute one of your points into the equation b = Y₁ - m × X₁ to solve for the y-intercept b.
Does this slope calculator store my coordinates?
No. All calculations happen locally in your browser. Your coordinates are never sent to any server.
What is the difference between slope and gradient?
In basic two-dimensional geometry, slope and gradient refer to the same concept: the ratio of vertical change to horizontal change. In multivariable calculus, a gradient is a vector of partial derivatives.
How do I find the slope of a line from two points?
Divide the change in y by the change in x: m = (y2 - y1) / (x2 - x1). For (2, 3) and (6, 11) that is (11 - 3) / (6 - 2) = 8 / 4 = 2.
What is the slope of a horizontal line?
Zero. Every point has the same y-value, so the rise is 0 and 0 divided by any run is 0. The equation has the form y = constant.
What is the point-slope formula?
It is y - y1 = m(x - x1), where m is the slope and (x1, y1) is a point on the line. Expand it and solve for y to get slope-intercept form y = mx + b.
How do I find the slope from an equation?
Rearrange it into y = mx + b and read m. For 3x + 2y = 6, solve for y: y = -1.5x + 3, so the slope is -1.5, which equals -A / B = -3 / 2.
How do I convert slope to percent grade?
Multiply the slope by 100. A slope of 0.08 is an 8% grade, and a slope of 1/12 is about 8.33%.