Finding the slope between two points of a line

The slope of a line is commonly defined as rise over run. This reminds me of stairs on a staircase. The stairs are all built with a specific height (rise) and length (run), and the stairs help you to go from one point to another point on the staircase (the line). (More on this in a later section.) A line is comprised of infinitely many points, but we need only two points on the line to find the slope.

For any two points on a line, with coordinates $$(x_1,\, y_1)$$ and $$(x_2,\, y_2)$$ the formula for the slope, $$m$$, of the line is:


 * $$m = \frac{\text{rise}}{\text{run}} = \frac{y_2 - y_1}{x_2 - x_1}$$

Note that rise is the difference between the two y values of the points, and run is the difference between the two x values of the points.

Calculating the slope
To calculate the slope of a line, the first step is to identify two points on the line. Let's try some examples, given two specified points.

Example 1:
On the graph at right, two points are labeled on the green line:
 * $$(2,\, 6)$$, which we'll label as point 1, corresponding to $$(x_1,\, y_1)$$,
 * $$(3,\, 9)$$, which we'll label as point 2, corresponding to $$(x_2,\, y_2)$$.

The slope of the line is:

$$m = \frac{y_2 - y_1}{x_2 - x_1} = \frac{9 - 6}{3-2} = \frac{3}{1} = 3$$

Example 2:
On the graph at right, two points are labeled on the blue line:
 * $$(-1,\, 6)$$, which we'll label as point 1, corresponding to $$(x_1,\, y_1)$$,
 * $$(1,\, 2)$$, which we'll label as point 2, corresponding to $$(x_2,\, y_2)$$.

The slope of the line is:

$$m = \frac{y_2 - y_1}{x_2 - x_1} = \frac{2 - 6}{1 - (-1)} = \frac{2 - 6}{1 + 1} = \frac{-4}{2} = -2$$

Example 3:
On the graph at right, two points are labeled on the blue line:
 * $$(-5,\, 8)$$, which we'll label as point 1, corresponding to $$(x_1,\, y_1)$$,
 * $$(3,\, 8)$$, which we'll label as point 2, corresponding to $$(x_2,\, y_2)$$.

The slope of the line is:

$$m = \frac{y_2 - y_1}{x_2 - x_1} = \frac{8 - 8}{3 - (-5)} = \frac{0}{3 + 5} = \frac{0}{8} = 0$$

Example 4:
On the graph at right, two points are labeled on the blue line:
 * $$(-3,\, -2)$$, which we'll label as point 1, corresponding to $$(x_1,\, y_1)$$,
 * $$(-3,\, 4)$$, which we'll label as point 2, corresponding to $$(x_2,\, y_2)$$.

The slope of the line is:

$$m = \frac{y_2 - y_1}{x_2 - x_1} = \frac{4 - (-2)}{-3 - (-3)} = \frac{4 + 2}{-3 + 3} = \frac{6}{0}$$

The slope, $$m$$, is undefined. This is because we cannot divide by 0. For example, there is no number that we can multiply 0 by to get 6.