Skip to content
CalcTide logo
Education & Math

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.

Education & MathBy

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

  1. 1Enter the x and y coordinates of the first point (x1, y1).
  2. 2Enter the x and y coordinates of the second point (x2, y2).
  3. 3Click Calculate to get the slope, rise, run, angle, y-intercept, and line equation.
  4. 4Check the signs of rise and run. Reversing both points reverses both signs but leaves their ratio, the slope, unchanged.
  5. 5For a vertical result, use the x = constant equation and N/A intercept rather than trying to use y = mx + b.
  6. 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)

X11
Y12
X24
Y28
Result2

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)

X10
Y14
X22
Y20
Result-2

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

X10
Y15
X24
Y25
ResultSlope 0, equation y = 0x + 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

X12
Y13
X22
Y29
ResultUndefined, equation 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

X10
Y14
X22
Y20
ResultSlope -2, equation y = -2x + 4

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 1Point 2Slope
(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.

Try the Distance Formula Calculator

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/.

Frequently Asked Questions

The slope formula is m = (y2 - y1) / (x2 - x1). It gives the steepness of a line between two points by dividing the vertical change (the rise) by the horizontal change (the run).
Divide the rise by the run. Subtract the y values to get the rise (y2 - y1) and subtract the x values to get the run (x2 - x1), then divide the rise by the run. For example, from (1, 2) to (4, 8) the rise is 6 and the run is 3, so the slope is 2.
The slope between (1, 2) and (4, 8) is 2. The rise is 8 - 2 = 6 and the run is 4 - 1 = 3, so the slope is 6 / 3 = 2.
The slope of a vertical line is undefined. The run (x2 - x1) is zero for a vertical line, and dividing by zero is not allowed, so the slope cannot be calculated and the line is written as x = constant.
A zero slope means the line is horizontal. The rise (y2 - y1) is zero because both points share the same y value, so dividing zero by the run gives a slope of 0.
A negative slope means the line falls from left to right. As the x value increases the y value decreases, so the rise is negative while the run is positive, which makes the slope a negative number.
The calculator displays y = 0x + b, where b is the shared y coordinate. For points (0, 5) and (4, 5), it shows y = 0x + 5.
No. Switching points reverses both rise and run, so their ratio stays the same. The displayed rise and run signs do change.
For a nonvertical line, it uses b = y1 - mx1. The calculator then displays the equation as y = mx + b with the appropriate plus or minus sign.
The implementation reports the vertical branch because the run is zero, but one point does not define a unique line. Enter two distinct points for a meaningful slope and equation.
It converts arctangent of the slope from radians to degrees and rounds to 2 decimal places. A vertical line is assigned 90 degrees.
It estimates slope calculator outputs using the visible inputs and formula assumptions on this page.

Explore More in Education & Math