Skip to main content
guidealgebralinear equations

How to Find the Equation of a Line: 4 Methods with Worked Examples

·15 min read·Solvify Team

Learning how to find the equation of a line is one of the most used skills in algebra, and the process is straightforward once you know which method fits the information you are given. There are four common scenarios: you have the slope and y-intercept directly, you have two points, you have one point and a slope, or you need to convert between forms. Each situation maps to a specific approach, and all four methods rely on the same two core ideas — the slope formula and the slope-intercept equation y = mx + b. This guide walks through every method with full worked examples, clear step-by-step reasoning, common error traps, and practice problems so you can confidently find the equation of any line.

What Is the Equation of a Line?

A line in the coordinate plane is a set of infinitely many points that all share a single mathematical relationship between their x and y coordinates. The equation of a line captures that relationship exactly: any point (x, y) that lies on the line will make the equation true, and any point not on the line will not. The most common form is slope-intercept form: y = mx + b. Here, m is the slope — the rate at which the line rises or falls for every one unit moved to the right. A positive slope means the line goes up from left to right; a negative slope means it falls. The value b is the y-intercept, the point where the line crosses the y-axis (at x = 0). For example, the line y = 2x + 3 has slope m = 2 and y-intercept b = 3. Start at (0, 3) on the y-axis, then for every 1 unit you move right, move 2 units up. The line y = −x + 5 has slope m = −1 and y-intercept b = 5 — it falls from left to right, passing through (0, 5). Why does the equation of a line matter outside a classroom? Engineers use linear equations to model rates of change. Scientists use them to analyze data that follows a straight-line trend. Anyone working with distance vs. time, cost vs. quantity, or any two quantities that change at a constant rate is working with the equation of a line.

Every point on the line satisfies the equation, and every point off the line does not. This is the definition that makes the equation of a line a precise, useful tool.

The Three Standard Forms — and When to Use Each

Three forms appear across math textbooks and tests, and each one is the natural starting point for a different type of problem. Before learning how to find the equation of a line, it helps to know all three so you can recognize which one the problem is asking for.

1. Slope-Intercept Form: y = mx + b

This is the most widely used form. m is the slope and b is the y-intercept. Use this form when you know the slope and y-intercept directly, or when you need to graph the line quickly. Every linear equation can be rearranged to this form by solving for y. Example: y = 3x − 7 has slope 3 and y-intercept −7. To sketch it, plot (0, −7) then move up 3 and right 1 repeatedly.

2. Point-Slope Form: y − y₁ = m(x − x₁)

This form is built for situations where you know one point (x₁, y₁) on the line and the slope m. It is the bridge between those two pieces of information and the final slope-intercept equation. Substitute the known values, distribute, then rearrange. Example: slope m = 4, point (2, 6) gives y − 6 = 4(x − 2). Expanding: y = 4x − 2.

3. Standard Form: Ax + By = C

Standard form requires integer coefficients (no fractions) and both variables on the left side. A is positive by convention. This form is preferred in systems of equations and more advanced algebra courses. Example: 3x + 2y = 12. To convert from slope-intercept y = 3x − 1, subtract 3x from both sides: −3x + y = −1, then multiply by −1: 3x − y = 1.

Slope-intercept form y = mx + b is ideal for graphing and everyday use. Point-slope form y − y₁ = m(x − x₁) is the working tool when you know one point and a slope.

Method 1: Slope and Y-Intercept Given Directly

The simplest case when finding the equation of a line is when both the slope and y-intercept are given to you directly. Plug the values into y = mx + b and write the result — no calculation needed. This method is also how you write the equation after completing any of the other three methods, since they all end in slope-intercept form.

1. Example 1: slope = 5, y-intercept = −2

Substitute directly into y = mx + b: m = 5, b = −2 y = 5x + (−2) y = 5x − 2 This is the complete equation of the line. It rises steeply — 5 units up for every 1 unit right — and crosses the y-axis at (0, −2). Check: at x = 1, y = 5(1) − 2 = 3. At x = 3, y = 5(3) − 2 = 13. Both points lie on the line.

2. Example 2: slope = −3/4, y-intercept = 6

m = −3/4, b = 6 y = (−3/4)x + 6 The negative fraction slope means the line falls 3 units for every 4 units moved right. It crosses the y-axis at (0, 6). Check: at x = 4, y = (−3/4)(4) + 6 = −3 + 6 = 3. So (4, 3) is on the line. At x = 8, y = (−3/4)(8) + 6 = −6 + 6 = 0. So (8, 0) is the x-intercept.

3. Example 3: slope = 0, y-intercept = 4

m = 0, b = 4 y = 0x + 4 y = 4 A slope of 0 produces a horizontal line. The equation y = 4 describes every point where the y-coordinate equals 4, regardless of x. The line runs perfectly flat at height 4 and passes through (0, 4), (3, 4), (−5, 4), and every other point with y = 4.

Method 2: How to Find the Equation of a Line from Two Points

When you are given two points and no slope, calculate the slope first using the slope formula: m = (y₂ − y₁) ÷ (x₂ − x₁). This is rise over run — the vertical change divided by the horizontal change between the two points. Once you have the slope, substitute it and either point into point-slope form, then simplify to slope-intercept form. This is the most commonly tested method because it requires two separate formulas and more arithmetic.

1. General Procedure (5 Steps)

Step 1: Label the two points as (x₁, y₁) and (x₂, y₂). Step 2: Calculate slope: m = (y₂ − y₁) ÷ (x₂ − x₁). Step 3: Substitute m and one point into point-slope form: y − y₁ = m(x − x₁). Step 4: Distribute and rearrange to y = mx + b. Step 5: Check by substituting both original points into the final equation — both must satisfy it.

2. Example 1: Points (1, 3) and (4, 9)

Step 1: (x₁, y₁) = (1, 3), (x₂, y₂) = (4, 9) Step 2: m = (9 − 3) ÷ (4 − 1) = 6 ÷ 3 = 2 Step 3: y − 3 = 2(x − 1) Step 4: y − 3 = 2x − 2 → y = 2x + 1 Check: Plug in (1, 3): 2(1) + 1 = 3 ✓. Plug in (4, 9): 2(4) + 1 = 9 ✓ Equation of the line: y = 2x + 1

3. Example 2: Points (−2, 7) and (4, −5) — Negative Slope

Step 1: (x₁, y₁) = (−2, 7), (x₂, y₂) = (4, −5) Step 2: m = (−5 − 7) ÷ (4 − (−2)) = −12 ÷ 6 = −2 Step 3: y − 7 = −2(x − (−2)) → y − 7 = −2(x + 2) Step 4: y − 7 = −2x − 4 → y = −2x + 3 Check: Plug in (−2, 7): −2(−2) + 3 = 4 + 3 = 7 ✓. Plug in (4, −5): −2(4) + 3 = −8 + 3 = −5 ✓ Equation of the line: y = −2x + 3

4. Example 3: Points (0, 5) and (3, 5) — Horizontal Line

Step 1: (x₁, y₁) = (0, 5), (x₂, y₂) = (3, 5) Step 2: m = (5 − 5) ÷ (3 − 0) = 0 ÷ 3 = 0 The slope is zero, so the line is horizontal. Since (0, 5) is on the line, the y-intercept is 5. Equation: y = 5 Both points satisfy y = 5 ✓. No further steps needed when slope = 0.

Slope formula: m = (y₂ − y₁) ÷ (x₂ − x₁). Always subtract y-values in the same order as x-values — use point 2 minus point 1 throughout, or point 1 minus point 2 throughout. Mixing the order gives the wrong sign.

Method 3: One Point and a Slope Are Given

This scenario is designed for point-slope form. When a problem states 'the line has slope 3 and passes through (2, 7)', substitute directly into y − y₁ = m(x − x₁), then expand and simplify. Point-slope form is a working step, not a final answer — always rearrange to slope-intercept or standard form before writing your result.

1. Example 1: Slope m = 2, passes through (3, 7)

Point-slope: y − 7 = 2(x − 3) Distribute: y − 7 = 2x − 6 Add 7 to both sides: y = 2x + 1 Check: At x = 3, y = 2(3) + 1 = 7 ✓

2. Example 2: Slope m = −3, passes through (−1, 5)

Point-slope: y − 5 = −3(x − (−1)) → y − 5 = −3(x + 1) Distribute: y − 5 = −3x − 3 Add 5 to both sides: y = −3x + 2 Check: At x = −1, y = −3(−1) + 2 = 3 + 2 = 5 ✓ Note: (x − (−1)) becomes (x + 1). Forgetting to flip the double negative here is a very common error.

3. Example 3: Slope m = 1/2, passes through (4, −3)

Point-slope: y − (−3) = (1/2)(x − 4) → y + 3 = (1/2)(x − 4) Distribute: y + 3 = (1/2)x − 2 Subtract 3 from both sides: y = (1/2)x − 5 Check: At x = 4, y = (1/2)(4) − 5 = 2 − 5 = −3 ✓ Note: y − (−3) simplifies to y + 3. Treat subtracting a negative as adding a positive.

When x₁ is negative, y − y₁ = m(x − x₁) becomes m(x + |x₁|) after simplification. If x₁ = −2, then (x − (−2)) = (x + 2). Not flipping that sign is one of the most frequent mistakes with point-slope form.

Method 4: Writing the Equation in Standard Form

Standard form Ax + By = C requires integer coefficients with A > 0. To convert from slope-intercept form, move the x-term to the left side and clear any fractions by multiplying every term by the denominator. Standard form is especially useful when working with systems of equations or when a problem explicitly requests it.

1. Converting y = (2/3)x + 4 to Standard Form

Start with: y = (2/3)x + 4 Multiply every term by 3 to clear the fraction: 3y = 2x + 12 Subtract 2x from both sides: −2x + 3y = 12 Multiply through by −1 so A > 0: 2x − 3y = −12 Check: At x = 0: −3y = −12 → y = 4. Does (0, 4) satisfy y = (2/3)(0) + 4 = 4? ✓ At x = 3: 2(3) − 3y = −12 → 6 − 3y = −12 → y = 6. Check: (2/3)(3) + 4 = 2 + 4 = 6 ✓

2. From Two Points to Standard Form: (1, 2) and (3, 8)

Step 1: Find slope: m = (8 − 2) ÷ (3 − 1) = 6 ÷ 2 = 3 Step 2: Point-slope with (1, 2): y − 2 = 3(x − 1) → y − 2 = 3x − 3 → y = 3x − 1 Step 3: Subtract 3x from both sides: −3x + y = −1 Step 4: Multiply by −1: 3x − y = 1 Check: (1, 2): 3(1) − 2 = 1 ✓. (3, 8): 3(3) − 8 = 9 − 8 = 1 ✓

Horizontal and Vertical Lines: Special Cases That Confuse Students

Horizontal and vertical lines do not fit the y = mx + b template in the usual way, and many students mix up the two. Here is the distinction: A horizontal line has a slope of zero (m = 0). It runs perfectly flat, parallel to the x-axis. Its equation is simply y = k, where k is the constant y-value of every point on the line. The x-coordinate can be anything; the y-coordinate is always k. Example: the line through (0, 4), (3, 4), and (−5, 4) is y = 4. A vertical line has an undefined slope. Slope is rise over run, and a vertical line has zero run — dividing by zero is undefined. Its equation is x = h, where h is the constant x-value. The y-coordinate can be anything; the x-coordinate is always h. Example: the line through (3, 0), (3, 5), and (3, −2) is x = 3. A quick test when given two points: if both x-coordinates are the same, the line is vertical (x = h). If both y-coordinates are the same, the line is horizontal (y = k). Example: Find the equation of the line through (5, 2) and (5, −7). Both x-coordinates are 5 — this is a vertical line. Equation: x = 5. Example: Find the equation of the line through (−3, 6) and (8, 6). Both y-coordinates are 6 — this is a horizontal line. Equation: y = 6.

Horizontal line: y = k, slope = 0. Vertical line: x = h, slope = undefined. If both points share the same x-coordinate, write x = h. If both share the same y-coordinate, write y = k.

Parallel and Perpendicular Lines

Parallel and perpendicular line problems are a frequent application of how to find the equation of a line. They require you to determine a slope from a geometric condition and then apply that slope through a given point.

1. Parallel Lines: Same Slope, Different Intercept

Parallel lines never intersect and always have the same slope. If line 1 has equation y = 3x + 7, every line parallel to it also has slope m = 3, just with a different y-intercept. Example: Find the equation of the line parallel to y = 3x + 7 that passes through (2, 1). Slope: m = 3 (same as the given line) Point-slope: y − 1 = 3(x − 2) → y − 1 = 3x − 6 → y = 3x − 5 Check: Both lines have slope 3 ✓. Different y-intercepts (7 vs. −5) confirm they are parallel, not identical ✓. Check point: At x = 2, y = 3(2) − 5 = 1 ✓

2. Perpendicular Lines: Negative Reciprocal Slopes

Perpendicular lines intersect at a 90° angle. Their slopes are negative reciprocals of each other: if line 1 has slope m, line 2 has slope −1/m. The product of perpendicular slopes always equals −1. Example: Find the equation of the line perpendicular to y = 4x + 1 that passes through (2, 3). Slope of original: m = 4. Perpendicular slope: −1/4. Point-slope: y − 3 = (−1/4)(x − 2) → y − 3 = (−1/4)x + 1/2 → y = (−1/4)x + 7/2 Check slopes: 4 × (−1/4) = −1 ✓ Check point: (−1/4)(2) + 7/2 = −1/2 + 7/2 = 6/2 = 3 ✓ Shortcut for perpendicular slope: take the original slope, flip it (invert the fraction), and change the sign. Slope 2/3 → flip to 3/2 → change sign to −3/2.

Parallel lines share the same slope. Perpendicular lines have slopes that multiply to −1: if one slope is m, the other is −1/m. Flip the fraction and negate the sign.

Common Mistakes When Finding the Equation of a Line

These errors appear repeatedly across all four methods. Knowing them in advance makes them much easier to catch before they cost marks.

1. Subtracting points in mismatched order in the slope formula

In m = (y₂ − y₁) ÷ (x₂ − x₁), you must subtract in the same order in numerator and denominator. A common error: using y₂ − y₁ on top but x₁ − x₂ on the bottom. For points (1, 3) and (4, 9): correct is m = (9 − 3) ÷ (4 − 1) = 2. Using (9 − 3) ÷ (1 − 4) gives −2, flipping the sign and producing the wrong equation.

2. Plugging in the wrong coordinates in point-slope form

In y − y₁ = m(x − x₁), y₁ and x₁ must come from the same point. Mixing up — taking the y-coordinate from one point and the x-coordinate from another — produces a completely wrong equation. Label your points before substituting. If the point is (3, 7), write x₁ = 3 and y₁ = 7 explicitly before filling in the formula.

3. Leaving the answer in point-slope form

Point-slope form y − y₁ = m(x − x₁) is a working step, not a final form. Most problems expect slope-intercept form y = mx + b or standard form. Always distribute and collect like terms to complete the simplification. y − 3 = 2(x − 1) is technically correct but incomplete — the final answer is y = 2x + 1.

4. Confusing x-intercept with y-intercept

The y-intercept b in y = mx + b is where the line crosses the y-axis (x = 0). The x-intercept is where the line crosses the x-axis (y = 0). A problem that says 'the line crosses the x-axis at (3, 0)' is giving you a point with y = 0, not b = 3. Substitute (3, 0) into point-slope form — do not write y = mx + 3.

5. Getting parallel and perpendicular slopes backwards

Parallel lines keep the same slope — no change needed. Perpendicular lines need the negative reciprocal — flip the fraction and negate the sign. The slope 3/4 becomes −4/3 for the perpendicular line. A common error is negating without flipping: −3/4 gives the wrong slope. Check: (3/4) × (−4/3) = −12/12 = −1 ✓

Practice Problems: Find the Equation of a Line

Work through each problem on your own before reading the solution. The problems increase in difficulty and cover all four methods.

1. Problem 1: Slope = 4, y-intercept = −3

Substitute directly: y = 4x − 3. Equation of the line: y = 4x − 3. Check: slope is 4 ✓, crosses y-axis at (0, −3) ✓

2. Problem 2: Points (2, 4) and (5, 10)

Step 1: m = (10 − 4) ÷ (5 − 2) = 6 ÷ 3 = 2 Step 2: y − 4 = 2(x − 2) → y − 4 = 2x − 4 → y = 2x Check: (2, 4): 2(2) = 4 ✓. (5, 10): 2(5) = 10 ✓ Note: y-intercept is 0, meaning the line passes through the origin.

3. Problem 3: Slope = −5, passes through (1, 8)

Point-slope: y − 8 = −5(x − 1) Distribute: y − 8 = −5x + 5 Add 8: y = −5x + 13 Check: At x = 1: −5(1) + 13 = −5 + 13 = 8 ✓

4. Problem 4: Points (−3, 2) and (6, −1)

Step 1: m = (−1 − 2) ÷ (6 − (−3)) = −3 ÷ 9 = −1/3 Step 2: y − 2 = (−1/3)(x − (−3)) → y − 2 = (−1/3)(x + 3) Distribute: y − 2 = (−1/3)x − 1 Add 2: y = (−1/3)x + 1 Check: (−3, 2): (−1/3)(−3) + 1 = 1 + 1 = 2 ✓. (6, −1): (−1/3)(6) + 1 = −2 + 1 = −1 ✓

5. Problem 5: Line perpendicular to y = 2x + 5 through (4, 3)

Perpendicular slope: −1/2 (negative reciprocal of 2) Point-slope: y − 3 = (−1/2)(x − 4) Distribute: y − 3 = (−1/2)x + 2 Add 3: y = (−1/2)x + 5 Check slope: 2 × (−1/2) = −1 ✓. Check point: (−1/2)(4) + 5 = −2 + 5 = 3 ✓

6. Problem 6: Points (3, 7) and (3, −2)

Both points have x = 3. The x-coordinate does not change between the two points, so this is a vertical line. Equation: x = 3 Slope is undefined for vertical lines — no slope-intercept form exists. Check: (3, 7) satisfies x = 3 ✓. (3, −2) satisfies x = 3 ✓

Check your work: substitute both original points back into the final equation. If both sides match for both points, the equation is correct.

Frequently Asked Questions About Finding the Equation of a Line

1. What is the easiest method to find the equation of a line?

If you have the slope and y-intercept, y = mx + b requires zero calculation — just substitute. If you have two points or a point and a slope, point-slope form is the most direct path. The two-point method (slope formula first, then point-slope form) is the most broadly applicable because the steps are the same regardless of which pair of values you are given.

2. How do I find the equation of a line from a graph?

Read two clear grid intersection points where the line passes exactly through a corner. Calculate the slope using those two points: m = (y₂ − y₁) ÷ (x₂ − x₁). Then identify the y-intercept directly — the point where the line crosses the y-axis — and write y = mx + b. If the y-axis crossing falls between grid lines, use point-slope form with one of your two read points instead.

3. Can two different equations represent the same line?

Yes — the same line can be written in multiple equivalent forms. The equations y = 2x + 3, y − 5 = 2(x − 1), and 2x − y = −3 all describe the exact same line. They are different algebraic representations of the same geometric object. When a problem asks for a specific form (slope-intercept or standard form), always convert to that form before submitting your answer.

4. How do I find the equation of a horizontal or vertical line?

A horizontal line parallel to the x-axis has equation y = k, where k is the constant y-value. A vertical line parallel to the y-axis has equation x = h, where h is the constant x-value. Example: the horizontal line through (4, 7) is y = 7. The vertical line through (−3, 2) is x = −3. Neither form uses slope or the y = mx + b structure.

5. What if both given points have the same y-coordinate?

If both points share the same y-value, the slope is 0 and the line is horizontal. For example, given (2, 5) and (8, 5): m = (5 − 5) ÷ (8 − 2) = 0 ÷ 6 = 0. The equation is y = 5. When slope is 0, skip point-slope form entirely and write the horizontal equation directly.

6. What is the difference between slope-intercept form and the equation of a line?

Slope-intercept form y = mx + b is one way to express the equation of a line, not the only way. Point-slope form and standard form are equally valid equations for the same line. 'Equation of a line' is the general term for any algebraic relationship satisfied by all points on that line. In practice, slope-intercept form is the most common answer format because it directly shows both the slope and the y-intercept.

Tags:
guidealgebralinear equations

Get Homework Help Now

Join millions of students using our AI math solver for homework help. Get instant solutions to math problems, step-by-step explanations, and 24/7 homework assistance.

Available for iOS and Android devices