Slope Calculator

Find the slope (gradient) of a line from two points, with the slope type and the equation y = mx + b calculated automatically.

Last updated:

Was this calculator helpful?

★ ★ ★ ★ ★
Embed this calculator

Calculation Examples

Calculation Case Result
Points (1, 2) and (3, 6) m = (6 - 2) ÷ (3 - 1) = 4 ÷ 2 = 2 (positive slope) | Line: y = 2x
Points (-1, 5) and (2, -1) m = (-1 - 5) ÷ (2 - (-1)) = -6 ÷ 3 = -2 (negative slope) | Line: y = -2x + 3
Points (2, 4) and (7, 4) m = (4 - 4) ÷ (7 - 2) = 0 ÷ 5 = 0 (zero slope, horizontal line) | Line: y = 4
Points (3, 1) and (3, 5) m = (5 - 1) ÷ (3 - 3) = 4 ÷ 0 (undefined slope, vertical line) | Line: x = 3
Mihail Doncenco
Mihail Doncenco Site Creator & Calculator Expert

Founder and developer of CalcMate. Builds and maintains every calculator on this site, focusing on formula accuracy and clear, practical results.

How to Use the Slope Calculator

Enter the coordinates of two points, \((x_1, y_1)\) and \((x_2, y_2)\). The calculator applies the slope formula: \[ m = \dfrac{y_2 - y_1}{x_2 - x_1} = \dfrac{\Delta y}{\Delta x} \] It returns the slope \(m\), the slope type (positive, negative, zero, or undefined), and the slope-intercept equation \(y = mx + b\) of the line through both points. The \(y\)-intercept comes from \(b = y_1 - m x_1\). Example: for (1, 2) and (3, 6), \(m = \dfrac{6 - 2}{3 - 1} = 2\) and \(b = 2 - 2 \times 1 = 0\), so \(y = 2x\).Slope formula: m equals y2 minus y1 divided by x2 minus x1, illustrating rise over run

The Four Types of Slope: Positive, Negative, Zero, and Undefined

Slope \(m\) measures both the steepness and the direction of a line on a Cartesian plane, often described as "rise over run" (\(\Delta y / \Delta x\)). A line has one of four slope types:

1. Positive slope \((m > 0)\): the line rises from left to right, and \(y\) grows by \(m\) units for every 1 unit of \(x\). Example: points (1, 2) and (3, 6) give \(m = \dfrac{6 - 2}{3 - 1} = 2\).

2. Negative slope \((m < 0)\): the line falls from left to right. Example: points (-1, 5) and (2, -1) give \(m = \dfrac{-1 - 5}{2 - (-1)} = \dfrac{-6}{3} = -2\).

3. Zero slope \((m = 0)\): the line is horizontal, because \(\Delta y = 0\) and all points share the same \(y\)-value. Example: points (2, 4) and (7, 4) give \(m = \dfrac{4 - 4}{7 - 2} = 0\).

4. Undefined slope: the line is vertical, because \(\Delta x = 0\) and division by zero is undefined. Example: points (3, 1) and (3, 5) give \(m = \dfrac{5 - 1}{3 - 3} = \dfrac{4}{0}\), which has no value.

Diagram showing all four slope types: positive, negative, zero, and undefined on a Cartesian plane

Useful Tips 💡

  • The order of the two points does not change the slope. Swapping them flips the sign of both the numerator and the denominator, so the ratio stays the same. Keep the same order in both parts of the fraction to avoid sign errors in manual checks.
  • Use slope to test whether three points lie on one line. Points (1, 2), (3, 6), and (5, 10) give a slope of 2 for both pairs, (6 - 2)/(3 - 1) and (10 - 6)/(5 - 3), so they are collinear.
  • To turn a percent grade into a slope, divide by 100. A 8% grade is m = 0.08. To get the angle, take the arctangent of the slope: a slope of 0.08 is about 4.6°.

📋Steps to Calculate

  1. Enter the coordinates of the first point: x1 and y1.

  2. Enter the coordinates of the second point: x2 and y2.

  3. Click "Calculate" to view the slope value m, its type, and the line equation y = mx + b.

Mistakes to Avoid ⚠️

  1. Subtracting coordinates in different orders. The formula needs the same point first in both parts: (y2 - y1) / (x2 - x1). Using (y2 - y1) / (x1 - x2) returns the negative of the correct slope.
  2. Mixing up zero slope and undefined slope. A horizontal line has zero slope (m = 0, because the vertical change is 0). A vertical line has undefined slope (the horizontal change is 0, so the division is impossible).
  3. Treating slope as an angle. Slope is the tangent of the angle with the positive x-axis. A slope of 1 is 45°, but a slope of 2 is about 63.4°, not 90°.
  4. Judging steepness by eye on charts with different axis scales. A slope of 10 can look gentler than a slope of 2 if the y-axis is compressed.

Practical Applications📊

  1. Roofing and drainage: a 4:12 roof pitch is a slope of 4/12 ≈ 0.333. The International Plumbing Code (Section 704.1) sets a typical minimum of 1/4 inch per foot for small horizontal drain pipes, which is a slope of about 0.0208.

  2. Ramps and roads: the ADA 2010 Standards (Section 405.2) cap the running slope of an accessible ramp at 1:12, or 8.33%. A 6% road grade means a slope of 0.06, which is 6 m of rise per 100 m of horizontal distance.

  3. Physics and data analysis: on a position-time graph, slope is velocity. A car moving from 20 m to 80 m in 4 s has a slope of 60/4 = 15 m/s. In linear regression, a slope of 2.5 points per hour of study means each extra hour adds 2.5 points to the predicted score.

  4. Geometry: parallel lines share the same slope, and perpendicular lines have slopes whose product is -1. A line with slope 3 is perpendicular to a line with slope -1/3.

Questions and Answers

How are slopes of parallel and perpendicular lines related?

Parallel lines have equal slopes, and perpendicular lines have slopes that are negative reciprocals. If \(m_1 = m_2\) and the \(y\)-intercepts differ, the lines never meet. For perpendicular lines, \(m_1 \times m_2 = -1\), so \(m_2 = -\dfrac{1}{m_1}\). Example: a line with \(m = 3\) is perpendicular to a line with \(m = -\dfrac{1}{3}\). A horizontal and a vertical line are also perpendicular, but they are a special case with slopes 0 and undefined.

How do you calculate slope from two points?

To calculate slope from two points, subtract the \(y\)-coordinates and divide by the difference of the \(x\)-coordinates, in the same order: \(m = \dfrac{y_2 - y_1}{x_2 - x_1}\). Example: for (-1, 5) and (2, -1), \(m = \dfrac{-1 - 5}{2 - (-1)} = \dfrac{-6}{3} = -2\). Swapping the two points reverses both the numerator and the denominator, so the result is the same.

What is slope and how is it defined mathematically?

Slope is the ratio of vertical change to horizontal change between two points on a line: \(m = \dfrac{y_2 - y_1}{x_2 - x_1} = \dfrac{\Delta y}{\Delta x}\). A positive value means the line rises from left to right, a negative value means it falls, and a larger absolute value means a steeper line. Slope is a core idea of coordinate geometry and generalizes to the derivative in calculus. On a straight line it is constant: any two points give the same ratio.

What is the difference between zero slope and undefined slope?

A horizontal line has zero slope, while a vertical line has undefined slope. On a horizontal line \(\Delta y = 0\) and \(\Delta x \neq 0\), so \(m = \dfrac{0}{\Delta x} = 0\) and the equation is \(y = c\). On a vertical line \(\Delta x = 0\) and \(\Delta y \neq 0\), so the denominator is zero, no real value of \(m\) exists, and the equation is \(x = c\). People confuse them because both lines hold one coordinate constant, but they are different cases.

What is the relationship between slope and the angle of inclination?

The slope equals the tangent of the angle \(\theta\) between the line and the positive \(x\)-axis: \(m = \tan(\theta)\), with \(0^\circ \leq \theta < 180^\circ\). A slope of 1 gives \(\theta = 45^\circ\), a slope of 0 gives \(0^\circ\), and a slope of -1 gives \(135^\circ\). For \(m = 2\), \(\theta = \arctan(2) \approx 63.4^\circ\). Doubling the slope does not double the angle, because the tangent function is not linear. As the slope grows without bound, the angle approaches \(90^\circ\), the vertical line.

What is the relationship between slope and the line equation y = mx + b?

In the slope-intercept form \(y = mx + b\), \(m\) is the slope and \(b\) is the \(y\)-intercept, the value of \(y\) where the line crosses the \(y\)-axis (\(x = 0\)). Given the slope and one point \((x_1, y_1)\), the intercept is \(b = y_1 - m x_1\). For \(m = 2\) through the point (1, 2), \(b = 2 - 2 \times 1 = 0\), so \(y = 2x\). Vertical lines cannot be written in this form, because their slope is undefined.

Which formula does the slope calculator use?

The calculator uses the standard coordinate geometry formula \(m = \dfrac{y_2 - y_1}{x_2 - x_1}\). When \(x_2 - x_1 = 0\), it returns "undefined" for a vertical line instead of a number. It then finds the intercept with \(b = y_1 - m x_1\) and reports the slope type. If both points are identical, \((x_1, y_1) = (x_2, y_2)\), infinitely many lines pass through that single point and the slope cannot be determined, so the calculator flags the input as invalid.
Disclaimer: This calculator is designed to provide helpful estimates for informational purposes. While we strive for accuracy, financial (or medical) results can vary based on local laws and individual circumstances. We recommend consulting with a professional advisor for critical decisions.