Sub topic 5
Writing the equation of a line
This chapter assumes you can compute the slope of a line from two points and can solve two linear equations in two unknowns. The slope of the line through (x1, y1) and (x2, y2) is m = (y2 − y1) / (x2 − x1), and it is undefined when x1 = x2.
What an equation of a line means
A point (x, y) lies on a line exactly when its coordinates satisfy the line's equation. Every non-degenerate line can be written as a linear equation in x and y, and every linear equation in x and y describes a line. CAT questions give you a line in different ways: a slope and a point, two points, two intercepts, or a description such as "perpendicular to...". Each way has a form that makes the equation quick to write.
| Form | Equation | Use it when you know |
|---|---|---|
| Slope-intercept | y = mx + c | the slope m and the y-intercept c |
| Point-slope | y − y1 = m(x − x1) | the slope and one point |
| Two-point | (y − y1)(x2 − x1) = (y2 − y1)(x − x1) | two points on the line |
| Intercept | x/a + y/b = 1 | both intercepts, a on the x-axis and b on the y-axis |
| General | ax + by + c = 0 | nothing in particular; it is the standard final form |
Slope-intercept form
The form y = mx + c says that y changes by m units for every 1 unit of x, and that the line crosses the y-axis at (0, c). The y-intercept is the y-coordinate where the line meets the y-axis. Setting x = 0 gives it directly.
Example: a line has slope −2 and passes through (0, 5). Then y = −2x + 5.
This form cannot describe a vertical line, because a vertical line has no slope. A vertical line is written x = k, and a horizontal line is y = k.
Point-slope form
If the line has slope m and passes through (x1, y1), then any other point (x, y) on it has slope m relative to (x1, y1):
(y − y1) / (x − x1) = m, which rearranges to y − y1 = m(x − x1).
Example: slope 3 through (2, −1).
y + 1 = 3(x − 2), so y = 3x − 7.
This is the most useful form in practice. Slope-intercept form is a special case of it with the point (0, c).
Two-point form
When two points are given, find the slope first, then use point-slope form with either point.
Example: the line through A(1, 2) and B(5, 10).
- m = (10 − 2) / (5 − 1) = 2.
- Use A: y − 2 = 2(x − 1), so y = 2x.
Check with B: 2 × 5 = 10, which matches. Checking the second point is a cheap way to catch arithmetic slips.
The cross-multiplied version in the table, (y − y1)(x2 − x1) = (y2 − y1)(x − x1), has the advantage that it also works when x1 = x2. In that case it reduces to x = x1, the vertical line.
Intercept form
The x-intercept is where the line meets the x-axis (y = 0), and the y-intercept is where it meets the y-axis (x = 0). If these are a and b, the line passes through (a, 0) and (0, b), and its equation is
x/a + y/b = 1.
Example: intercepts 4 and 3 give x/4 + y/3 = 1, which is 3x + 4y = 12.
The form also gives a fast area result. The line and the two axes enclose a right triangle with legs |a| and |b|, so its area is |ab| / 2. For the line above, the area is 4 × 3 / 2 = 6.
Intercept form fails for lines through the origin (both intercepts are 0) and for lines parallel to an axis (one intercept does not exist).
General form
The general form is ax + by + c = 0, where a and b are not both zero. It handles every line, including vertical and horizontal ones. From it you can read off:
- slope = −a / b (when b ≠ 0)
- x-intercept = −c / a (when a ≠ 0)
- y-intercept = −c / b (when b ≠ 0)
Example: 3x + 4y − 12 = 0 has slope −3/4, x-intercept 4, and y-intercept 3.
Multiplying every term by the same non-zero number gives the same line. So 3x + 4y − 12 = 0 and 6x + 8y − 24 = 0 are one line. Keep this in mind when comparing two equations. Two lines are the same line only when their coefficients are in proportion, including the constant term.
Converting between forms
def from_two_points(p, q):
# returns (a, b, c) for the line ax + by + c = 0 through p and q
(x1, y1), (x2, y2) = p, q
a = y2 - y1
b = x1 - x2
c = -(a * x1 + b * y1)
return a, b, c
def describe(a, b, c):
slope = -a / b if b != 0 else None
x_int = -c / a if a != 0 else None
y_int = -c / b if b != 0 else None
return slope, x_int, y_int
a, b, c = from_two_points((1, 2), (5, 10))
print(a, b, c)
print(describe(a, b, c))This prints 8 -4 0 followed by (2.0, -0.0, -0.0). The line 8x − 4y = 0 is y = 2x, as found earlier. The negative zeros are a display artifact of floating point and mean 0.
The helper builds the general form straight from two points. It uses a = y2 − y1 and b = x1 − x2, so a vertical line (x1 = x2) gives b = 0 and no division is needed.
Choosing a form
A short rule: start from the form that needs the least work given your data, and finish by converting to general form so later steps (distance to a point, intersections, parallel and perpendicular tests) can use the coefficients directly.
Lines with a parameter
CAT questions often give a family of lines, such as y = mx + 3 or kx + y = 5, and ask for a value of the parameter. The method is to substitute the known condition.
Example: for what value of k does the line kx + 2y = 10 pass through (2, 3)?
Substitute: 2k + 6 = 10, so k = 2.
Example: the line x/a + y/b = 1 passes through (2, 3) and has equal intercepts a = b. Then 2/a + 3/a = 1, so a = 5 and the line is x + y = 5.
For equal intercepts, always check the case of a line through the origin. The line y = 1.5x passes through (2, 3) and has both intercepts equal to 0. Whether that case counts depends on the wording of the question.
Common errors
- Using slope-intercept form for a vertical line. The line x = 4 has no slope. Write it as x = 4.
- Losing a sign when moving terms. In y − y1 = m(x − x1), a negative y1 gives a plus sign: y − (−1) = y + 1.
- Reading the slope as a rather than −a / b from ax + by + c = 0. The slope of 2x + 3y = 6 is −2/3, not 2.
- Using intercept form when an intercept is zero, which would mean dividing by zero.
- Mixing up which intercept goes under x and which under y. The x-intercept a goes under x.
A worked CAT-style problem
Find the equation of the line that passes through (2, 3) and cuts off equal positive lengths from the two axes.
Equal positive intercepts mean a = b > 0, so the line is x/a + y/a = 1, or x + y = a. Substituting (2, 3) gives a = 5. The line is x + y = 5, or x + y − 5 = 0. The check: the intercepts are both 5, and 2 + 3 = 5.
Exercises
Exercise
Write the equation of the line through (−1, 4) and (3, −4) in general form, and give its slope and both intercepts.
Show answer
Slope = (−4 − 4) / (3 − (−1)) = −8/4 = −2. Using (−1, 4): y − 4 = −2(x + 1), so y = −2x + 2, which is 2x + y − 2 = 0. The slope is −2, the y-intercept is 2, and the x-intercept is 1. Check with (3, −4): 2(3) + (−4) − 2 = 0.
Exercise
A line has x-intercept 6 and y-intercept −4. Write its equation and find the area of the triangle it forms with the axes.
Show answer
Intercept form gives x/6 + y/(−4) = 1. Multiplying by 12 gives 2x − 3y = 12, or 2x − 3y − 12 = 0. The triangle has legs 6 and 4, so its area is 6 × 4 / 2 = 12.
Exercise
For what value of k does the line 3x + ky = 12 have slope −1/2?
Show answer
The slope is −3/k. Setting −3/k = −1/2 gives k = 6. The line is 3x + 6y = 12, which is x + 2y = 4, with slope −1/2.