### How can we find the equation of a straight line?

We already know how to do this: once we know the gradient \(m\) and the \(y\)-intercept \(c\), we can just write down \[y=mx+c\] and we are done.

But what if we don’t know the \(y\)-intercept? In this piece, we’ll explore several scenarios and some related methods of approaching this question.

### How can we find the equation from the gradient and a point on the line?

There are many times in mathematics where we know the gradient of a straight line and the coordinates of some point on the line, and we want to find its equation. When we get to Calculus of Powers, we will meet a very common example of this type of problem: how do we find the equation of the tangent to a curve?

In the meantime, though, we will just suppose that we know the gradient and a point on the line, and want to find the equation of this line.

We’ll start with a specific example: Find the equation of the line with gradient \(3\) passing through \((1,2)\).

#### A first approach

We know that the line has equation \(y=mx+c\), and we know that \(m=3\), so the equation is \(y=3x+c\).

Now when \(x=1\), we must have \(y=2\), as the point \((1,2)\) lies on the line. (Remember that the equation tells us the rule which every point on the line has to obey: “the \(y\)-coordinate is \(3\) times the \(x\)-coordinate plus \(c\)”.)

So we can substitute in \(x=1\) and \(y=2\) to get \[\begin{align*} &2=3\times1+c\\ \Longrightarrow\quad& 2=3+c\\ \Longrightarrow\quad& c=-1\ . \end{align*}\]So the equation is \(y=3x-1\).

In fact, this method will always work no matter which co-ordinates and what gradient we are given!

We are about to look at some other methods which can be used instead and often appear to be slicker, but this one is solid and reliable.

#### A second approach: thinking about gradients

On this interactivity, one point is fixed at \((1,2)\). Move the second point \((x,y)\) so that it lies on the line with gradient \(3\) passing through \((1,2)\). As you do so, think about how you *know* that your point \((x,y)\) lies on this line.

And this gives us another way of writing our straight line!

To convert it into a more familiar form, we can multiply both sides by \(x-1\) to get: \[\begin{equation} y-2=3(x-1),\label{eq:2} \end{equation}\]then expand the brackets to get \[y-2=3x-3.\] Adding \(2\) to both sides finally gets us back to \(y=3x-1\).

There is actually a reason why we prefer the form \(\eqref{eq:2}\) over the original \(\eqref{eq:1}\). Think about the point \((1,2)\) itself, which lies on the line. If we try substituting those values into \(\eqref{eq:1}\), we end up with \(\frac{0}{0}=3\), which has no mathematical meaning, as we are not allowed to divide by zero.

On the other hand, if we substitute \(x=1\) and \(y=2\) into \(\eqref{eq:2}\), we get \(0=0\), which is perfectly correct.

\[y-y_1=m(x-x_1).\]

This is a very useful form to know, as it allows us to immediately write down an equation for a line when we know its gradient and a point on the line. We can then multiply out and rearrange to get the equation in the form \(y=mx+c\) if we wish to do so.

### How can we find the equation from two points on the line?

We know how to find the gradient of the line between two points. Once we have that, we can then use one of the methods we’ve just been discussing to find the equation of the line.

For example, let’s find the equation of the straight line joining \((1,3)\) and \((7,1)\).

The gradient is \[\frac{\text{change in $y$}}{\text{change in $x$}} = \frac{1-3}{7-1} = \frac{-2}{6} = -\frac{1}{3}\]

So the equation of the line with gradient \(-\frac{1}{3}\) passing through \((1,3)\) is \[y-3=-\frac{1}{3}(x-1),\] which we can rearrange to get \(y=-\frac{1}{3}x+\frac{10}{3}\).

In general, if we have the two points \((x_1,y_1)\) and \((x_2,y_2)\), then the gradient of the line joining them is \(\dfrac{y_2-y_1}{x_2-x_1}\). If we use the equation of form \(\eqref{eq:1}\) that we had above, we obtain the very symmetrical form for the line: \[\frac{y-y_1}{x-x_1}=\frac{y_2-y_1}{x_2-x_1}.\] If we now convert this into a form not using fractions, by multiplying both sides by \((x-x_1)(x_2-x_1)\), we get \[(x_2-x_1)(y-y_1)=(y_2-y_1)(x-x_1),\] which again has a pleasing symmetry to it.

Finally, if we expand the brackets and rearrange, we can write this in yet another way: \[(y_2-y_1)x-(x_2-x_1)y=x_1y_2-x_2y_1.\]

It is not worth trying to memorise any of these general formulae; work them out as you need them!

#### A substitution method

An alternative method is to substitute the coordinates of the two points into the equation \(y=mx+c\). In the example of the points \((1,3)\) and \((7,1)\), we get the simultaneous equations \[\begin{align*} 3&=m+c\\ 1&=7m+c \end{align*}\]Subtracting these equations gives \(2=-6m\) so \(m=-\frac{1}{3}\). Substituting this back into one of the equations allows us to find that \(c=\frac{10}{3}\), as before.

### Another way to write the equation: \(ax+by+c=0\)

Sometimes, the numbers which appear in the equation of a straight line written as \(y=mx+c\) can be somewhat awkward and involve fractions, for example our answer \(y=-\frac{1}{3}x+\frac{10}{3}\) in the last section. One thing that can make the equation look nicer in this case is to multiply through by an integer to make all of the numbers integers. In this case, we can multiply through by \(3\) to get \(3y=-x+10\), which now has no fractions.

Once we are rearranging equations like this, though, it might seem harder to compare two equations to decide if they represent the same line or parallel lines or so forth. For example, we could have rearranged this to get \(x=10-3y\) or multiplied by \(6\) instead to get \(6y=-2x+20\), which both represent the same line, but look somewhat different.

One way of being a bit more consistent is to rearrange the equation to always put everything on the left hand side, getting \[x+3y-10=0.\]

One advantage of this way of writing straight lines is that it includes vertical lines such as \(x=4\), which can be written as \(x-4=0\) (or \(x+0y-4=0\) to be explicit about the absence of \(y\)). But it has the disadvantage that the same line can still be written in more than one way (for example, \(2x+6y-20=0\) in this case).

So it is often still easier to work with the \(y=mx+c\) form, especially if you are trying to decide if lines are parallel or perpendicular.

Challenge: Given two lines \(a_1x+b_1y+c_1=0\) and \(a_2x+b_2y+c_2=0\), how can you tell if they are parallel or perpendicular, *without* converting them back into the form \(y=mx+c\)?

### Alternative perspectives: Thinking about translations

We know that a straight line through the origin with gradient \(m\) has equation \(y=mx\). If we now wish to look at the straight line through \((x_1,y_1)\) with the same gradient, we can achieve this by either translating our line through the origin or by translating our coordinate system.

We’ll begin by looking at what happens if we translate our coordinate system, and come back to thinking about translating the line itself later.

In the following interactive graph, the original axes are shown in black and a new set of axes are in blue. The red point is shown with its coordinates according to both the original black axes (which we’ve called \((x,y)\)) and the new blue axes (called \((X,Y)\)).

Can you find a relation between \((X,Y)\) and \((x,y)\)? Explore by moving the red point and also the blue axes (which you can do by dragging the origin of the blue axes; you may also need to move the origin in order to see the blue axis labels, due to a bug in GeoGebra).

We can take this further by drawing a straight line on the graph.

The next graph shows a red point on a red line of gradient \(m\) passing through the point \((x_1,y_1)\).

You can control the gradient of the line with the slider, you can move the point \((x_1,y_1)\) and you can move the point on the red line.

What condition do the coordinates of the red point satisfy in the **blue** axes (the \((X,Y)\) coordinates)?

Remembering how the blue coordinates \((X,Y)\) are related to the black coordinates \((x,y)\), can you figure out the condition the coordinates of the red point satisfy in the **black** axes (the \((x,y)\) coordinates)?

This idea of translating a coordinate system was taken much further by Einstein when he developed his Special Theory of Relativity. But that is a story for another day!

This form of the equation is also useful because it tells us that \(y-y_1\) is directly proportional to \(x-x_1\). Directly proportionality is such a nice thing itself that it is sometimes useful to write the equation of a line in this form.

Finally, we can think about translating the line instead of translating the coordinate system. When we translate an object by the vector \(\dbinom{x_1}{y_1}\), the coordinates of all of its points have \(x_1\) added to the \(x\)-coordinate and \(y_1\) added to the \(y\)-coordinate.

If we consider the line with gradient \(m\) passing through the origin, it has equation \(y=mx\). To keep the same sort of notation as we used earlier, we will pick a point \((X,Y)\) on this line, so that \(Y=mX\).

If we now translate this line by \(\dbinom{x_1}{y_1}\), so that the origin moves to \((x_1,y_1)\), the point \((X,Y)\) will move to \((X+x_1,Y+y_1)\), as shown in the following interactivity.

You can change the value of \(\dbinom{x_1}{y_1}\) by moving the blue circle, and you can move the black point \((X,Y)\) along the black line \(y=mx\).

You can also change the gradient of the black line \(y=mx\) by moving the slider.

So if \((x,y)\) are the coordinates of a point on the translated line, we have \[x=X+x_1, \quad y=Y+y_1\qquad \text{where}\quad Y=mX.\] Rearranging to get \(X=x-x_1\) and \(Y=y-y_1\), the relationship \(Y=mX\) becomes \[y-y_1=m(x-x_1),\] which is the same equation as before.