Skip to content

Find the Equation of a Line

By the end of this section, you will be able to: find an equation of the line given the slope and yy-intercept, find an equation of the line given the slope and a point, find an equation of the line given two points, find an equation of a line parallel to a given line, and find an equation of a line perpendicular to a given line.

How do online companies know that “you may also like” a particular item based on something you just ordered? How can economists know how a rise in the minimum wage will affect the unemployment rate? How do medical researchers create drugs to target cancer cells? How can traffic engineers predict the effect on your commuting time of an increase or decrease in gas prices? It’s all mathematics.

The physical sciences, social sciences, and the business world are full of situations that can be modeled with linear equations relating two variables. To create a mathematical model of a linear relation between two variables, we must be able to find the equation of the line. In this section, we will look at several ways to write the equation of a line. The specific method we use will be determined by what information we are given.

Find an equation of the line given the slope and y-intercept

We can easily determine the slope and intercept of a line if the equation is written in slope-intercept form, y=mx+by = mx + b. Now we will do the reverse—we will start with the slope and yy-intercept and use them to find the equation of the line.

Example. Find the equation of a line with slope 9-9 and yy-intercept (0,4)(0,-4).

Since we are given the slope and yy-intercept of the line, we can substitute the needed values into the slope-intercept form, y=mx+by=mx+b.

Name the slope.m=9Name the y-intercept.(0,b)=(0,4)Substitute the values into y=mx+b.y=9x+(4)=9x4 \begin{array}{lrcl} \text{Name the slope.} & m &=& -9 \\[4pt] \text{Name the }y\text{-intercept.} & (0,b) &=& (0,-4) \\[4pt] \text{Substitute the values into }y=mx+b. & y &=& -9x+(-4) \\[4pt] &&=& -9x-4 \end{array}

Find the equation of a line with slope 25\tfrac{2}{5} and yy-intercept (0,4)(0,4).

Find the equation of a line with slope 1-1 and yy-intercept (0,3)(0,-3).

Sometimes, the slope and intercept need to be determined from the graph.

Example. Find the equation of the line shown in the graph.

xy

We need to find the slope and yy-intercept of the line from the graph so we can substitute the needed values into the slope-intercept form, y=mx+by=mx+b. To find the slope, we choose two points on the graph. The yy-intercept is (0,4)(0,-4) and the graph passes through (3,2)(3,-2).

Find the slope, by counting the rise and run.m=riserun=23Find the y-intercept.(0,b)=(0,4)Substitute the values into y=mx+b.y=23x4 \begin{array}{lrcl} \text{Find the slope, by counting the rise and run.} & m &=& \tfrac{\text{rise}}{\text{run}} \\[4pt] &&=& \tfrac{2}{3} \\[4pt] \text{Find the }y\text{-intercept.} & (0,b) &=& (0,-4) \\[4pt] \text{Substitute the values into }y=mx+b. & y &=& \tfrac{2}{3}x-4 \end{array}
xy

Find the equation of the line shown in the graph immediately above.

xy

Find the equation of the line shown in the graph immediately above.

Find an equation of the line given the slope and a point

Finding an equation of a line using the slope-intercept form of the equation works well when you are given the slope and yy-intercept or when you read them off a graph. But what happens when you have another point instead of the yy-intercept?

We are going to use the slope formula to derive another form of an equation of the line. Suppose we have a line that has slope mm and that contains some specific point (x1,y1)(x_1,y_1) and some other point, which we will just call (x,y)(x,y). We can write the slope of this line and then change it to a different form.

m=yy1xx1Multiply both sides of the equation by xx1.m(xx1)=(yy1xx1)(xx1)Simplify.m(xx1)=yy1Rewrite the equation with the y terms on the left.yy1=m(xx1) \begin{array}{lrcl} && m &= \tfrac{y-y_1}{x-x_1} \\[10pt] \text{Multiply both sides of the equation by }x-x_1. && m(x-x_1) &= \left(\tfrac{y-y_1}{x-x_1}\right)(x-x_1) \\[10pt] \text{Simplify.} && m(x-x_1) &= y-y_1 \\[4pt] \text{Rewrite the equation with the }y\text{ terms on the left.} && y-y_1 &= m(x-x_1) \end{array}

This format is called the point-slope form of an equation of a line.

Point-slope form of an equation of a line. The point-slope form of an equation of a line with slope mm and containing the point (x1,y1)(x_1,y_1) is yy1=m(xx1)y-y_1=m(x-x_1).

We can use the point-slope form of an equation to find an equation of a line when we know the slope and at least one point. Then, we will rewrite the equation in slope-intercept form. Most applications of linear equations use the slope-intercept form.

Example. Find an equation of a line with slope m=13m=-\tfrac{1}{3} that contains the point (6,4)(6,-4). Write the equation in slope-intercept form.

Identify the slope.m=13Identify the point.(x1,y1)=(6,4)Substitute the values into the point-slope form.y(4)=13(x6)Simplify.y+4=13x+2Write the equation in slope-intercept form.y=13x2 \begin{array}{lrcl} \text{Identify the slope.} & m &=& -\tfrac{1}{3} \\[4pt] \text{Identify the point.} & (x_1,y_1) &=& (6,-4) \\[4pt] \text{Substitute the values into the point-slope form.} & y-(-4) &=& -\tfrac{1}{3}(x-6) \\[10pt] \text{Simplify.} & y+4 &=& -\tfrac{1}{3}x+2 \\[10pt] \text{Write the equation in slope-intercept form.} & y &=& -\tfrac{1}{3}x-2 \end{array}

Find the equation of a line with slope m=25m=-\tfrac{2}{5} and containing the point (10,5)(10,-5).

Find the equation of a line with slope m=34m=-\tfrac{3}{4} and containing the point (4,7)(4,-7).

We list the steps for easy reference.

To find an equation of a line given the slope and a point.

  1. Identify the slope.
  2. Identify the point.
  3. Substitute the values into the point-slope form, yy1=m(xx1)y-y_1=m(x-x_1).
  4. Write the equation in slope-intercept form.

Example. Find an equation of a horizontal line that contains the point (2,6)(-2,-6). Write the equation in slope-intercept form.

Every horizontal line has slope 00. We can substitute the slope and point into the point-slope form, yy1=m(xx1)y-y_1=m(x-x_1).

Identify the slope.m=0Identify the point.(x1,y1)=(2,6)Substitute the values.y(6)=0(x(2))Simplify.y+6=0y=6 \begin{array}{lrcl} \text{Identify the slope.} & m &=& 0 \\[4pt] \text{Identify the point.} & (x_1,y_1) &=& (-2,-6) \\[4pt] \text{Substitute the values.} & y-(-6) &=& 0(x-(-2)) \\[4pt] \text{Simplify.} & y+6 &=& 0 \\[4pt] && y &= -6 \end{array}

It is in yy-form, but could be written y=0x6y=0x-6. Did we end up with the form of a horizontal line, y=by=b?

Find the equation of a horizontal line containing the point (3,8)(-3,8).

Find the equation of a horizontal line containing the point (1,4)(-1,4).

Find an equation of the line given two points

When real-world data is collected, a linear model can be created from two data points. In the next example we’ll see how to find an equation of a line when just two points are given.

So far, we have two options for finding an equation of a line: slope-intercept or point-slope. When we start with two points, it makes more sense to use the point-slope form.

But then we need the slope. Can we find the slope with just two points? Yes. Then, once we have the slope, we can use it and one of the given points to find the equation.

Example. Find an equation of a line that contains the points (3,1)(-3,-1) and (2,2)(2,-2). Write the equation in slope-intercept form.

Find the slope using the given points.m=y2y1x2x1=2(1)2(3)=15Choose either point.(x1,y1)=(2,2)Substitute into the point-slope form.y(2)=15(x2)Simplify.y+2=15x+25Write in slope-intercept form.y=15x85 \begin{array}{lrcl} \text{Find the slope using the given points.} & m &=& \tfrac{y_2-y_1}{x_2-x_1} \\[10pt] &&=& \tfrac{-2-(-1)}{2-(-3)} \\[10pt] &&=& -\tfrac{1}{5} \\[10pt] \text{Choose either point.} & (x_1,y_1) &=& (2,-2) \\[4pt] \text{Substitute into the point-slope form.} & y-(-2) &=& -\tfrac{1}{5}(x-2) \\[10pt] \text{Simplify.} & y+2 &=& -\tfrac{1}{5}x+\tfrac{2}{5} \\[10pt] \text{Write in slope-intercept form.} & y &=& -\tfrac{1}{5}x-\tfrac{8}{5} \end{array}

Find the equation of a line containing the points (2,4)(-2,-4) and (1,3)(1,-3).

Find the equation of a line containing the points (4,3)(-4,-3) and (1,5)(1,-5).

The steps are summarized here.

To find an equation of a line given two points.

  1. Find the slope using the given points, m=y2y1x2x1m=\tfrac{y_2-y_1}{x_2-x_1}.
  2. Choose one point.
  3. Substitute the values into the point-slope form: yy1=m(xx1)y-y_1=m(x-x_1).
  4. Write the equation in slope-intercept form.

Example. Find an equation of a line that contains the points (3,5)(-3,5) and (3,4)(-3,4). Write the equation in slope-intercept form.

Again, the first step will be to find the slope.

Find the slope through (3,5) and (3,4).m=y2y1x2x1=453(3)=10 \begin{array}{lrcl} \text{Find the slope through }(-3,5)\text{ and }(-3,4). & m &=& \tfrac{y_2-y_1}{x_2-x_1} \\[10pt] &&=& \tfrac{4-5}{-3-(-3)} \\[10pt] &&=& \tfrac{-1}{0} \end{array}

The slope is undefined. This tells us it is a vertical line. Both of our points have an xx-coordinate of 3-3. So our equation of the line is x=3x=-3. Since there is no yy, we cannot write it in slope-intercept form.

You may want to sketch a graph using the two given points. Does your graph agree with our conclusion that this is a vertical line?

Find the equation of a line containing the points (5,1)(5,1) and (5,4)(5,-4).

Find the equation of a line containing the points (4,4)(-4,4) and (4,3)(-4,3).

We have seen that we can use either the slope-intercept form or the point-slope form to find an equation of a line. Which form we use will depend on the information we are given.

If givenUseForm
Slope and yy-interceptslope-intercepty=mx+by=mx+b
Slope and a pointpoint-slopeyy1=m(xx1)y-y_1=m(x-x_1)
Two pointspoint-slopeyy1=m(xx1)y-y_1=m(x-x_1)

Find an equation of a line parallel to a given line

Suppose we need to find an equation of a line that passes through a specific point and is parallel to a given line. We can use the fact that parallel lines have the same slope. So we will have a point and the slope—just what we need to use the point-slope equation.

First, let’s look at this graphically. This graph shows y=2x3y=2x-3. We want to graph a line parallel to this line and passing through the point (2,1)(-2,1).

xy

We know that parallel lines have the same slope. So the second line will have the same slope as y=2x3y=2x-3. That slope is m=2m_{\parallel}=2. We’ll use the notation mm_{\parallel} to represent the slope of a line parallel to a line with slope mm. (Notice that the subscript \parallel looks like two parallel lines.)

The second line will pass through (2,1)(-2,1) and have m=2m=2. To graph the line, we start at (2,1)(-2,1) and count out the rise and run. With m=2m=2 (or m=21m=\tfrac{2}{1}), we count out the rise 22 and the run 11. We draw the line, as shown in the graph.

xy

Do the lines appear parallel? Does the second line pass through (2,1)(-2,1)? We were asked to graph the line; now let’s see how to do this algebraically. We can use either the slope-intercept form or the point-slope form to find an equation of a line. Here we know one point and can find the slope. So we will use the point-slope form.

Example. Find an equation of a line parallel to y=2x3y=2x-3 that contains the point (2,1)(-2,1). Write the equation in slope-intercept form.

Find the slope of the given line.m=2Find the slope of the parallel line.m=2Identify the point.(x1,y1)=(2,1)Substitute into the point-slope form.y1=2(x(2))Simplify.y1=2(x+2)=2x+4Write in slope-intercept form.y=2x+5 \begin{array}{lrcl} \text{Find the slope of the given line.} & m &=& 2 \\[4pt] \text{Find the slope of the parallel line.} & m_{\parallel} &=& 2 \\[4pt] \text{Identify the point.} & (x_1,y_1) &=& (-2,1) \\[4pt] \text{Substitute into the point-slope form.} & y-1 &=& 2(x-(-2)) \\[4pt] \text{Simplify.} & y-1 &=& 2(x+2) \\[4pt] &&=& 2x+4 \\[4pt] \text{Write in slope-intercept form.} & y &=& 2x+5 \end{array}

Look at the graph with the parallel lines shown previously. Does this equation make sense? What is the yy-intercept of the line? What is the slope?

Find an equation of a line parallel to y=3x+1y=3x+1 that contains the point (4,2)(4,2).

Find an equation of a line parallel to y=12x3y=\tfrac{1}{2}x-3 that contains the point (6,4)(6,4).

Find an equation of a line parallel to a given line.

  1. Find the slope of the given line.
  2. Find the slope of the parallel line.
  3. Identify the point.
  4. Substitute the values into the point-slope form: yy1=m(xx1)y-y_1=m(x-x_1).
  5. Write the equation in slope-intercept form.

Find an equation of a line perpendicular to a given line

Now, let’s consider perpendicular lines. Suppose we need to find a line passing through a specific point and which is perpendicular to a given line. We can use the fact that perpendicular lines have slopes that are negative reciprocals. We will again use the point-slope equation, like we did with parallel lines.

This graph shows y=2x3y=2x-3. Now, we want to graph a line perpendicular to this line and passing through (2,1)(-2,1).

xy

We know that perpendicular lines have slopes that are negative reciprocals. We’ll use the notation mm_{\perp} to represent the slope of a line perpendicular to a line with slope mm. (Notice that the subscript \perp looks like the right angles made by two perpendicular lines.)

y=2x3m=2m=12 \begin{array}{rcl} y &=& 2x-3 \\[4pt] m &=& 2 \\[4pt] m_{\perp} &=& -\tfrac{1}{2} \end{array}

We now know the perpendicular line will pass through (2,1)(-2,1) with m=12m_{\perp}=-\tfrac{1}{2}. To graph the line, we will start at (2,1)(-2,1) and count out the rise 1-1 and the run 22. Then we draw the line.

xy

Do the lines appear perpendicular? Does the second line pass through (2,1)(-2,1)? We were asked to graph the line; now, let’s see how to do this algebraically.

We can use either the slope-intercept form or the point-slope form to find an equation of a line. In this example we know one point, and can find the slope, so we will use the point-slope form.

Example. Find an equation of a line perpendicular to y=2x3y=2x-3 that contains the point (2,1)(-2,1). Write the equation in slope-intercept form.

Find the slope of the given line.m=2Find the slope of the perpendicular line.m=12Identify the point.(x1,y1)=(2,1)Substitute into the point-slope form.y1=12(x(2))Simplify.y1=12(x+2)=12x1Write in slope-intercept form.y=12x \begin{array}{lrcl} \text{Find the slope of the given line.} & m &=& 2 \\[4pt] \text{Find the slope of the perpendicular line.} & m_{\perp} &=& -\tfrac{1}{2} \\[10pt] \text{Identify the point.} & (x_1,y_1) &=& (-2,1) \\[4pt] \text{Substitute into the point-slope form.} & y-1 &=& -\tfrac{1}{2}(x-(-2)) \\[10pt] \text{Simplify.} & y-1 &=& -\tfrac{1}{2}(x+2) \\[10pt] &&=& -\tfrac{1}{2}x-1 \\[10pt] \text{Write in slope-intercept form.} & y &=& -\tfrac{1}{2}x \end{array}

Find an equation of a line perpendicular to y=3x+1y=3x+1 that contains the point (4,2)(4,2).

Find an equation of a line perpendicular to y=12x3y=\tfrac{1}{2}x-3 that contains the point (6,4)(6,4).

Find an equation of a line perpendicular to a given line.

  1. Find the slope of the given line.
  2. Find the slope of the perpendicular line.
  3. Identify the point.
  4. Substitute the values into the point-slope form, yy1=m(xx1)y-y_1=m(x-x_1).
  5. Write the equation in slope-intercept form.

Example. Find an equation of a line perpendicular to x=5x=5 that contains the point (3,2)(3,-2). Write the equation in slope-intercept form.

Again, since we know one point, the point-slope option seems more promising than the slope-intercept option. We need the slope to use this form, and we know the new line will be perpendicular to x=5x=5. This line is vertical, so its perpendicular will be horizontal. This tells us m=0m_{\perp}=0.

Identify the point.(x1,y1)=(3,2)Identify the slope of the perpendicular line.m=0Substitute the values.y(2)=0(x3)Simplify.y+2=0y=2 \begin{array}{lrcl} \text{Identify the point.} & (x_1,y_1) &=& (3,-2) \\[4pt] \text{Identify the slope of the perpendicular line.} & m_{\perp} &=& 0 \\[4pt] \text{Substitute the values.} & y-(-2) &=& 0(x-3) \\[4pt] \text{Simplify.} & y+2 &=& 0 \\[4pt] && y &= -2 \end{array}

Sketch the graph of both lines. On your graph, do the lines appear to be perpendicular?

Find an equation of a line that is perpendicular to x=4x=4 and contains the point (4,5)(4,-5).

Find an equation of a line that is perpendicular to x=2x=2 and contains the point (2,1)(2,-1).

In the preceding example, we used the point-slope form to find the equation. We could have looked at this in a different way. We want to find a line that is perpendicular to x=5x=5 that contains the point (3,2)(3,-2). The first graph shows us the line x=5x=5 and the point (3,2)(3,-2).

xy

We know every line perpendicular to a vertical line is horizontal, so we will sketch the horizontal line through (3,2)(3,-2).

xy

Do the lines appear perpendicular? If we look at a few points on this horizontal line, we notice they all have yy-coordinates of 2-2. So, the equation of the line perpendicular to the vertical line x=5x=5 is y=2y=-2.

Example. Find an equation of a line that is perpendicular to y=3y=-3 that contains the point (3,5)(-3,5). Write the equation in slope-intercept form.

The line y=3y=-3 is a horizontal line. Any line perpendicular to it must be vertical, in the form x=ax=a. Since the perpendicular line is vertical and passes through (3,5)(-3,5), every point on it has an xx-coordinate of 3-3. The equation of the perpendicular line is x=3x=-3. You may want to sketch the lines. Do they appear perpendicular?

Find an equation of a line that is perpendicular to y=1y=1 and contains the point (5,1)(-5,1).

Find an equation of a line that is perpendicular to y=5y=-5 and contains the point (4,5)(-4,-5).

Key terms

point-slope form — the form yy1=m(xx1)y-y_1=m(x-x_1) of an equation of a line with slope mm containing the point (x1,y1)(x_1,y_1). parallel lines — lines in the same plane that do not intersect and have the same slope. perpendicular lines — lines that intersect at a right angle and whose slopes are negative reciprocals.


This section is adapted from Intermediate Algebra 2e, Section 3.3: Find the Equation of a Line by Lynn Marecek, Andrea Honeycutt Mathis, and OpenStax, © OpenStax, licensed under CC BY-NC-SA 4.0. Access the original for free at openstax.org. Changes: recreated the coordinate-plane figures as accessible interactive graphs; omitted the Be Prepared quiz, media links, and end-of-section exercises; and converted the practice problems (“Try Its”) into interactive exercises with instant feedback.