What is the equation of a line?
The equation of a line is a rule that every point on the line satisfies. A non-vertical line can be written in several equivalent forms, and each is useful for a different job. The slope m tells you how steep the line is, and the intercept b tells you where it crosses the y-axis.
The three forms of a line
| Form | Equation | Best for |
|---|---|---|
| Slope-intercept | y = mx + b | Graphing and reading the slope and y-intercept |
| Point-slope | y − y₁ = m(x − x₁) | Writing a line from a slope and one point |
| Standard | Ax + By = C | Finding intercepts and solving systems |
How to find the equation from two points
- Find the slope: m = (y₂ − y₁) ÷ (x₂ − x₁).
- Substitute one point into y = mx + b and solve for b: b = y₁ − m × x₁.
- Write y = mx + b.
- Rewrite in point-slope or standard form if needed.
- Check that the second point satisfies the equation.
Worked examples
Two points: (1, 2) and (4, 6)
The slope is (6 − 2) ÷ (4 − 1) = 4/3. Then b = 2 − (4/3)(1) = 2/3. So y = (4/3)x + 2/3. In point-slope form, y − 2 = (4/3)(x − 1), and in standard form, 4x − 3y = −2. Check the other point: 4(4) − 3(6) = −2.
Negative slope: (−2, 5) and (3, −5)
The slope is (−5 − 5) ÷ (3 − (−2)) = −10 ÷ 5 = −2. Then b = 5 − (−2)(−2) = 1, so y = −2x + 1, or 2x + y = 1.
From a slope and a point: slope 2 through (3, 5)
b = 5 − 2 × 3 = −1, so y = 2x − 1.
Horizontal and vertical lines
For (2, 3) and (7, 3), the slope is 0 and the line is y = 3. For (2, 3) and (2, 9), the run is zero, so the slope is undefined and the line is x = 2.
Intercepts
The y-intercept is the value of b, where the line crosses the y-axis. The x-intercept is where y = 0, so x = −b ÷ m. For y = (4/3)x + 2/3, the y-intercept is (0, 2/3) and the x-intercept is (−1/2, 0).
Parallel and perpendicular lines
Parallel lines have the same slope. Perpendicular lines have slopes that multiply to −1, so the perpendicular slope is the negative reciprocal. A line parallel to y = 2x − 1 through (0, 4) is y = 2x + 4, and a perpendicular line through the same point is y = −(1/2)x + 4.
Common mistakes
Subtracting the coordinates in a different order for x and y flips the sign of the slope, so keep the same point first in both. Another error is forgetting to carry the sign of the slope when you find b. In standard form, A is normally written positive. A vertical line cannot be written as y = mx + b, because its slope is undefined. Use the slope, distance and midpoint calculator for the slope and distance, or the system of equations calculator to find where two lines meet.
Frequently asked questions
How do you find the equation of a line from two points?
Find the slope with rise over run, then substitute one point into y = mx + b to solve for b. For (1, 2) and (4, 6), the slope is 4/3 and b is 2/3, so y = (4/3)x + 2/3.
What is point-slope form?
Point-slope form is y − y₁ = m(x − x₁). It writes a line directly from its slope m and any one point (x₁, y₁) on it, without solving for the intercept. It is the quickest way to write a line from a slope and a point.
What is standard form of a line?
Standard form is Ax + By = C, usually with A, B and C as whole numbers and A positive. It makes intercepts easy to find and is the form used for systems of equations. The line y = (4/3)x + 2/3 becomes 4x − 3y = −2.
What is the equation of a vertical line?
A vertical line has the form x = a constant, such as x = 2. Every point on it has the same x-value, so the run is zero and the slope is undefined. It cannot be written in slope-intercept form.
How do you find a perpendicular line?
Take the negative reciprocal of the original slope, then use the new slope with the given point. If the original slope is 2, the perpendicular slope is −1/2. Two perpendicular lines always have slopes that multiply to −1.
How do you find the x-intercept of a line?
Set y = 0 and solve for x. From y = mx + b this gives x = −b ÷ m. For y = 2x − 1, the x-intercept is 1/2. A horizontal line other than the x-axis has no x-intercept.
More Geometry calculators
- Area Calculator
- Volume Calculator
- Circle Calculator
- Pythagorean Theorem Calculator
- Slope, Distance and Midpoint Calculator
- Midpoint Calculator
- Distance Formula Calculator
Browse every geometry calculator.
Other calculators
- Percentage Calculator
- Quadratic Formula Calculator
- Fraction Calculator
- GCF and LCM Calculator
- Mean, Median, Mode Calculator
- Standard Deviation Calculator
- Linear Equation Calculator
- Exponent and Root Calculator
- System of Equations Calculator
- Order of Operations Calculator
- Scientific Calculator with Steps
- Z-Score Calculator
- Permutation and Combination Calculator
- Percentage Change Calculator
- Percent Error Calculator
- Variance Calculator
Related topics on this page: slope-intercept form, point-slope form, standard form, y-intercept, x-intercept, line through two points, vertical and horizontal lines