# Graphing - Equation of the Line

If you are given a line on a graph (or enough information to construct a line), you will likely also be asked to find the equation of the line. The equation of the line is unique to each line; that is, every line has a different equation. With it, you can readily tell the slope of the line, and you can calculate what the x-value is for any y-value on the line (and vice versa). It is very handy!

The most common and basic form of the equation of the line is:

y = mx + b

where m is the slope and b is the y-intercept (where the line crosses through the y-axis).

Another way to write it, which is more general is called the POINT-SLOPE FORMULA:

(y-y1) = m(x-x1)

where m is the slope, and x1 and y1 are the coordinates of a known point on the graph. (If you pay close attention, you can see that this way of writing it is really the same as the slope formula, but rearranged!) The version basically says 'give any point at all, and a slope, and you have enough information to draw the line."

Let's use the graph from the slope lesson to practice, using points (2,1) and (7,7). To get our final answer, we are going to have to do a couple of steps first. Let's use the y=mx+b equation. The steps we are going to do are:
1) Find the slope
2) Find the y-intercept
3) Write the equation of the line

Finding the slope is easy now, if you read the posting on slopes (I always leave numbers as fractions, instead of changing to decimals):

m = (y2-y1)/(x2-x1)
= (7-1)/(7-2)
= 6/5

The y-intercept is easy now... just plug numbers into y=mx+b, and solve for b. So, b=y-mx. We have our slope now, and for y and x, we just substitute in the coordinates of a single point (x and y MUST be from the same point!)

b=y-mx
= 1-(6/5) x 2
= 1-12/5
= (-7/5) (you have to do some fraction math!)

So now we can write the equation of our line!

y = mx+b
y = (6/5)x - (7/5).... (if we leave it like this, we can read the values for slope and y-int right from the equation!)
y = (6x - 7)/5

If we work through using the other formula... (y-y1) = m(x-x1)... we get the same answer, and we don't have to explicitly solve for b! First, solve for slope. Second, substitute in values for slope and x1,y1, and then rearrange!

slope = 6/5 (same thing we did above)

so (y-y1) = m(x-x1)..... (sub in slope, and point (2,1) for (x1,y1))
(y-1) = (6/5)(x-2)...
y=(6/5)(x-2) + 1...
y = (6/5)x - (6/5)2 + 1...
y=(6/5)x -12/5 + 1...
y=(6/5)x -(7/5)... (same slope and y-int)
y=(6x-7)/5

Same answer! That is the equation of the line. Now if you put in any value for x, you can say exactly what the value for y would be... if you wanted to know what y is when x is 1000, you can do that now! You will see that it will always be on the same straight line.

If we work through and do the same thing for the red line on the graph, with points (-6,2) and (-4,-5), we can get the equation for that line too! Let's try it this time using just the one formula.

(y-y1) = m(x-x1)
((-5)-2) = m((-4)-(-6))
(-7) = m(2)
m=(-7/2)

Now put that back into the same formula along with a point, and rearrange:

(y-y1) = m(x-x1)
(y-2) = (-7/2)(x-(-6))
y-2 = (-7/2)(x+6)
y= (-7/2)x + (-7/2)(6) + 2
y = (-7/2)x -21 + 2
y = (-7/2)x -19

(see slope (-7/2) and y-int (-19)... look at the graph, and you will see that makes sense! Negative slope, very low y-int!)

That's all there is to it! Just remember that there are a few steps to follow, depending on the formula you are using... basically, remember to always find the slope first, then the y-intercept, and plug directly into y=mx+b... or use the point-slope formula to find the slope using 2 points, and then resubstitute it back in with a single point and rearrange. It's not that complicated once you practice and understand what you are doing! Either method is going to give you the same answer, so pick your favorite and stick with it!