## Using the Slope Formula to Find the Slope between Two Points

### Learning Outcomes

• Use the slope formula to find the slope of a line between two points
• Find the slope of horizontal and vertical lines

Sometimes we need to find the slope of a line between two points and we might not have a graph to count out the rise and the run. We could plot the points on grid paper, then count out the rise and the run, but there is a way to find the slope without graphing.

Before we get to it, we need to introduce some new algebraic notation. We have seen that an ordered pair $\left(x,y\right)$ gives the coordinates of a point. But when we work with slopes, we use two points. How can the same symbol $\left(x,y\right)$ be used to represent two different points?

Mathematicians use subscripts to distinguish between the points. A subscript is a small number written to the right of, and a little lower than, a variable.

We will use $\left({x}_{1},{y}_{1}\right)$ to identify the first point and $\left({x}_{2},{y}_{2}\right)$ to identify the second point. (If we had more than two points, we could use $\left({x}_{3},{y}_{3}\right),\left({x}_{4},{y}_{4}\right)$, and so on.)

## The Slope Formula

You’ve seen that you can find the slope of a line on a graph by measuring the rise and the run. You can also find the slope of a straight line without its graph if you know the coordinates of any two points on that line. Every point has a set of coordinates: an $x$-value and a $y$-value, written as an ordered pair $(x, y)$. The $x$ value tells you where a point is horizontally. The $y$ value tells you where the point is vertically.

Consider two points on a line—Point 1 and Point 2. Point 1 has coordinates $\left(x_{1},y_{1}\right)$ and Point 2 has coordinates $\left(x_{2},y_{2}\right)$.

The rise is the vertical distance between the two points, which is the difference between their  $y$-coordinates. That makes the rise $\left(y_{2}-y_{1}\right)$. The run between these two points is the difference in the $x$-coordinates, or $\left(x_{2}-x_{1}\right)$.

So, $\displaystyle \text{Slope}=\frac{\text{rise}}{\text{run}}$ or $\displaystyle m=\frac{{{y}_{2}}-{{y}_{1}}}{{{x}_{2}}-{{x}_{1}}}$.

To see how the rise and run relate to the coordinates of the two points, let’s take another look at the slope of the line between the points $\left(2,3\right)$ and $\left(7,6\right)$ below.

Since we have two points, we will use subscript notation.

$\stackrel{{x}_{1},{y}_{1}}{\left(2,3\right)}\stackrel{{x}_{2},{y}_{2}}{\left(7,6\right)}$

On the graph, we counted the rise of $3$. The rise can also be found by subtracting the $y\text{-coordinates}$ of the points.

$\begin{array}{c}{y}_{2}-{y}_{1}\\ 6 - 3\\ 3\end{array}$

We counted a run of $5$. The run can also be found by subtracting the $x\text{-coordinates}$.

$\begin{array}{c}{x}_{2}-{x}_{1}\\ 7 - 2\\ 5\end{array}$

 We know $m={\Large\frac{\text{rise}}{\text{run}}}$ So $m={\Large\frac{3}{5}}$ We rewrite the rise and run by putting in the coordinates. $m={\Large\frac{6 - 3}{7 - 2}}$ But $6$ is the $y$ -coordinate of the second point, ${y}_{2}$ and $3$ is the $y$ -coordinate of the first point ${y}_{1}$ . So we can rewrite the rise using subscript notation. $m={\Large\frac{{y}_{2}-{y}_{1}}{7 - 2}}$ Also $7$ is the $x$ -coordinate of the second point, ${x}_{2}$ and $2$ is the $x$ -coordinate of the first point ${x}_{2}$ . So we rewrite the run using subscript notation. $m={\Large\frac{{y}_{2}-{y}_{1}}{{x}_{2}-{x}_{1}}}$

We’ve shown that $m={\Large\frac{{y}_{2}-{y}_{1}}{{x}_{2}-{x}_{1}}}$ is really another version of $m={\Large\frac{\text{rise}}{\text{run}}}$. We can use this formula to find the slope of a line when we have two points on the line.

### Slope Formula

The slope of the line between two points $\left({x}_{1},{y}_{1}\right)$ and $\left({x}_{2},{y}_{2}\right)$ is

$m={\Large\frac{{y}_{2}-{y}_{1}}{{x}_{2}-{x}_{1}}}$

$\text{Slope is }y\text{ of the second point minus }y\text{ of the first point}$
$\text{over}$
$x\text{ of the second point minus }x\text{ of the first point.}$

### example

Find the slope of the line between the points $\left(1,2\right)$ and $\left(4,5\right)$.

Solution

 We’ll call $\left(1,2\right)$ point #1 and $\left(4,5\right)$ point #2. $\stackrel{{x}_{1},{y}_{1}}{\left(1,2\right)}\text{and}\stackrel{{x}_{2},{y}_{2}}{\left(4,5\right)}$ Use the slope formula. $m={\Large\frac{{y}_{2}-{y}_{1}}{{x}_{2}-{x}_{1}}}$ Substitute the values in the slope formula: $y$ of the second point minus $y$ of the first point $m={\Large\frac{5 - 2}{{x}_{2}-{x}_{1}}}$ $x$ of the second point minus $x$ of the first point $m={\Large\frac{5 - 2}{4 - 1}}$ Simplify the numerator and the denominator. $m={\Large\frac{3}{3}}$ $m=1$

Let’s confirm this by counting out the slope on the graph.

The rise is $3$ and the run is $3$, so
$\begin{array}{}\\ m=\frac{\text{rise}}{\text{run}}\hfill \\ m={\Large\frac{3}{3}}\hfill \\ m=1\hfill \end{array}$

It is important to remember that the slope is the same no matter which order we select the points.  Previously, whenever we found the slope by looking at the graph, we always selected our points from left to right so that our run was always a positive value.  Now, let’s take a look at an example in which we select our points from right to left.

The point $(0,2)$ is indicated as Point 1, and $(−2,6)$ as Point 2. So you are going to move from Point 1 to Point 2. A triangle is drawn in above the line to help illustrate the rise and run.

You can see from the graph that the rise going from Point 1 to Point 2 is $4$, because you are moving $4$ units in a positive direction (up). The run is $−2$, because you are then moving in a negative direction (left) $2$ units (think of it like running backwards!). Using the slope formula,

$\displaystyle \text{Slope}=\frac{\text{rise}}{\text{run}}=\frac{4}{-2}=-2$.

You do not need the graph to find the slope. You can just use the coordinates, keeping careful track of which is Point 1 and which is Point 2. Let’s organize the information about the two points:

Name Ordered Pair Coordinates
Point 1 $(0,2)$ $\begin{array}{l}x_{1}=0\\y_{1}=2\end{array}$
Point 2 $(−2,6)$ $\begin{array}{l}x_{2}=-2\\y_{2}=6\end{array}$

The slope, $m=\frac{y_{2}-y_{1}}{x_{2}-x_{1}}=\frac{6-2}{-2-0}=\frac{4}{-2}=-2$. The slope of the line, m, is $−2$.

Remember, it doesn’t matter which point is designated as Point 1 and which is Point 2. You could have called $(−2,6)$ Point 1, and $(0,2)$ Point 2. In that case, putting the coordinates into the slope formula produces the equation $m=\frac{2-6}{0-\left(-2\right)}=\frac{-4}{2}=-2$. Once again, the slope is $m=-2$. That’s the same slope as before. The important thing is to be consistent when you subtract: you must always subtract in the same order $\left(y_{2}-y_{1}\right)$ and $\left(x_{2}-x_{1}\right)$.

### example

Find the slope of the line through the points $\left(-2,-3\right)$ and $\left(-7,4\right)$.

### Example

What is the slope of the line that contains the points $(4,2)$ and $(5,5)$?

The example below shows the solution when you reverse the order of the points, calling $(5,5)$ Point 1 and $(4,2)$ Point 2.

### Example

What is the slope of the line that contains the points $(5,5)$ and $(4,2)$?

Notice that regardless of which ordered pair is named Point 1 and which is named Point 2, the slope is still $3$.

What is the slope of the line that contains the points $(3,-6.25)$ and $(-1,8.5)$?

Watch these videos to see more examples of how to determine slope given two points on a line.

## Finding the Slopes of Horizontal and Vertical Lines

Now, let’s revisit horizontal and vertical lines.  So far in this section, we have considered lines that run “uphill” or “downhill.” Their slopes are always positive or negative numbers. But what about horizontal and vertical lines? Can we still use the slope formula to calculate their slopes?

Consider the line above.  We learned in the previous section that because it is horizontal, its slope is $0$. You can also use the slope formula with two points on this horizontal line to calculate the slope of this horizontal line. Using $(−3,3)$ as Point 1 and (2, 3) as Point 2, you get:

$\displaystyle \begin{array}{l}m=\frac{{{y}_{2}}-{{y}_{1}}}{{{x}_{2}}-{{x}_{1}}}\\\\m=\frac{3-3}{2-\left(-3\right)}=\frac{0}{5}=0\end{array}$

The slope of this horizontal line is $0$.

Let’s consider any horizontal line. No matter which two points you choose on the line, they will always have the same y-coordinate. So, when you apply the slope formula, the numerator will always be $0$. Zero divided by any non-zero number is $0$, so the slope of any horizontal line is always $0$.

The equation for the horizontal line $y=3$ is telling you that no matter which two points you choose on this line, the y-coordinate will always be $3$.

How about vertical lines? In their case, no matter which two points you choose, they will always have the same x-coordinate. The equation for this line is $x=2$.

So, what happens when you use the slope formula with two points on this vertical line to calculate the slope? Using $(2,1)$ as Point 1 and $(2,3)$ as Point 2, you get:

$\displaystyle \begin{array}{l}m=\frac{{{y}_{2}}-{{y}_{1}}}{{{x}_{2}}-{{x}_{1}}}\\\\m=\frac{3-1}{2-2}=\frac{2}{0}\end{array}$

But division by zero has no meaning for the set of real numbers. Because of this fact, it is said that the slope of this vertical line is undefined. This is true for all vertical lines—they all have a slope that is undefined.

### Example

What is the slope of the line that contains the points $(3,2)$ and $(−8,2)$?

## Contribute!

Did you have an idea for improving this content? We’d love your input.