Sub topic 6
Perpendicular slopes are negative reciprocals
This chapter proves one algebraic test for perpendicular lines and shows how to use it safely. It assumes you can compute a slope from two points, work with fractions, and recognize a right angle. Slope was reviewed earlier in this tutorial, and you saw that parallel lines share a slope. Here you will see why perpendicular lines follow a different rule.
The rule
Two non-vertical lines with slopes m₁ and m₂ are perpendicular exactly when
m₁ · m₂ = −1
Equivalently, m₂ = −1/m₁. The slope of one line is the negative reciprocal of the other. To build a negative reciprocal, do two things:
- Flip the fraction (take the reciprocal).
- Change the sign.
| Slope m | Reciprocal | Negative reciprocal (perpendicular slope) |
|---|---|---|
| 2 | 1/2 | −1/2 |
| −3 | −1/3 | 1/3 |
| 3/4 | 4/3 | −4/3 |
| −5/2 | −2/5 | 2/5 |
| 0 | undefined | vertical line, slope undefined |
| undefined (vertical) | none | 0 |
The last two rows are special cases. They are covered in their own chapter, but the code below already handles them.
Why the rule holds: a rotation argument
Slope is rise over run, so a line with slope m has the direction vector (1, m). Moving 1 unit right moves you m units up.
A perpendicular line points along the original direction turned by 90°. Rotating a vector (x, y) by 90° counterclockwise gives (−y, x). Apply that to (1, m):
(1, m) → (−m, 1)
The rotated vector has run −m and rise 1, so its slope is
1 / (−m) = −1/m
That is the negative reciprocal. The flip comes from swapping the roles of x and y. The sign change comes from the rotation sending the old y-value to a negative x-value.
Rotating clockwise gives (m, −1), with slope −1/m again. Either direction gives the same line direction.
Why the rule holds: a Pythagorean argument
The rotation argument relies on a formula for rotating vectors. This second proof uses only the Pythagorean theorem and distances.
Translating a line does not change its slope, so you can move both lines until they cross at the origin O. Let the first line have slope m and the second have slope n. Pick the points P = (1, m) on the first line and Q = (1, n) on the second.
The lines are perpendicular exactly when angle POQ is a right angle. By the Pythagorean theorem and its converse, that happens exactly when OP² + OQ² = PQ².
- OP² = 1² + m² = 1 + m²
- OQ² = 1 + n²
- PQ² = (m − n)², because P and Q share x = 1 and differ only in height.
Set up the equation:
(1 + m²) + (1 + n²) = (m − n)²
2 + m² + n² = m² − 2mn + n²
2 = −2mn
mn = −1
Every step is reversible, so this proves both directions. Perpendicular lines have slopes that multiply to −1, and slopes that multiply to −1 give perpendicular lines.
What the rule says about signs
If m₁ · m₂ = −1, the product is negative, so the two slopes have opposite signs. One line rises from left to right and the other falls. This gives a quick sanity check. Two lines that both rise cannot be perpendicular.
The magnitudes are reciprocals. A steep line (large |m|) pairs with a shallow line (small |m|). Slope 10 pairs with −1/10. The special case |m| = 1 pairs with itself in magnitude: slope 1 pairs with slope −1, which gives the 45° diagonals that cross at a right angle.
Worked example: testing two lines
Line 1 passes through A(−2, 1) and B(4, 3). Line 2 passes through C(0, 5) and D(1, 2). Are they perpendicular?
- Slope of line 1: (3 − 1) / (4 − (−2)) = 2/6 = 1/3.
- Slope of line 2: (2 − 5) / (1 − 0) = −3.
- Product: (1/3)(−3) = −1.
The product is −1, so the lines are perpendicular. The negative reciprocal of 1/3 is −3, which matches.
A second case: A line through (1, 2) and (5, 5) has slope 3/4. A line with slope 4/3 is not perpendicular to it. The product is 1, not −1, because the sign was never changed. The correct partner is −4/3.
Testing in code
Use exact fractions, not floating-point numbers. A product like 0.1 · (−10) might print as −1.0, but other pairs can land at −0.9999999999999999, and == then reports "not perpendicular". The Fraction type from Python's standard library avoids this.
from fractions import Fraction
def slope(p, q):
(x1, y1), (x2, y2) = p, q
if x1 == x2:
return None # vertical line, slope undefined
return Fraction(y2 - y1, x2 - x1)
def classify(m1, m2):
if m1 is None and m2 is None:
return "parallel (or the same line)"
if m1 is None:
return "perpendicular" if m2 == 0 else "neither"
if m2 is None:
return "perpendicular" if m1 == 0 else "neither"
if m1 == m2:
return "parallel (or the same line)"
if m1 * m2 == -1:
return "perpendicular"
return "neither"
print(classify(slope((-2, 1), (4, 3)), slope((0, 5), (1, 2)))) # perpendicular
print(classify(slope((0, 1), (1, 3)), slope((0, 0), (4, -2)))) # perpendicular
print(classify(slope((1, 2), (5, 5)), Fraction(4, 3))) # neitherThe function checks for None before multiplying, because a vertical line has no slope to multiply.
A test that avoids slopes entirely
The rotation argument suggests another test. Take each line's direction vector (dx, dy) = (x₂ − x₁, y₂ − y₁). Two lines are perpendicular exactly when the dot product of their direction vectors is zero:
dx₁·dx₂ + dy₁·dy₂ = 0
With slopes m₁ = dy₁/dx₁ and m₂ = dy₂/dx₂, dividing the equation by dx₁·dx₂ gives 1 + m₁m₂ = 0, which is the same rule. The vector form needs no division, so it has no special case for vertical lines.
def perpendicular(p1, q1, p2, q2):
dx1, dy1 = q1[0] - p1[0], q1[1] - p1[1]
dx2, dy2 = q2[0] - p2[0], q2[1] - p2[1]
return dx1 * dx2 + dy1 * dy2 == 0
print(perpendicular((-2, 1), (4, 3), (0, 5), (1, 2))) # True
print(perpendicular((0, 0), (0, 4), (1, 1), (6, 1))) # True: vertical vs horizontal
print(perpendicular((0, 0), (1, 1), (0, 0), (1, 2))) # FalseThis version works with integer coordinates and gives exact answers. It does assume each pair of points is distinct. Two identical points give a zero vector, and a zero vector is "perpendicular" to everything under this test, which is meaningless for a line.
Reading the slope from different equation forms
The rule applies to the slope, so first get the slope out of the equation.
- Slope-intercept form y = mx + b: the slope is m directly.
- Point-slope form y − y₀ = m(x − x₀): the slope is m.
- Standard form Ax + By = C with B ≠ 0: solve for y to get y = −(A/B)x + C/B, so the slope is −A/B.
For standard form, the perpendicular slope is the negative reciprocal of −A/B, which is B/A. The coefficients swap places and the minus sign disappears. The line 3x + 4y = 7 has slope −3/4, and any line perpendicular to it has slope 4/3. A perpendicular line can be written as 4x − 3y = k for some constant k, since that form has slope 4/3.
Common errors
- Flipping without changing the sign. The reciprocal of 3/4 is 4/3, but the perpendicular slope is −4/3. Check by multiplying: (3/4)(4/3) = 1, not −1.
- Changing the sign without flipping. The opposite of 3/4 is −3/4, which is not perpendicular to slope 3/4. The product is −9/16.
- Confusing parallel with perpendicular. Parallel lines have equal slopes (m₁ = m₂). Perpendicular lines have slopes whose product is −1. Never mix the two checks.
- Reading the slope from standard form incorrectly. In 2x + 5y = 10, the slope is −2/5, not 2/5 and not 2. Solve for y first.
- Rounding. A decimal like 0.333 is not 1/3. The product 0.333 × (−3) is −0.999, which fails the exact test. Keep fractions exact.
- Dividing by zero. The expression −1/m fails when m = 0. A horizontal line has a vertical perpendicular, which has no slope. Handle this case before calculating.
Edge cases to keep in mind
A horizontal line (slope 0) and a vertical line (undefined slope) are always perpendicular. The product rule cannot show this, because undefined times 0 is meaningless. This is why the flowchart branches on vertical lines before multiplying.
Two vertical lines are parallel, not perpendicular. A vertical line and a line with any nonzero slope are never perpendicular.
The rule describes direction, not position. Two perpendicular lines always meet at exactly one point. The test says nothing about where that point is. To find it, solve the two line equations together.
Summary of the working model
Perpendicular slopes multiply to −1. That means flip the fraction, change the sign, and check the product. The proof comes from a 90° rotation, which sends direction (1, m) to (−m, 1), or from the Pythagorean theorem applied to points on x = 1. In code, use exact fractions or the dot-product test, and handle vertical and horizontal lines before dividing.
Exercise
Line L has equation 6x − 9y = 18. (a) What is the slope of L? (b) What slope must a line perpendicular to L have? (c) Is the line through (2, 1) and (−1, 7) perpendicular to L?
Show answer
(a) Solve for y: −9y = −6x + 18, so y = (2/3)x − 2. The slope is 2/3. (b) The negative reciprocal of 2/3 is −3/2. (c) The slope through (2, 1) and (−1, 7) is (7 − 1)/(−1 − 2) = 6/(−3) = −2. The product (2/3)(−2) = −4/3 is not −1, so the lines are not perpendicular. A perpendicular line would need slope −3/2.
Exercise
Use the vector test to decide whether the line through (0, 0) and (3, 6) is perpendicular to the line through (4, 1) and (6, 0). Then explain why the vector test needs no special case for vertical lines.
Show answer
The first direction vector is (3, 6) and the second is (2, −1). The dot product is 3·2 + 6·(−1) = 0, so the lines are perpendicular. The slopes confirm it: 2 and −1/2 multiply to −1. The vector test needs no special case because it never divides by dx. A vertical line has dx = 0, and the dot product handles that without any problem. For example, (0, 4) · (5, 0) = 0, so a vertical and a horizontal line are correctly reported as perpendicular.