# What is the slope of a line?

Finds the slope of the line through two points, with its angle, distance, y-intercept and equation, or a missing coordinate from the slope.

- Page: https://www.acalculator.org/math/slope-calculator
- JSON spec: https://www.acalculator.org/math/slope-calculator.json
- Version: 45876901b81b

## Default answer

Example with the default inputs (x₁ 1, y₁ 2, x₂ 5, y₂ 8): The line through (1, 2) and (5, 8) has a slope of 1.5.

## Inputs

| Key | Label | Description |
| --- | --- | --- |
| x1 | x₁ | The x-coordinate of the first point. |
| y1 | y₁ | The y-coordinate of the first point. |
| x2 | x₂ | The x-coordinate of the second point. |
| y2 | y₂ | The y-coordinate of the second point. |
| m | Slope (m) | Rise over run: how much y changes for each 1 that x increases. |

## Outputs

| Key | Label | Description |
| --- | --- | --- |
| x1 | x₁ | The x-coordinate of the first point. |
| y1 | y₁ | The y-coordinate of the first point. |
| x2 | x₂ | The x-coordinate of the second point. |
| y2 | y₂ | The y-coordinate of the second point. |
| m | Slope (m) | Rise over run: how much y changes for each 1 that x increases. |
| equation | Equation of the line | The line through both points in slope-intercept form, y = mx + b. |
| intercept | y-intercept (b) | Where the line crosses the y-axis: b = y₁ − m × x₁. |
| angle | Angle of incline | The angle between the line and the x-axis: arctan m, from −90° to 90°. |
| grade | Grade | The slope as a percent: m × 100. |
| rise | Rise (Δy) | The change in y: y₂ − y₁. |
| run | Run (Δx) | The change in x: x₂ − x₁. |
| distance | Distance between the points | The length of the segment: √(Δx² + Δy²). |

## Method

m = (y₂ − y₁) ÷ (x₂ − x₁): the rise between two points divided by the run.

## Assumptions

- The two points must have different x-coordinates: a vertical line has no slope.
- The angle is arctan m, measured from the positive x-axis, between −90° and 90°.
- Coordinates are plain numbers from −10¹⁰⁰ to 10¹⁰⁰, in one unit; a coordinate worked out beyond that has no answer.

## Worked examples

1. x1 = 1, y1 = 2, x2 = 5, y2 = 8 gives m = 1.5, intercept = 0.5, equation = y = 1.5x + 0.5, angle = 0.982794, grade = 150%, rise = 6, run = 4, distance = 7.211103. Source: hand calculation in content.mdx: m = (8 − 2) ÷ (5 − 1) = 1.5; Python 3: math.atan(1.5) = 0.982793723247329, math.hypot(4, 6) = 7.211102550927978.
2. x1 = -2, y1 = 3, x2 = 4, y2 = -9 gives m = -2, intercept = -1, equation = y = -2x - 1, distance = 13.416408. Source: hand calculation in content.mdx: m = −12 ÷ 6 = −2, b = 3 − (−2)(−2) = −1; Python 3: math.hypot(6, 12) = 13.416407864998739.
3. x1 = 0, y1 = 4, x2 = 7, y2 = 4 gives m = 0, equation = y = 4, angle = 0, grade = 0%. Source: hand calculation in content.mdx: a horizontal line has rise 0, so m = 0.
4. x1 = 2, y1 = 1, x2 = 10, m = 0.75 gives y2 = 7, intercept = -0.5. Source: hand calculation in content.mdx: y₂ = 1 + 0.75 × (10 − 2) = 7.
5. x1 = 1, y1 = 1, y2 = 4, m = 1 gives x2 = 4, equation = y = x, angle = 0.785398. Source: hand calculation in content.mdx: x₂ = 1 + (4 − 1) ÷ 1 = 4; arctan 1 = 45°.

## FAQ

### How do I find the slope between two points?

Subtract the y-coordinates, subtract the x-coordinates in the same order, and divide: m = (y₂ − y₁) ÷ (x₂ − x₁). Through (1, 2) and (5, 8), the rise is 8 − 2 = 6 and the run is 5 − 1 = 4, so the slope is 6 ÷ 4 = 1.5.

### What does the slope tell me?

How steep the line is and which way it goes. A slope of 1.5 means y goes up 1.5 for every 1 that x goes right. A positive slope rises from left to right, a negative slope falls, and a slope of 0 is a flat, horizontal line.

### What is the slope of a vertical line?

It has none (it is undefined). On a vertical line the run x₂ − x₁ is 0, and you cannot divide by 0. Its equation is x = a number, such as x = 3, rather than y = mx + b.

### How do I get the equation of the line from two points?

Find the slope m, then the y-intercept b = y₁ − m × x₁, and write y = mx + b. Through (1, 2) and (5, 8): m = 1.5 and b = 2 − 1.5 × 1 = 0.5, so the line is y = 1.5x + 0.5.

### How do I turn a slope into an angle or a percent grade?

The angle is the arctangent of the slope: arctan 1.5 = 56.31°. The grade is the slope times 100: a slope of 0.08 is an 8% grade, as on road signs. A slope of 1 is a 45° angle and a 100% grade.

### Does it matter which point I call the first?

No. Swapping the points changes the sign of both the rise and the run, so their quotient, the slope, stays the same. Only keep the same order for x and y: (y₂ − y₁) ÷ (x₂ − x₁).

## Sources

- OpenStax, Elementary Algebra 2e, section 4.4 Understand Slope of a Line: https://openstax.org/books/elementary-algebra-2e/pages/4-4-understand-slope-of-a-line
- OpenStax, Elementary Algebra 2e, section 4.5 Use the Slope-Intercept Form of an Equation of a Line: https://openstax.org/books/elementary-algebra-2e/pages/4-5-use-the-slope-intercept-form-of-an-equation-of-a-line
