Explainer: Calculating the Slope of a Line given Two Points

In this explainer, we will learn how to calculate the slope of a line given two points on it and determine whether the slope is positive, negative, zero, or undefined.

Key Information: The Slope of a Line

The general form of a straight line in the π‘₯𝑦-plane is 𝑦=π‘šπ‘₯+𝑏.

In this form, the slope (or gradient) of the line is represented by the coefficient π‘š and the 𝑦-axis intercept is represented by the constant 𝑏.

For this explainer, we will be focusing on the slope.

The equation of a straight line describes all points that lie on it. When given a set of two points on a line, (π‘₯1,𝑦1) and (π‘₯2,𝑦2), we can write out two equations using the given information: 𝑦1=π‘šπ‘₯1+𝑏,𝑦2=π‘šπ‘₯2+𝑏.

Let us illustrate how these two equations can be used to find π‘š. Our first step is to subtract 𝑦1 from 𝑦2: 𝑦2βˆ’π‘¦1=(π‘šπ‘₯2+𝑏)βˆ’(π‘šπ‘₯1+𝑏).

On the right-hand side of the new equation, our 𝑏 terms cancel out: 𝑦2βˆ’π‘¦1=π‘šπ‘₯2+π‘βˆ’π‘šπ‘₯1βˆ’π‘π‘¦2βˆ’π‘¦1=π‘šπ‘₯2βˆ’π‘šπ‘₯1.

We can now take out a factor of π‘š from the right-hand side of our equation, 𝑦2βˆ’π‘¦1=π‘š(π‘₯2βˆ’π‘₯1), and divide both sides by (π‘₯2βˆ’π‘₯1) to find π‘š, expressed in terms of the four known coordinates: π‘š=𝑦2βˆ’π‘¦1π‘₯2βˆ’π‘₯1.

This expression can be understood more intuitively when we realize the following: changein𝑦=(𝑦2βˆ’π‘¦1),changeinπ‘₯=(π‘₯2βˆ’π‘₯1).

We can therefore see that, for any straight line, dividing the change in 𝑦 by the change in π‘₯ over two points will give us the slope: π‘š=changein𝑦changeinπ‘₯.

Key Information: Determining the Slope of a Line given Two Points

When given two points, (π‘₯1,𝑦1) and (π‘₯2,𝑦2), that lie on a straight line, the slope of the line can be calculated using the following formula: π‘š=𝑦2βˆ’π‘¦1π‘₯2βˆ’π‘₯1.

To put this expression in words, π‘š=changein𝑦changeinπ‘₯.

It is worth noting that the order in which we label our two points from left to right is not important. Choosing the left-hand point as (π‘₯2,𝑦2) and the right-hand point as (π‘₯1,𝑦1) will still output the correct slope.

To further explore this, let us imagine a simple case where two points on a line are 1 unit apart in the π‘₯-direction. In this situation, the following is true: π‘₯2=π‘₯1+1π‘₯2βˆ’π‘₯1=1.

We can now substitute this into the formula for the slope of a line, which gives π‘š=𝑦2βˆ’π‘¦11.

In this simple case, we can see that the formula for π‘š reduces to the following: π‘š=𝑦2βˆ’π‘¦1=changein𝑦.

The slope π‘š can therefore be understood as the change in the 𝑦-position when a point is moved 1 unit along the line in the positive π‘₯-direction (from left to right).

By thinking of the slope in this way, we can see that a larger π‘š will give rise to a larger change in 𝑦, and the line we observe can be considered β€œsteeper.”

When looking at the slopes of one or more lines, you may be asked to compare the β€œsteepness.”

In cases of both positive and negative values of π‘š, a line may be considered steep despite the differing directions of the incline.

In order to quantify the steepness, it will be useful to think of the absolute value of π‘š. Absolute value is denoted by two vertical lines. Absolutevalueofπ‘š=|π‘š|.

The absolute value of a number can be thought of as its distance from 0. Since distance is scalar, the absolute value of any negative number is positive and its numerical value is maintained.

The line with the steepest slope can therefore be found by identifying the largest absolute value of π‘š.

Finally, let us continue with our simple case where the following is true: π‘₯2βˆ’π‘₯1=1,π‘š=changein𝑦.

Since π‘š is equal to the change in 𝑦, we can see that a positive value of π‘š will correspond to an increase in 𝑦 and a negative value of π‘š will correspond to a decrease in 𝑦 (as we move in the positive π‘₯-direction).

In other words, the sign of π‘š tells us whether our line goes up or down as we move from left to right.

Let us summarize these two properties of π‘š.

Key Information: Understanding the Properties of a Slope

The absolute value of π‘š represents the steepness of the slope.

In general, line 1 (slope: π‘š1) is steeper than line 2 (slope: π‘š2) if |π‘š1|>|π‘š2|.

The sign of the π‘š denotes the direction of the incline as you move in the positive π‘₯-direction: π‘š>0;𝑦increasesasπ‘₯increases,π‘š<0;𝑦decreasesasπ‘₯increases.

We can now look at a few examples that use the slope formula to find π‘š of a line given at least two points that lie on the line.

Example 1: Finding the Slopes of Straight Lines

Determine the slope of the line that passes through the points 𝐴(2,βˆ’5) and 𝐡(4,5).

Answer

Taking point 𝐴 to be (π‘₯1,𝑦1) and point 𝐡 to be (π‘₯2,𝑦2), we can input the π‘₯ and 𝑦 coordinates into the formula for the slope of a line: π‘š=𝑦2βˆ’π‘¦1π‘₯2βˆ’π‘₯1.

Performing the substitution which gives the following equation: π‘š=5βˆ’(βˆ’5)4βˆ’2, we can then simplify our fraction to reach the solution: π‘š=5+54βˆ’2=102=5.

We have now found that the line has a slope of positive 5. In practical terms, this means that for every 1 unit we move to the right in the π‘₯-direction, the line will rise by 5 units in the 𝑦-direction.

Example 2: Finding the Slope of a Line Drawn in Coordinate Axes

Find the slope of the line shown.

Answer

The graph above shows two points marked on a straight line. One thing that we may notice is that the line shown in the diagram goes down as we move from left to right. This β€œvisual check” can immediately tell us that the slope of the line will be negative.

To find the slope, we can first determine the coordinates of the two points and then use the formula for the slope of a straight line. π‘š=𝑦2βˆ’π‘¦1π‘₯2βˆ’π‘₯1.

We can see that the first point lies at the coordinates (βˆ’5,1). Let us take this point to be (π‘₯1,𝑦1). The second point lies at the coordinates (βˆ’1,βˆ’4), and we can take this to be (π‘₯2,𝑦2).

We can input the π‘₯- and 𝑦-coordinates into the formula for the slope of a line to give us the following equation: π‘š=βˆ’4βˆ’1βˆ’1βˆ’(βˆ’5).

We can then simplify the right-hand side of our equation to solve for the slope, π‘š: π‘š=βˆ’5βˆ’1+5=βˆ’54.

Finally, we can note that the slope of the line is negative, and this agrees with our initial β€œvisual check” based on the diagram.

Example 3: Comparing the Slopes of Two Straight Lines given the Coordinates of Two Points Lying on Them

Line 1 passes through the points 𝐴(βˆ’6,17) and 𝐡(βˆ’18,βˆ’14). Line 2 passes through the points 𝐢(βˆ’2,0) and 𝐷(βˆ’9,20). Which of the two lines has a steeper slope?

Answer

We can first determine the slope of line 1 by taking point 𝐴 to be (π‘₯1,𝑦1) and point 𝐡 to be (π‘₯2,𝑦2). As with the previous example, we can input the π‘₯- and 𝑦-coordinates into the formula for the slope of a line: π‘š1=(βˆ’14)βˆ’17(βˆ’18)βˆ’(βˆ’6).

We can now simplify our fraction to find the slope of line 1, giving π‘š1=βˆ’14βˆ’17βˆ’18+6=βˆ’31βˆ’12=3112.

For this question, we will use an accuracy of three decimal places: π‘š1β‰ˆ2.583.

Let us now calculate the slope of line 2 using the same method and assigning point 𝐢 to be (π‘₯1,𝑦1) and point 𝐷 to be (π‘₯2,𝑦2): π‘š2=20βˆ’0(βˆ’9)βˆ’(βˆ’2).

Again, we can now simplify our fraction to find the slope of line 2, giving π‘š2=20βˆ’0βˆ’9+2=βˆ’207.

For consistency with π‘š1, we use an accuracy of three decimal places: π‘š2β‰ˆβˆ’2.587.

To find which line is steeper, we compare the absolute value of the two slopes: |2.583|<|βˆ’2.587||π‘š1|<|π‘š2|.

When comparing slopes, the number with the largest absolute value corresponds to a steeper slope. We can therefore say that line 2 is steeper than line 1.

The equation for the slope of a line can also be used to find information about coordinates that lie on the line. Let us look at a few examples of this.

Example 4: Determining the 𝑦-Coordinates for Two Points Lying on Two Parallel Lines

If the line passing through points 𝐴(βˆ’13,8) and 𝐡(20,𝑦) is parallel to the line passing through points 𝐢(βˆ’2,0) and 𝐷(7,𝑦), what is the value of 𝑦?

Answer

Let us say that line 1 passes through points 𝐴 and 𝐡 and has a slope π‘š1. Similarly, line 2 passes through points 𝐢 and 𝐷 and has a slope π‘š2. We can define our points as follows: 𝐴(βˆ’13,8)=(π‘₯1,𝑦1),𝐡(20,𝑦)=(π‘₯2,𝑦2),𝐢(βˆ’2,0)=(π‘₯3,𝑦3),𝐷(7,𝑦)=(π‘₯4,𝑦4).

We can recall that parallel lines always remain equidistant (and will therefore never meet). In the π‘₯𝑦-plane, this can only be true if the slopes of the lines are equal. Since the question tells us that line 1 and line 2 are parallel, we can conclude that π‘š1=π‘š2.

We can now substitute the coordinate values into our slope equation: 𝑦2βˆ’π‘¦1π‘₯2βˆ’π‘₯1=𝑦4βˆ’π‘¦3π‘₯4βˆ’π‘₯3π‘¦βˆ’820βˆ’(βˆ’13)=π‘¦βˆ’07βˆ’(βˆ’2).

Simplifying the fractions, we find the following: π‘¦βˆ’820+13=𝑦7+2π‘¦βˆ’833=𝑦9.

We can multiply both sides of our equation by the denominators 9 and 33, 9π‘¦βˆ’72=33𝑦, and collect the 𝑦-terms to solve: βˆ’72=24𝑦𝑦=βˆ’7224𝑦=βˆ’3.

To finish off, we know that 𝑦2 and 𝑦4 are equal to the 𝑦-value we have just found. We can therefore complete the information for points 𝐡 and 𝐷: 𝐡(20,βˆ’3),𝐷(7,βˆ’3).

Note: We now have a complete set of two coordinates. This information could be used to find the slopes of both lines. In this case, the question does not require us to find π‘š, but you may wish to complete this step in similar questions to check that π‘š1=π‘š2.

Example 5: Finding the 𝑦-Coordinate of a Point Lying on a Straight Line given the Slope and the Coordinates of Another Point on the Line

Given that the slope of a straight line passing through the points (9,βˆ’7) and (βˆ’3,π‘˜) is βˆ’512, find the value of π‘˜.

Answer

Let us substitute the known values into the equation for the slope of a straight line, taking our first point (9,βˆ’7) to be (π‘₯1,𝑦1) and our second point (βˆ’3,π‘˜) to be (π‘₯2,𝑦2).

We also substitute βˆ’512 as the given value for the slope: π‘š=𝑦2βˆ’π‘¦1π‘₯2βˆ’π‘₯1βˆ’512=π‘˜βˆ’(βˆ’7)(βˆ’3)βˆ’9.

We can then simplify the right-hand side of the equation and multiply both sides by βˆ’12: βˆ’512=π‘˜+7βˆ’12(βˆ’5)(βˆ’12)12=π‘˜+7.

In doing this, we find that the denominator of the left-hand side of our equation can be eliminated: 5=π‘˜+7.

This allows us to solve for π‘˜: π‘˜=5βˆ’7=βˆ’2

The coordinates of the second point given in the question are (βˆ’3,βˆ’2).

Finally, we can use our formula to determine the coordinates of a point on a line with a given slope.

Example 6: Determining the 𝑦-Coordinates of a Point on a Straight Line

What is the value of 𝑦 so that 𝐴(βˆ’9,6), 𝐡(3,βˆ’3), and 𝐢(βˆ’1,𝑦) are collinear?

Answer

First, we can recall that collinear points all lie on the same line. This means that the slope of line 𝐴𝐡 is the same as that of line 𝐡𝐢: π‘šπ΄π΅=π‘šπ΅πΆ.

We can determine the slope of line 𝐴𝐡 by using the formula for the slope of a line, taking 𝐴 to be (π‘₯1,𝑦1) and 𝐡 to be (π‘₯2,𝑦2): π‘šπ΄π΅=(βˆ’3)βˆ’63βˆ’(βˆ’9)π‘šπ΄π΅=βˆ’3βˆ’63+9.

We now simplify our fraction: π‘šπ΄π΅=βˆ’912π‘šπ΄π΅=βˆ’34.

Since we know that the slope of line 𝐡𝐢 is equal to the slope of line 𝐴𝐡, we also can say that π‘šπ΅πΆ=βˆ’34

Let us substitute the values for points 𝐡 and 𝐢 into our formula and solve for 𝑦: π‘¦βˆ’(βˆ’3)(βˆ’1)βˆ’3=βˆ’34𝑦+3βˆ’4=βˆ’34.

Multiplying both sides by βˆ’4 gives us our solution: 𝑦+3=3𝑦=0.

To finish, we can now write point 𝐢 in full, using the information we have found: 𝐢(βˆ’1,0).

Key Points

  1. The general form of a straight line in the π‘₯𝑦-plane is 𝑦=π‘šπ‘₯+𝑏.
  2. When given two points, (π‘₯1,𝑦1) and (π‘₯2,𝑦2), that lie on a straight line, the slope of the line can be calculated using the following formula: π‘š=𝑦2βˆ’π‘¦1π‘₯2βˆ’π‘₯1.
  3. The slope π‘š can be understood as the change in the 𝑦-position when a point is moved 1 unit along a line in the positive π‘₯-direction.
  4. The slope π‘š can be positive or negative. You can visually identify the sign of π‘š by checking whether the line goes up or down as you move from left to right.
  5. The absolute value of π‘š, denoted as |π‘š|, represents the steepness of the slope.
  6. In general, one slope is considered β€œsteeper” than another if it has a greater |π‘š|.

Nagwa uses cookies to ensure you get the best experience on our website. Learn more about our Privacy Policy.