Sub topic 4
Writing an equation from a point and a slope
What this chapter covers
This chapter assumes you can plot points, compute slope as rise over run, work with y = mx + b, solve a linear equation for one variable, and do arithmetic with fractions and negative numbers. Here you will build the equation of a line when you know one point on it and its slope. You will then rewrite the result in slope-intercept and standard form, and check it.
Why start from a point
Slope-intercept form, y = mx + b, needs the y-intercept b. Problems often give a different point, such as (4, 7), and the intercept is not obvious. You could substitute into y = mx + b and solve for b, which works but takes an extra step. Point-slope form skips that step by building the known point into the equation.
The template
A line with slope m that passes through the point (x₁, y₁) has the equation:
y - y₁ = m(x - x₁)
Here x and y are the variables, so they stay as letters. The values x₁, y₁ and m are numbers you copy in from the problem.
The template follows from the definition of slope. Pick any other point (x, y) on the line. The slope between (x₁, y₁) and (x, y) is (y - y₁) / (x - x₁), and that must equal m. Multiply both sides by (x - x₁) and you get the template. The only point that the derivation excludes is (x₁, y₁) itself, because the division would be 0/0. That point satisfies the final equation anyway, since both sides become 0.
The procedure
- Write down m, x₁ and y₁.
- Substitute them into y - y₁ = m(x - x₁).
- Simplify the signs: subtracting a negative number becomes addition.
- Convert to another form only if the problem asks for it.
Worked example 1: positive values
Write the equation of the line with slope 2 through (1, 3).
Substitute m = 2, x₁ = 1, y₁ = 3:
y - 3 = 2(x - 1)
That is already a correct answer in point-slope form. To reach slope-intercept form, distribute and isolate y:
- y - 3 = 2x - 2
- y = 2x + 1
For standard form Ax + By = C, move the x term to the left side:
- -2x + y = 1
- Multiply by -1 so that A is not negative: 2x - y = -1
All three equations describe the same line.
Worked example 2: negative coordinates and a fractional slope
Write the equation of the line with slope -3/2 through (-2, 5).
Substitute m = -3/2, x₁ = -2, y₁ = 5:
y - 5 = -3/2 (x - (-2))
Subtracting -2 is the same as adding 2, so:
y - 5 = -3/2 (x + 2)
Slope-intercept form:
- y - 5 = -3/2 x - 3
- y = -3/2 x + 2
Standard form: multiply every term of y = -3/2 x + 2 by 2 to clear the fraction, which gives 2y = -3x + 4. Then move the x term to the left to get 3x + 2y = 4.
Check with the given point: 3(-2) + 2(5) = -6 + 10 = 4. ✓
Worked example 3: zero slope
Write the equation of the line with slope 0 through (3, -4).
y - (-4) = 0(x - 3), so y + 4 = 0, so y = -4.
The right side vanishes because anything times 0 is 0. A slope of 0 always gives a horizontal line, and y is constant. The x-coordinate of the given point does not appear in the answer.
Automating the conversion
The conversion to standard form has several steps where a sign or a fraction can go wrong. This function does them mechanically. It uses Fraction so that no rounding error creeps in. It clears denominators, divides by the greatest common divisor, and makes A non-negative.
from fractions import Fraction
from math import gcd
def point_slope_to_standard(m, x1, y1):
"""Convert y - y1 = m(x - x1) to Ax + By = C with integer A, B, C and A >= 0."""
m, x1, y1 = Fraction(m), Fraction(x1), Fraction(y1)
# y - y1 = m(x - x1) -> -m*x + y = y1 - m*x1
a, b, c = -m, Fraction(1), y1 - m * x1
# Clear denominators, then divide out the common factor.
den = a.denominator * c.denominator
a, b, c = int(a * den), int(b * den), int(c * den)
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
print(point_slope_to_standard(2, 1, 3)) # (2, -1, -1) -> 2x - y = -1
print(point_slope_to_standard(Fraction(-3, 2), -2, 5)) # (3, 2, 4) -> 3x + 2y = 4
print(point_slope_to_standard(Fraction(1, 2), 4, 1)) # (1, -2, 2) -> x - 2y = 2
print(point_slope_to_standard(0, 3, -4)) # (0, 1, -4) -> y = -4The first call reproduces example 1 and the second reproduces example 2. The fourth call shows the zero-slope case: A is 0, so the sign rule makes B positive instead.
Note the line a, b, c = -m, Fraction(1), y1 - m * x1. It is the algebra from the template: y - y₁ = mx - mx₁ rearranges to -mx + y = y₁ - mx₁.
Checking by substitution
A correct equation must be satisfied by the point you started with. It must also have the slope you were given. Both checks are cheap:
- Substitute (x₁, y₁) into your final equation. Both sides must be equal.
- Pick a second point from your equation, such as x = x₁ + 1, and confirm that y changes by exactly m.
For example 1, y = 2x + 1 gives y = 3 at x = 1, and y = 5 at x = 2. The change is 2, which is the slope.
Edge cases
- Fractional or decimal slope. The template works unchanged. Convert decimals to fractions (0.75 = 3/4) before clearing denominators, so the arithmetic stays exact.
- Point on an axis. If the point is (0, b), then x₁ = 0 and the template becomes y - b = mx, which is slope-intercept form. If the point is (a, 0), the template becomes y = m(x - a), which shows the x-intercept directly.
- Negative slope. Keep the minus sign with m when you substitute. A common slip is to write y - y₁ = -m(x - x₁) when m is already negative, which flips the slope's sign twice.
- Undefined slope. A vertical line has no slope, so there is no m to substitute. Its equation is x = x₁. The point-slope template cannot represent it, and a later chapter covers this case.
- Many equivalent answers. y - 3 = 2(x - 1) and y - 7 = 2(x - 3) both describe the same line, because (3, 7) is also on it. Any point on the line gives a valid point-slope form. When you compare your answer with a key, convert both to the same form first.
Summary table
| Given | Substitute | Result |
|---|---|---|
| m = 2, (1, 3) | y - 3 = 2(x - 1) | y = 2x + 1 |
| m = -3/2, (-2, 5) | y - 5 = -3/2 (x + 2) | 3x + 2y = 4 |
| m = 0, (3, -4) | y + 4 = 0 | y = -4 |
| m = 1/2, (4, 1) | y - 1 = 1/2 (x - 4) | x - 2y = 2 |
Exercise
Write the equation of the line with slope -4 that passes through (3, -1). Give it in point-slope form, then in standard form Ax + By = C with integer coefficients and A non-negative. Check your answer by substitution.
Show answer
Point-slope form: y - (-1) = -4(x - 3), which simplifies to y + 1 = -4(x - 3). Distribute: y + 1 = -4x + 12, so y = -4x + 11. Move the x term left: 4x + y = 11. Here A = 4, B = 1 and C = 11. Check: 4(3) + (-1) = 12 - 1 = 11, which matches C. A second point, x = 4, gives y = -5, and y dropped by 4 when x rose by 1, which matches the slope.
Exercise
A line has slope 2/3 and passes through (-6, 2). Write its equation in standard form with integer coefficients and A non-negative.
Show answer
Point-slope form: y - 2 = 2/3 (x + 6). Distribute: y - 2 = 2/3 x + 4, so y = 2/3 x + 6. Multiply by 3: 3y = 2x + 18. Move the x term left: -2x + 3y = 18. Multiply by -1 so that A is non-negative: 2x - 3y = -18. Check: 2(-6) - 3(2) = -12 - 6 = -18. ✓