Sub topic 10
Horizontal and vertical lines as special cases
This chapter assumes you can find a slope from two points, write y = mx + b, and solve a linear equation for one variable. It also assumes you have seen point-slope form, y - y1 = m(x - x1), and standard form, Ax + By = C.
Most lines you have worked with so far have a slope that is a nonzero number. Two families break that pattern. A horizontal line has slope 0. A vertical line has no slope at all. Both still fit standard form, but only the horizontal line fits point-slope form. This chapter shows why, how to write each equation, and how to avoid the usual mix-ups.
Horizontal lines: slope zero
A horizontal line stays at one height. Every point on it has the same y-coordinate, so the rise between any two points is 0.
Take the points (-1, 4) and (6, 4):
- slope = (4 - 4) / (6 - (-1)) = 0 / 7 = 0
Substitute m = 0 and the point (-1, 4) into point-slope form:
- y - 4 = 0(x - (-1))
- y - 4 = 0
- y = 4
The x term disappears because it is multiplied by 0. What remains says that y equals 4 no matter what x is. That is the equation of the line.
In standard form, y = 4 is 0x + 1y = 4. So A = 0, B = 1, and C = 4.
Intercepts of a horizontal line
The line y = 4 crosses the y-axis at (0, 4). It never reaches y = 0, so it has no x-intercept. The one exception is y = 0, which is the x-axis itself. Every point on it is an x-intercept.
Vertical lines: undefined slope
A vertical line stays at one x-value. Every point on it has the same x-coordinate, so the run between any two points is 0.
Take the points (3, -2) and (3, 5):
- slope = (5 - (-2)) / (3 - 3) = 7 / 0
Division by zero is undefined, so the line has no slope. This is different from a slope of 0. A slope of 0 is a real number. "Undefined" means no number fits.
Why there is no point-slope form
Point-slope form needs a number for m. A vertical line does not have one, so you cannot write y - y1 = m(x - x1) for it. Trying to force it fails:
- Any value you pick for m gives a line that is not vertical.
- Moving m toward "infinity" is not a legal replacement.
Describe the line by what stays fixed, which is x. Every point has x = 3, so the equation is:
- x = 3
In standard form, this is 1x + 0y = 3. So A = 1, B = 0, and C = 3.
Intercepts of a vertical line
The line x = 3 crosses the x-axis at (3, 0). It never reaches x = 0, so it has no y-intercept. The exception is x = 0, which is the y-axis.
Side-by-side comparison
| Property | Horizontal line | Vertical line |
|---|---|---|
| Example | y = 4 | x = 3 |
| What is constant | y | x |
| Slope | 0 | Undefined |
| Point-slope form | y - y1 = 0(x - x1), which simplifies to y = y1 | Does not exist |
| Slope-intercept form | y = 0x + 4 | Does not exist |
| Standard form (A, B, C) | (0, 1, 4) | (1, 0, 3) |
| x-intercept | None, unless the line is y = 0 | (3, 0) |
| y-intercept | (0, 4) | None, unless the line is x = 0 |
A vertical line is the only kind of line that has no slope-intercept form. That is why standard form matters. It is the one form that covers every straight line.
Reading the type from standard form
You can tell what kind of line you have by checking which coefficient is zero.
A and B cannot both be 0. If they were, the equation would be 0 = C, which is either never true or always true. It would not describe a line.
Here are three examples:
- 5x = 20 has B = 0. Divide by 5 to get x = 4, a vertical line.
- -3y = 9 has A = 0. Divide by -3 to get y = -3, a horizontal line.
- 2x - 3y = 6 has neither coefficient equal to 0. Its slope is -A/B = -2/(-3) = 2/3.
One formula that handles every case
The two-point method from the earlier chapter divides by x2 - x1, which fails for a vertical line. You can avoid the division by going straight to standard form. For points (x1, y1) and (x2, y2), use:
- A = y2 - y1
- B = x1 - x2
- C = A·x1 + B·y1
Then divide A, B, and C by their greatest common divisor and make A non-negative. If A is 0, make B positive.
from math import gcd
def standard_form(p, q):
"""Return (A, B, C) for the line through p and q, with A >= 0."""
(x1, y1), (x2, y2) = p, q
if p == q:
raise ValueError("need two different points")
a = y2 - y1
b = x1 - x2
c = a * x1 + b * y1
g = gcd(gcd(a, b), c)
a, b, c = a // g, b // g, c // g
if a < 0 or (a == 0 and b < 0):
a, b, c = -a, -b, -c
return a, b, c
def describe(a, b, c):
if b == 0:
return f"vertical: x = {c // a}"
if a == 0:
return f"horizontal: y = {c // b}"
return f"sloped: {a}x + {b}y = {c}"
for p, q in [((3, -2), (3, 5)), ((-1, 4), (6, 4)), ((1, 3), (4, 9))]:
abc = standard_form(p, q)
print(abc, describe(*abc))
# (1, 0, 3) vertical: x = 3
# (0, 1, 4) horizontal: y = 4
# (2, -1, -1) sloped: 2x + -1y = -1When the line is vertical, B comes out as 0. When it is horizontal, A comes out as 0. Nothing divides by zero. After dividing by the greatest common divisor, a vertical line has A = 1 and a horizontal line has B = 1, so c // a and c // b are exact.
Worked examples
A horizontal line through a point
Write the line through (2, -5) with slope 0.
- Use point-slope form: y - (-5) = 0(x - 2).
- Simplify: y + 5 = 0.
- Solve: y = -5.
The line is y = -5. In standard form it is 0x + 1y = -5.
A vertical line through a point
Write the line through (-3, 7) that is vertical.
A vertical line keeps its x-value, so the equation is x = -3. In standard form it is 1x + 0y = -3.
A line from two points that share a coordinate
Write the line through (6, 1) and (6, -4).
- The x-coordinates match, so the run is 0 and the line is vertical.
- Every point on the line has x = 6.
- The equation is x = 6.
Parallel and perpendicular cases
Horizontal and vertical lines also need special treatment when you compare slopes.
- Any two horizontal lines are parallel. Any two vertical lines are parallel, even though neither has a slope you can compare.
- Every horizontal line is perpendicular to every vertical line.
- The rule "perpendicular slopes are negative reciprocals" does not apply here. The reciprocal of 0 is undefined, and a vertical line has no slope to flip.
For example, the line perpendicular to y = 4 through (5, 2) is x = 5. The line parallel to x = 3 through (5, 2) is x = 5 as well.
Common errors
- Swapping the two equations. The line through (2, 4) that is horizontal is y = 4, not x = 4. Ask which coordinate stays the same along the line. Then write that variable, an equals sign, and the value.
- Saying a vertical line has slope 0. Slope 0 is horizontal. A vertical line has an undefined slope.
- Forcing a vertical line into y = mx + b. There is no such form. Write x = k.
- Dropping the variable. The line 3x = 12 is x = 4. It is not "4".
- Expecting two intercepts. A horizontal or vertical line usually has only one. If you look for the other one, you will divide by zero or get an impossible equation.
Practice
Exercise
Write the equation of the line through (4, -1) and (-2, -1). Then write it in standard form with A non-negative.
Show answer
Both points have y = -1, so the rise is 0 and the line is horizontal. The equation is y = -1. In standard form it is 0x + 1y = -1, so (A, B, C) = (0, 1, -1).
Exercise
Explain why the line through (5, 2) and (5, 9) has no point-slope form, and give its equation.
Show answer
The slope is (9 - 2) / (5 - 5) = 7 / 0, which is undefined. Point-slope form needs a number for m, so it cannot be written. Every point has x = 5, so the equation is x = 5, or 1x + 0y = 5 in standard form.
Exercise
The equation 6y = 30 is in the form Ax + By = C. What kind of line is it, and what are its intercepts?
Show answer
Here A = 0, so the line is horizontal. Dividing by 6 gives y = 5. The y-intercept is (0, 5). There is no x-intercept, because y is never 0.
Exercise
Write the line through (-3, 8) that is perpendicular to y = 2.
Show answer
The line y = 2 is horizontal, so a perpendicular line is vertical. It must pass through (-3, 8), so its equation is x = -3.