## Lines and linear equations

### Graphs of lines

Geometry taught us that exactly one line crosses through any two points. We can use this fact in algebra as well. When drawing the graph of a line, we only need two points, and then use a straight edge to connect them. Remember, though, that lines are infinitely long: they do not start and stop at the two points we used to draw them.

Lines can be expressed algebraically as an equation that relates the $y$-values to the $x$-values. We can use the same fact that we used earlier that two points are contained in exactly one line. With only two points, we can determine the equation of a line. Before we do this, let's discuss some very important characteristics of lines: slope, $y$-intercept, and $x$-intercept.

#### Slope

Think of the slope of a line as its "steepness": how quickly it rises or falls from left to right. This value is indicated in the graph above as $\frac{\Delta y}{\Delta x}$, which specifies how much the line rises or falls (change in $y$) as we move from left to right (change in $x$). It is important to relate slope or steepness to the rate of vertical change per horizontal change. A popular example is that of speed, which measures the change in distance per change in time. Where a line can represent the distance traveled at various points in time, the slope of the line represents the speed. A steep line represents high speed, whereas very little steepness represents a much slower rate of travel, or low speed. This is illustrated in the graph below.

Speed graph

The vertical axis represents distance, and the horizontal axis represents time. The red line is steeper than the blue and green lines. Notice the distance traveled after one hour on the red line is about 5 miles. It is much greater than the distance traveled on the blue or green lines after one hour - about $1$ mile and $\frac{1}{5}$, respectively. The steeper the line, the greater the distance traveled per unit of time. In other words, steepness or slope represents speed. The red lines is the fastest, with the greatest slope, and the green line is the slowest, with the smallest slope.

Slope can be classified in four ways: positive, negative, zero, and undefined slope. Positive slope means that as we move from left to right on the graph, the line rises. Negative slope means that as we move from left to right on the graph, the line falls. Zero slope means that the line is horizontal: it neither rises nor falls as we move from left to right. Vertical lines are said to have "undefined slope," as their slope appears to be some infinitely large, undefined value. See the graphs below that show each of the four slope types.

 Positive slope: Negative slope: Zero slope (Horizontal): Undefined slope (Vertical): $\frac{\Delta y}{\Delta x} \gt 0$ $\frac{\Delta y}{\Delta x} \lt 0$ $\Delta y = 0$, $\Delta x \neq 0$, so $\frac{\Delta y}{\Delta x} = 0$ $\Delta x = 0$, so $\frac{\Delta y}{\Delta x}$ is undefined

Investigate the behavior of a line by adjusting the slope via the "$m$-slider".

Watch this video on slope for more insight into the concept.

#### $y$-Intercept

The $y$-intercept of a line is the point where the line crosses the $y$-axis. Note that this happens when $x = 0$. What are the $y$-intercepts of the lines in the graphs above?

It looks like the $y$-intercepts are $(0, 1)$, $(0, 0)$, and $(0, 1)$ for the first three graphs. There is no $y$-intercept on the fourth graph - the line never crosses the $y$-axis.

Investigate the behavior of a line by adjusting the $y$-intercept via the "$b$-slider".

#### $x$-Intercept

The $x$-intercept is a similar concept as $y$-intercept: it is the point where the line crosses the $x$-axis. This happens when $y = 0$. The $x$-intercept is not used as often as $y$-intercept, as we will see when determing the equation of a line. What are the $x$-intercepts of the lines in the graphs above?

It looks like the $x$-intercepts are $(-\frac{1}{2}, 0)$ and $(0, 0)$ for the first two graphs. There is no $x$-intercept on the third graph. The fourth graph has an $x$-intercept at $(-1, 0)$.

### Equations of lines

In order to write an equation of a line, we usually have to determine the slope of the line first.

#### Calculating slope

Algebraically, slope is calculated as the ratio of the change in the $y$ value to the change in the $x$ value between any two points on the line. If we have two points, $(x_1, y_1)$ and $(x_2, y_2)$, slope is expressed as:

$$\bbox[yellow, 5px]{\text{slope} = m = \frac{\Delta y}{\Delta x} = \frac{y_2 - y_1}{x_2 - x_1}.}$$

Note that we use the letter $m$ to denote slope. A line that is very steep has $m$ values with very large magnitude, whereas as line that is not steep has $m$ values with very small magnitude. For example, slopes of $100$ and $-1,000$ have much larger magnitude than slopes of $-0.1$ or $1$.

##### Example:

Find the slope of the line that passes through points $(-2, 1)$ and $(5, 8)$.

Using the formula for slope, and letting point $(x_1, y_1) = (-2, 1)$ and point $(x_2, y_2) = (5, 8)$, \begin{align*} m &= \frac{\Delta y}{\Delta x} = \frac{y_2 - y_1}{x_2 - x_1}\\[1ex] &= \frac{8 - 1}{5 - (-2)}\\[1ex] &= \frac{7}{5 + 2}\\[1ex] &= \frac{7}{7}\\[1ex] &= 1 \end{align*}

Note that we chose point $(-2, 1)$ as $(x_1, y_1)$ and point $(5, 8)$ as $(x_2, y_2)$. This was by choice, as we could have let point $(5, 8)$ be $(x_1, y_1)$ and point $(-2, 1)$ be $(x_1, y_1)$. How does that affect the calculation of slope?

\begin{align*} m &= \frac{\Delta y}{\Delta x} = \frac{y_2 - y_1}{x_2 - x_1}\\[1ex] &= \frac{1 - 8}{-2 - 5}\\[1ex] &= \frac{-7}{-7}\\[1ex] &= 1 \end{align*}

We see the slope is the same either way we choose the first and second points. We can now conclude that the slope of the line that passes through points $(-2, 1)$ and $(5, 8)$ is $1$.

Watch this video for more examples on calculating slope.

Now that we know what slope and $y$-intercepts are, we can determine the equation of a line given any two points on the line. There are two primary ways to write the equation of a line: point-slope form and slope-intercept form. We will first look at point-slope form.

#### Point-Slope form

The point-slope form of an equation that passes through the point $(x_1, y_1)$ with slope $m$ is the following:

$$\bbox[yellow, 5px]{\text{Point-Slope form:}\ \ y - y_1 = m(x - x_1).}$$
##### Example:

What is the equation of the line has slope $m = 2$ and passes through the point $(5, 4)$ in point-slope form?

Using the formula for the point-slope form of the equation of the line, we can just substitute the slope and point coordinate values directly. In other words, $m = 2$ and $(x_1, y_2) = (5, 4)$. So, the equation of the line is $$y - 4 = 2(x - 5).$$

##### Example:

Given two points, $(-3, -5)$ and $(2, 5)$, write the point-slope equation of the line that passes through them.

First, we calculate the slope: \begin{align*} m &= \frac{y_2 - y_1}{x_2 - x_1}\\[1ex] &= \frac{5 - (-5)}{2 - (-3)}\\[1ex] &= \frac{10}{5}\\[1ex] &= 2 \end{align*}

Graphically, we can verify the slope by looking at the change in $y$-values versus the change in $x$-values between the two points:

Graph of line passing through $(2, 5)$ and $(-3, -5)$.

We can now use one of the points along with the slope to write the equation of the line: \begin{align*} y - y_1 &= m(x - x_1) \\ y - 5 &= 2(x - 2) \quad\checkmark \end{align*}

We could also have used the other point to write the equation of the line: \begin{align*} y - y_1 &= m(x - x_1) \\ y - (-5) &= 2(x - (-3)) \\ y + 5 &= 2(x + 3) \quad\checkmark \end{align*}

But wait! Those two equations look different. How can they both describe the same line? If we simplify the equations, we see that they are indeed the same. Let's do just that: \begin{align*} y - 5 &= 2(x - 2) \\ y - 5 &= 2x - 4 \\ y - 5 + 5 &= 2x - 4 + 5 \\ y &= 2x + 1 \quad\checkmark \end{align*}
\begin{align*} y + 5 &= 2(x + 3) \\ y + 5 &= 2x + 6 \\ y + 5 - 5 &= 2x + 6 - 5 \\ y &= 2x + 1 \quad\checkmark \end{align*}

So, using either point to write the point-slope form of the equation results in the same "simplified" equation. We will see next that this simplified equation is another important form of linear equations.

#### Slope-Intercept form

Another way to express the equation of a line is slope-intercept form.

$$\bbox[yellow, 5px]{\text{Slope-Intercept form:}\ \ y = mx + b.}$$

In this equation, $m$ again is the slope of the line, and $(0, b)$ is the $y$-intercept. Like point-slope form, all we need are two points in order to write the equation that passes through them in slope-intercept form.

##### Constants vs. Variables

It is important to note that in the equation for slope-intercept form, the letters $a$ and $b$ are constant values, as opposed to the letters $x$ and $y$, which are variables. Remember, constants represent a "fixed" number - it does not change. A variable can be one of many values - it can change. A given line contains many points, each of which has a unique $x$ and $y$ value, but that line only has one slope-intercept equation with one value each for $m$ and $b$.

##### Example:

Given the same two points above, $(-3, -5)$ and $(2, 5)$, write the slope-intercept form of the equation of the line that passes through them.

We already calculated the slope, $m$, above to be $2$. We can then use one of the points to solve for $b$. Using $(2, 5)$, \begin{align*} y &= 2x + b \\ 5 &= 2(2) + b \\ 5 &= 4 + b \\ 1 &= b. \end{align*} So, the equation of the line in slope-intercept form is, $$y = 2x + 1.$$ The $y$-intercept of the line is $(0, b) = (0, 1)$. Look at the graph above to verify this is the $y$-intercept. At what point does the line cross the $y$-axis?

At first glance, it seems the point-slope and slope-intercept equations of the line are different, but they really do describe the same line. We can verify this by "simplifying" the point-slope form as such: \begin{align*} y - 5 &= 2(x - 2) \\ y - 5 &= 2x - 4 \\ y - 5 + 5 &= 2x - 4 + 5 \\ y &= 2x + 1 \\ \end{align*}

Watch this video for more examples on writing equations of lines in slope-intercept form.

### Horizontal and Vertical Lines

Now that we can write equations of lines, we need to consider two special cases of lines: horizontal and vertical. We claimed above that horizontal lines have slope $m = 0$, and that vertical lines have undefined slope. How can we use this to determine the equations of horizontal and vertical lines?

#### Vertical lines

• If two points have the same $x$-coordinates, only a vertical line can pass through both points.
• Each point on a vertical line has the same $x$-coordinate.
• If two points have the same $x$-coordinate, $c$, the equation of the line is $x = c$.
• The $x$-intercept of a vertical line $x = c$ is the point $(c, 0)$.
• Except for the line $x = 0$, vertical lines do not have a $y$-intercept.
##### Example:

Consider two points, $(2, 0)$ and $(2, 1)$. What is the equation of the line that passes through them?

Graph of line passing through points $(2, 0)$ and $(2, 1)$

First, note that the $x$-coordinate is the same for both points. In fact, if we plot any point from the line, we can see that the $x$-coordinate will be $2$. We know that only a vertical line can pass through the points, so the equation of that line must be $x = 2$.

But, how can we verify this algebraically? First off, what is the slope? We calculate slope as \begin{align*} m &= \frac{1 - 0}{2 - 2} \\[1ex] &= \frac{1}{0} \\[1ex] &= \text{undefined} \end{align*} In this case, the slope value is undefined, which makes it a vertical line.

##### Slope-intercept and point-slope forms

At this point, you might ask, "how can I write the equation of a vertical line in slope-intercept or point-slope form?" The answer is that you really can only write the equation of a vertical line one way. For vertical lines, $x$ is the same, or constant, for all values of $y$. Because $y$ could be any number for vertical lines, the variable $y$ does not appear in the equation of a vertical line.

#### Horizontal lines

• If two points have the same $y$-coordinates, only a horizontal line can pass through both points.
• Each point on a horizontal line has the same $y$-coordinate.
• If two points have the same $y$-coordinate, $b$, the equation of the line is $y = b$.
• The $y$-intercept of a horizontal line $y = b$ is the point $(0, b)$.
• Except for the line $y = 0$, horizontal lines do not have an $x$-intercept.
##### Example:

Consider two points, $(3, 4)$ and $(0, 4)$. What is the equation of the line that passes through them?

Graph of line passing through points $(3, 4)$ and $(0, 4)$

First, note that the $y$-coordinate is the same for both points. In fact, if we plot any point on the line, we can see that the $y$-coordinate is $4$. We know that only a horizontal line can pass through the points, so the equation of that line must be $y = 4$.

How can we verify this algebraically? First, calculate the slope: \begin{align*} m &= \frac{4 - 4}{0 - 3} \\[1ex] &= \frac{0}{-3} \\[1ex] &= 0 \end{align*} Then, using slope-intercept form, we can substitute $0$ for $m$, and solve for $y$: \begin{align*} y &= (0)x + b \\[1ex] &= b \end{align*} This tells us that every point on the line has $y$-coordinate $b.$ Since we know two points on the line have $y$-coordinate $4$, $b$ must be $4$, and so the equation of the line is $y = 4$.

##### Slope-intercept and Point-slope forms

Similar to vertical lines, the equation of a horizontal line can only be written one way. For horizontal lines, $y$ is the same for all values of $x$. Because $x$ could be any number for horizontal lines, the variable $x$ does not appear in the equation of a horizontal line.

### Parallel and Perpendicular lines

Now that we know how to characterize lines by their slope, we can identify if two lines are parallel or perpendicular by their slopes.

#### Parallel lines

In geometry, we are told that two distinct lines that do not intersect are parallel. Looking at the graph below, there are two lines that seem to never to intersect. What can we say about their slopes?

It appears that the lines above have the same slope, and that is correct. Non-vertical parallel lines have the same slope. Any two vertical lines, however, are also parallel. It is important to note that vertical lines have undefined slope.

#### Perpendicular lines

We know from geometry that perpendicular lines form an angle of $90^{\circ}$. The blue and red lines in the graph below are perpendicular. What do we notice about their slopes?

Even though this is one specific example, the relationship between the slopes applies to all perpendicular lines. Ignoring the signs for now, notice the vertical change in the blue line equals the horizontal change in the red line. Likewise, the the vertical change in the red line equals the horizontal change in the blue line. So, then, what are the slopes of these two lines? $$\text{slope of blue line} = \frac{-2}{1} = -2$$ $$\text{slope of red line} = \frac{1}{2}$$

The other fact to notice is that the signs of the slopes of the lines are not the same. The blue line has a negative slope and the red line has a positive slope. If we multiply the slopes, we get, $$-2 \times \frac{1}{2} = -1.$$ This inverse and negative relationship between slopes is true for all perpendicular lines, except horizontal and vertical lines.

Here is another example of two perpendicular lines:

$$\text{slope of blue line} = \frac{-2}{3}$$ $$\text{slope of red line} = \frac{3}{2}$$ $$\text{Product of slopes }= \frac{-2}{3} \cdot \frac{3}{2} = -1$$ Again, we see that the slopes of two perpendicular lines are negative reciprocals, and therefore, their product is $-1$. Recall that the reciprocal of a number is $1$ divided by the number. Let's verify this with the examples above:

The negative reciprocal of $-2$ is $-\frac1{-2} = \frac{1}{2} \ \checkmark$.

The negative reciprocal of $\frac1{2}$ is $-\frac1{\frac1{2}} = -2 \ \checkmark$.

The negative reciprocal of $-\frac{2}{3}$ is $-\frac1{-\frac{2}{3}} = \frac{3}{2} \ \checkmark$.

The negative reciprocal of $\frac{3}{2}$ is $-\frac1{\frac{3}{2}} = -\frac{2}{3} \ \checkmark$.

##### Two lines are perpendicular if one of the following is true:
• The product of their slopes is $-1$.
• One line is vertical and the other is horizontal.

Checkout this video for practice with parallel and perpendicular lines.

### Exercises

Calculate the slope of the line passing through the given points.

 1. $(2, 1)$ and $(6, 9)$ 2. $(-4, -2)$ and $(2, -3)$ 3. $(3, 0)$ and $(6, 2)$ 4. $(0, 9)$ and $(4, 7)$ 5. $(-2, \frac{1}{2})$ and $(-5, \frac{1}{2})$ 6. $(-5, -1)$ and $(2, 3)$ 7. $(-10, 3)$ and $(-10, 4)$ 8. $(-6, -4)$ and $(6, 5)$ 9. $(5, -2)$ and $(-4, -2)$

Find the slope of each of the following lines.

 10. $y - 2 = \frac{1}{2}(x - 2)$ 11. $y + 1 = x - 4$ 12. $y - \frac{2}{3} = 4(x + 7)$ 13. $y = -(x + 2)$ 14. $2x + 3y = 6$ 15. $y = -2x$ 16. $y = x$ 17. $y = 4$ 18. $x = -2$ 19. $x = 0$ 20. $y = -1$ 21. $y = 0$

Write the point-slope form of the equation of the line with the given slope and containing the given point.

 22. $m = 6$; $(2, 7)$ 23. $m = \frac{3}{5}$; $(9, 2)$ 24. $m = -5$; $(6, 2)$ 25. $m = -2$; $(-4, -1)$ 26. $m = 1$; $(-2, -8)$ 27. $m = -1$; $(-3, 6)$ 28. $m = \frac{4}{3}$; $(7, -1)$ 29. $m = \frac{7}{2}$; $(-3, 4)$ 30. $m = -1$; $(-1, -1)$

Write the point-slope form of the equation of the line passing through the given pair of points.

 31. $(1, 5)$ and $(4, 2)$ 32. $(3, 7)$ and $(4, 8)$ 33. $(-3, 1)$ and $(3, 5)$ 34. $(-2, 3)$ and $(3, 5)$ 35. $(5, 0)$ and $(0, -2)$ 36. $(-2, 0)$ and $(0, 3)$ 37. $(0, 0)$ and $(-1, 1)$ 38. $(1, 1)$ and $(3, 1)$ 39. $(3, 2)$ and $(3, -2)$

Exercises 40-48: Write the slope-intercept form of the equation of the line with the given slope and containing the given point in exercises 22-30.

Exercises 49-57: Write the slope-intercept form of the equation of the line passing through the given pair of points in exercises 31-39.

Solutions