Sub topic 13
Parallel and perpendicular lines
This chapter assumes you can compute a slope from two points, read m and b from y = mx + b, and write a line's equation from a slope and a point. You should also be comfortable with fractions and signed numbers. Here you use slope as a test: two slopes tell you whether lines never meet, meet at a right angle, or do neither.
Parallel lines
Two lines in a plane are parallel if they never intersect. Slope measures steepness, so lines with the same steepness and direction keep a constant distance apart.
For non-vertical lines, y = m1·x + b1 and y = m2·x + b2 are parallel exactly when:
m1 = m2, andb1 ≠ b2.
The second condition matters. If both the slopes and the intercepts match, the equations describe the same line. That is one line written twice, not two parallel lines.
| Line 1 | Line 2 | Relationship |
|---|---|---|
| y = 3x + 2 | y = 3x − 5 | Parallel (same slope, different intercept) |
| y = 3x + 2 | y = 3x + 2 | Same line |
| y = 3x + 2 | y = −3x + 2 | Neither (they cross at (0, 2)) |
| x = 1 | x = 4 | Parallel (both vertical) |
Vertical lines have undefined slope, so the rule m1 = m2 does not apply to them. Any two vertical lines are parallel, and any two horizontal lines (slope 0) are parallel.
Why equal slopes mean no intersection
Suppose the lines meet at some x. Then m·x + b1 = m·x + b2. Subtracting m·x from both sides leaves b1 = b2. If the intercepts differ, this is a false statement, so no x satisfies it and the lines never meet. If the slopes differ, m1·x + b1 = m2·x + b2 solves to x = (b2 − b1)/(m1 − m2), which always exists, so the lines meet at exactly one point.
Perpendicular lines
Two lines are perpendicular if they meet at a 90° angle. For non-vertical, non-horizontal lines, this happens exactly when the slopes are negative reciprocals:
m1 · m2 = −1, which gives m2 = −1/m1.
To build the negative reciprocal, flip the fraction and change the sign:
| Slope | Negative reciprocal |
|---|---|
| 2 | −1/2 |
| −3/4 | 4/3 |
| 5 | −1/5 |
| −1 | 1 |
Why the negative reciprocal
Move along a line with slope m by a run of 1. The rise is m, so the direction is the vector (1, m). Rotating a vector (a, b) by 90° counter-clockwise gives (−b, a). Applied here, the rotated direction is (−m, 1). Its slope is rise over run, which is 1 / (−m) = −1/m.
So rotating by 90° swaps the roles of rise and run and flips one sign. That is the whole rule. The product m · (−1/m) is always −1.
The horizontal and vertical exception
The rule m1 · m2 = −1 cannot cover one case. A horizontal line has slope 0, and 0 has no reciprocal. A vertical line has undefined slope. These two directions are perpendicular to each other.
y = 4(horizontal) is perpendicular tox = −2(vertical).- Any line perpendicular to a horizontal line is vertical, and the reverse.
Writing an equation for a parallel or perpendicular line
The usual task is: "Find the line through a given point that is parallel (or perpendicular) to a given line." The method has three steps.
- Find the slope of the given line.
- Compute the new slope: the same slope for parallel, the negative reciprocal for perpendicular.
- Use the point to solve for
biny = mx + b, or use point-slope form.
Worked example: parallel
Find the line through (2, −1) that is parallel to y = 3x + 5.
- The slope of the given line is 3.
- A parallel line has slope 3.
- Substitute the point into
y = 3x + b:−1 = 3(2) + b, sob = −7.
The answer is y = 3x − 7.
Worked example: perpendicular
Find the line through (4, 1) that is perpendicular to y = 2x + 1.
- The slope of the given line is 2.
- The negative reciprocal is −1/2.
- Substitute the point into
y = −(1/2)x + b:1 = −(1/2)(4) + b, so1 = −2 + bandb = 3.
The answer is y = −(1/2)x + 3. The two lines cross where 2x + 1 = −(1/2)x + 3, which gives x = 0.8 and y = 2.6. You can verify this by substituting into both equations.
Starting from standard form
If the given line is in standard form, find its slope first. Solving Ax + By = C for y gives y = (−A/B)x + C/B, so the slope is −A/B. For 3x − y = 4, we have A = 3 and B = −1, so the slope is −3/(−1) = 3. That is the line used in the parallel example above.
Testing standard-form lines without dividing
Dividing by B fails when B = 0, which is exactly the vertical case. You can avoid the problem by comparing coefficients directly. For lines A1x + B1y = C1 and A2x + B2y = C2:
| Test | Condition |
|---|---|
| Same direction (parallel or identical) | `A1·B2 = A2·B1` |
| Identical lines | `A1·C2 = A2·C1` and `B1·C2 = B2·C1` as well |
| Perpendicular | `A1·A2 + B1·B2 = 0` |
The parallel test is the slope equality −A1/B1 = −A2/B2 with both sides multiplied by B1·B2. The perpendicular test is (−A1/B1)(−A2/B2) = −1 rearranged the same way. Neither version divides, so vertical and horizontal lines work without special cases.
def relation(line1, line2):
"""Classify two lines given in standard form (A, B, C) for Ax + By = C."""
A1, B1, C1 = line1
A2, B2, C2 = line2
if A1 * B2 == A2 * B1:
if A1 * C2 == A2 * C1 and B1 * C2 == B2 * C1:
return "same line"
return "parallel"
if A1 * A2 + B1 * B2 == 0:
return "perpendicular"
return "neither"
print(relation((2, -1, -1), (1, 2, 8))) # y = 2x + 1 and x + 2y = 8
print(relation((2, 3, 6), (4, 6, 12))) # 2x + 3y = 6 and 4x + 6y = 12
print(relation((2, 3, 6), (2, 3, 9))) # same slope, different intercept
print(relation((1, 0, 1), (1, 0, 3))) # x = 1 and x = 3
print(relation((1, 0, 1), (0, 1, 5))) # x = 1 and y = 5
print(relation((1, 1, 0), (1, 2, 0))) # crossing at the originRunning it prints:
perpendicular
same line
parallel
parallel
perpendicular
neitherThe inputs must be integers or fractions. With floats, the equality checks can fail because of rounding, such as 0.1 + 0.2 != 0.3.
Building the new line in code
This function takes a slope and a point and returns the perpendicular line through that point. It uses Fraction so the result is exact.
from fractions import Fraction
def perpendicular_through(m, x0, y0):
"""Return the line through (x0, y0) perpendicular to a line of slope m."""
m = Fraction(m)
if m == 0:
return f"x = {x0}" # perpendicular to a horizontal line is vertical
new_m = -1 / m
b = y0 - new_m * x0
return f"y = {new_m}x + {b}"
print(perpendicular_through(2, 4, 1)) # y = -1/2x + 3
print(perpendicular_through(Fraction(-3, 4), 0, 5)) # y = 4/3x + 5
print(perpendicular_through(0, 7, 2)) # x = 7For a parallel line, reuse the slope and compute b = y0 - m * x0.
Deciding which test to use
The flowchart summarizes the order of checks for two lines given in slope-intercept form, including the vertical cases.
Common errors
- Calling a repeated line parallel. Equal slopes with equal intercepts give one line. Check
bbefore answering "parallel". - Forgetting the sign change. The reciprocal of 3/5 is 5/3, but the negative reciprocal is −5/3.
- Applying the product rule to vertical lines.
x = 2has no slope to multiply. Use the horizontal/vertical special case. - Reading the slope from standard form without rearranging. In
2x + 3y = 6, the number multiplying x is not the slope. The slope is−A/B = −2/3. - Taking the intercept from the old line. The new line passes through the given point, so solve for
bagain. Copying the oldbonly works if the point happens to lie on the old line. - Rounding slopes before testing. A slope of 1/3 written as 0.33 is not exactly 1/3, so a product-equals-−1 check fails. Keep fractions exact.
Exercises
Exercise
Line P has the equation y = (2/5)x − 3. Line Q passes through (5, 1) and (0, 3.5). Are P and Q parallel, perpendicular, or neither?
Show answer
The slope of P is 2/5. The slope of Q is (3.5 − 1)/(0 − 5) = 2.5/(−5) = −1/2. The product is (2/5)(−1/2) = −1/5, which is not −1, and the slopes are not equal, so the lines are neither parallel nor perpendicular.
Exercise
Find the equation of the line through (−3, 4) that is perpendicular to 4x + 2y = 9.
Show answer
Solving for y gives y = −2x + 9/2, so the slope is −2. The negative reciprocal is 1/2. Substitute the point into y = (1/2)x + b: 4 = (1/2)(−3) + b, so b = 4 + 3/2 = 11/2. The line is y = (1/2)x + 11/2.
Exercise
For which value of k is the line kx + 3y = 7 perpendicular to the line 2x − y = 5?
Show answer
Use A1·A2 + B1·B2 = 0 with (k, 3) and (2, −1): 2k − 3 = 0, so k = 3/2. Check: the first line has slope −k/3 = −1/2, the second has slope 2, and their product is −1.
Exercise
Two lines are y = mx + 4 and y = 6x + b. Give the conditions on m and b that make them the same line, and the conditions that make them parallel but distinct.
Show answer
Same line: m = 6 and b = 4. Parallel but distinct: m = 6 and b ≠ 4.