Sub topic 4
Slope and collinearity
This chapter assumes you can plot points on the Cartesian plane, apply the distance formula, and solve linear equations in one and two variables. Slope is the first tool that describes a line's direction. Later chapters build on it for equations of lines, parallel and perpendicular tests, angles between lines, and areas.
What slope measures
The slope of a line is the change in y for each unit change in x. It is usually written m. For two points A(x₁, y₁) and B(x₂, y₂) with x₁ ≠ x₂:
m = (y₂ − y₁) / (x₂ − x₁)
The ratio is "rise over run". It does not matter which point you call A and which you call B, provided you subtract in the same order in the numerator and the denominator. Swapping both signs leaves the ratio unchanged.
Slope is the same for every pair of points on a given line. That is why one number describes the whole line.
def slope(p, q):
if p[0] == q[0]:
return None # vertical line: slope is undefined
return (q[1] - p[1]) / (q[0] - p[0])
print(slope((1, 2), (3, 8)))
print(slope((3, 8), (1, 2)))
print(slope((2, 5), (2, 9)))The first two calls print 3.0, which shows that the order of the points does not matter. The third prints None, because the line through (2, 5) and (2, 9) is vertical.
Reading the sign and size of the slope
The sign of m tells you the direction of the line when you read it left to right. The size of m tells you how steep it is.
| Slope | Line looks like | Angle with positive x-axis |
|---|---|---|
| m > 0 | rises to the right | acute (between 0° and 90°) |
| m = 0 | horizontal | 0° |
| m < 0 | falls to the right | obtuse (between 90° and 180°) |
| undefined | vertical | 90° |
The slope equals tan θ, where θ is the angle the line makes with the positive x-axis, measured anticlockwise. So a slope of 1 means 45°, a slope of √3 means 60°, and a slope of −1 means 135°. The next chapters on parallel lines and on the angle between lines rely on this link.
A larger absolute value of m means a steeper line. A line with m = −5 is steeper than one with m = 2, even though −5 is the smaller number.
Horizontal and vertical lines
These two cases cause most careless errors.
- A horizontal line has the same y for every point. Then y₂ − y₁ = 0, so m = 0. Its equation is y = k.
- A vertical line has the same x for every point. Then the denominator x₂ − x₁ = 0, so the slope is undefined. Its equation is x = k.
Do not say a vertical line has "slope zero" or "infinite slope" in a working. Say it is undefined, and handle it as a separate case.
Collinearity: three points on one line
Points are collinear if one straight line passes through all of them. For three points A, B, C, this holds exactly when the slope of AB equals the slope of BC. Both segments share the point B, so equal slopes force them onto the same line.
The test:
slope(AB) = slope(BC)
For example, take A(1, 2), B(3, 6), C(5, 10). Then slope(AB) = (6 − 2)/(3 − 1) = 2 and slope(BC) = (10 − 6)/(5 − 3) = 2. The slopes match, so the points are collinear.
Now change C to (5, 11). Then slope(BC) = (11 − 6)/(5 − 3) = 2.5, which differs from 2. The points are not collinear.
Avoiding division in the test
Dividing can fail when a segment is vertical, and fractions invite arithmetic slips. Cross-multiplying avoids both problems. The condition
(y₂ − y₁)/(x₂ − x₁) = (y₃ − y₂)/(x₃ − x₂)
becomes
(y₂ − y₁)(x₃ − x₂) = (y₃ − y₂)(x₂ − x₁)
This version holds even when two of the points share an x-coordinate.
def collinear(a, b, c):
return (b[1] - a[1]) * (c[0] - b[0]) == (c[1] - b[1]) * (b[0] - a[0])
print(collinear((1, 2), (3, 6), (5, 10)))
print(collinear((1, 2), (3, 6), (5, 11)))
print(collinear((4, 1), (4, 7), (4, -3)))The output is True, False, True. The third case is three points on the vertical line x = 4. A division-based test would crash on it.
Two other ways to test collinearity
CAT questions often allow a faster route than computing slopes.
- Distance test. Three points are collinear if the largest of the three distances equals the sum of the other two. For example, AB + BC = AC means B lies between A and C on a line. This is useful when the distances are already known from an earlier part of the question.
- Area test. Three points are collinear if the triangle they form has zero area. The shoelace formula in a later chapter makes this a single calculation and also works when the coordinates contain unknowns.
Finding an unknown coordinate
Many CAT questions give three points, one with an unknown coordinate, and state they are collinear. Set the two slopes equal and solve.
Suppose A(2, 3), B(4, 7), and C(6, k) are collinear. Then slope(AB) = (7 − 3)/(4 − 2) = 2. The slope from B to C must also be 2:
(k − 7)/(6 − 4) = 2
k − 7 = 4, so k = 11.
A shortcut: when the x-values are evenly spaced, the y-values must change by the same amount. The x-values go 2, 4, 6, so the y-values form an arithmetic progression: 3, 7, 11. This gives k = 11 without any slope calculation.
Slope and the ratio of division
Collinear points connect directly to the section formula from the previous chapter. If P divides AB in the ratio m:n, then P lies on line AB. So the slope of AP equals the slope of AB. This is a useful check on an answer. If you compute a section point and the slope from A to that point does not match slope(AB), you made an error.
Slope from other information
The slope can come from sources other than two points.
- From an angle. If the line makes angle θ with the positive x-axis, then m = tan θ.
- From the equation. A line written as y = mx + c has slope m. A line written as ax + by + c = 0 has slope −a/b, provided b ≠ 0. The next chapter on equations of lines explains why.
- From a description. A line that "rises 3 units for every 4 units to the right" has m = 3/4.
import math
def slope_from_angle(degrees):
return math.tan(math.radians(degrees))
def slope_from_general(a, b):
# line ax + by + c = 0, requires b != 0
return -a / b
print(round(slope_from_angle(45), 6))
print(round(slope_from_angle(135), 6))
print(slope_from_general(3, 4))The output is 1.0, −1.0, and −0.75. The line 3x + 4y − 10 = 0 falls to the right, so a negative slope is correct.
Common errors
- Mismatched order. Computing (y₂ − y₁)/(x₁ − x₂) flips the sign. Write the points in a column and subtract in the same direction for both coordinates.
- Dividing by zero. Check whether x₁ = x₂ before using the slope formula.
- Comparing the wrong pairs. The slope test needs a shared point. Comparing slope(AB) with slope(CD) for four points tests whether the lines are parallel, not whether they are the same line. Two lines with equal slopes that do not share a point are parallel and distinct.
- Confusing "steeper" with "greater". Compare absolute values for steepness, signed values for direction.
- Using tan θ for an obtuse angle without sign care. For θ = 120°, tan θ = −√3, so the line falls to the right.
Summary of the method
- Compute slope as rise over run, subtracting in a consistent order.
- Treat vertical lines separately, since their slope is undefined.
- For collinearity, use equal slopes between pairs that share a point, or cross-multiply to avoid division.
- When coordinates are evenly spaced, look for an arithmetic progression in the y-values.
- Use the distance or area test when that information is already in hand.
Exercise
The points P(1, 4), Q(3, k) and R(7, 12) are collinear. Find k, and state the slope of the line.
Show answer
Slope of PR = (12 − 4)/(7 − 1) = 8/6 = 4/3. Since Q lies on the same line, slope of PQ = (k − 4)/(3 − 1) = 4/3, so k − 4 = 8/3 and k = 20/3. The slope of the line is 4/3.
Exercise
A line passes through (2, 1) and makes an angle of 135° with the positive x-axis. Does it pass through (6, −3)? Give the slope you used.
Show answer
The slope is tan 135° = −1. The slope from (2, 1) to (6, −3) is (−3 − 1)/(6 − 2) = −4/4 = −1. The slopes match and the two points share (2, 1), so the line passes through (6, −3).
Exercise
For what value of t are the points A(t, 2), B(3, 5) and C(3, 9) collinear?
Show answer
B and C share x = 3, so the line through them is vertical (x = 3). A must lie on it, so t = 3. A slope-based test would divide by zero for BC, so the vertical case has to be handled directly.