topic badge
AustraliaNSW
Stage 5.1-2

4.02 Finding the equation of a straight line

Lesson

Introduction

We know that all linear equations can be written in the form y=mx+c where m is the gradient and c is the value of the y-intercept.

Knowing this, we can also work out the equation of a straight line if we are given its graph - we just need to work out the gradient and y-intercept. That is, we want to find m and c.

Equation from a graph

To find c we can just look at where the line crosses the y-axis. The value of y at this point is our y-intercept.

To find the gradient, we want to choose two points on the line that we can easily identify the co-ordinates of, ideally points with integer co-ordinates. Using these two points we can calculate the  gradient  , by identifying the rise and run of the line, or by using the gradient formula.

Consider the following graph. How can we work out its equation?

-4
-3
-2
-1
1
2
3
4
x
-7
-6
-5
-4
-3
-2
-1
1
y

We can see that the x and y-intercepts are clearly marked on the graph so let's use them.

The y-intercept is at (0,-6) which means c=-6.

To find the gradient m we want to work out the rise and run of the line. As we move along the line from the y-intercept to the x-intercept, we have moved from (0,-6) to (2,0). The x-value has increased by 2 and the y-value has increased by 6. We have a run of 2 and a rise of 6. So the gradient is equal to m=\dfrac62=3.

The equation of the line is y=3x-6.

We could have chosen any two points on this line, but sometimes the coordinates might not be clear if they are not integer values. In this case, the point that is one unit along the x-axis from the point (0,-6) has coordinates of (1,-3) which confirms the gradient is 3 as expected.

-4
-3
-2
-1
1
2
3
4
x
-4
-3
-2
-1
1
2
3
4
y

If the line passes through the origin (0,0) the x and y-intercept both occur at this point, so you will need to find a second point to calculate the gradient.

This line passes through the origin, (0,0), we can see it also passes through the point (2,-1). So we can use these two points.

Examples

Example 1

The variables x and y are related, and a table of values is given below:

x12345
y-3-6-9-12-15
a

What is the value of y when x=0?

Worked Solution
Create a strategy

Notice how the y-values are changing as the x-values decrease by 1.

Apply the idea

As the x-values decrease by 1 we can see in the table that the y-values increase by 3: \\ -9+3=-6, \, -6+3=-3, \ldots

This means the y-value when x=0 must be 3 more than the y-value when x=1, that is y=-3+3=0.

b

Write the linear equation expressing the relationship between x and y.

Worked Solution
Create a strategy

Find the gradient, then use the equation y=mx+c.

Apply the idea

The decrease in y-values as x increases by 1 is 3, so m=-3.

We know that the value of y when x=0 is 0, so c=0.

So the linear equation is y=-3x.

c

What is the value of y when x=-16?

Worked Solution
Create a strategy

Substitute the given x-value into the equation found from part (b).

Apply the idea
\displaystyle y\displaystyle =\displaystyle -3xWrite the equation
\displaystyle y\displaystyle =\displaystyle -3\times -16Substitute x=-16
\displaystyle =\displaystyle 48Evaluate

Example 2

A line passes through point A(8,2) and has a gradient of 2.

a

Find the value of the y-intercept of the line, denoted by c.

Worked Solution
Create a strategy

Use the gradient-intercept form y=mx+c and substitute the given values.

Apply the idea
\displaystyle y\displaystyle =\displaystyle mx+cUse the gradient-intercept form
\displaystyle mx+c\displaystyle =\displaystyle ySwap the sides
\displaystyle 2\times(8)+c\displaystyle =\displaystyle 2Substitute m=2, x=8, and y=2
\displaystyle 16+c\displaystyle =\displaystyle 2Simplify
\displaystyle c\displaystyle =\displaystyle -14Subtract 16 from both sides
b

Write the equation of the line in gradient-intercept form.

Worked Solution
Create a strategy

Substitute the gradient and the value of c found from part (a) into y=mx+c.

Apply the idea

y=2x-14

Idea summary

We could choose any two points on the line to find the equation of a line with a linear relationship.

All linear equations are of the form:

\displaystyle y=mx+c
\bm{m}
is the gradient
\bm{c}
is the y-intercept

The point-gradient formula

Sometimes we don't know the value of the y-intercept, but if we know the gradient and the coordinates of one point, we can still find the equation of the line. If we don't know the gradient, but know the coordinates of two points, we can first find the gradient and then use the point-gradient formula.

Let's say we know that the gradient of the line is -2. We also know a point on the line, (2,-8).

Now, apart from this point there are infinitely many other points on this line, and we will let (x,y) represent each of them.

Well, since (x,y) and (2,-8) are points on the line, then the gradient between them will be -2.

We know that to find the gradient given two points, we use:

m =\dfrac{y_2-y_1}{x_2-x_1}

Let's apply the gradient formula to (x,y) and (2,-8):

m =\dfrac{y-(-8)}{x-2}

But we know that the gradient of the line is -2. So:

\dfrac{y-(-8)}{x-2}=-2

Rearranging this slightly, we get:

y-(-8)=-2(x-2)

You may be thinking that we should simplify the equation, and of course if you do you should get y=-2x-4. What we want to do though, is generalise our steps so that we can apply it to any case where we're given a gradient m, and a point on the line (x_1,y_1).

This image shows a line through points A and B.. Ask your teacher for more information.

In the example above, the point on the line was (2,-8). Let's generalise and replace it with (x_1,y_1).

We were also given the gradient -2. Let's generalise and replace it with m.

So from y-(-8)=-2(x-2) we get: y-y_1=m\left(x-x_1\right).

We call this the point gradient formula, because when we know a point and the gradient using this rule we can easily get the equation of that line.

Given a point on the line (x_1,y_1) and the gradient m, the equation of the line is: y-y_1=m\left(x-x_1\right)

Examples

Example 3

A line passes through the point A\left(-2, -9\right) and has a gradient of -2. Using the point-gradient formula, express the equation of the line in gradient intercept form.

Worked Solution
Create a strategy

Use the point-gradient formula.

Apply the idea
\displaystyle y-y_1\displaystyle =\displaystyle m\left(x-x_1\right)Use the point-gradient formula
\displaystyle y-(-9)\displaystyle =\displaystyle -2\left(x-\left(-2\right)\right)Susbtitute \left(-2, -9\right) and m=-2
\displaystyle y+9\displaystyle =\displaystyle -2\left(x+2\right)Evaluate the adjacent signs
\displaystyle y+9\displaystyle =\displaystyle -2x-4Expand the brackets
\displaystyle y+9-9\displaystyle =\displaystyle -2x-4-9Subtract 9 from both sides
\displaystyle y\displaystyle =\displaystyle -2x-13Evaluate
Idea summary

To find the equation of a line given the gradient and a point, use the point-gradient formula:

\displaystyle y-y_1=m\left(x-x_1\right)
\bm{m}
is the gradient
\bm{(x_1,y_1)}
are the coordinates of the given point

Outcomes

MA5.2-9NA

uses the gradient-intercept form to interpret and graph linear relationships

What is Mathspace

About Mathspace