Equation of a Line Calculator (Free, with Graph)
AlgebraFreeNo sign-up
An equation of a line calculator writes the line through your data as y = mx + b. For the points (1, 3) and (4, 9), the slope is m = (9 − 3)/(4 − 1) = 2. Then b = 3 − 2 × 1 = 1, so the line is y = 2x + 1, or 2x − y = −1 in standard form.
Already know the line and only need it as y = mx + b? Use the Slope Intercept Form Calculator for the slope, the y-intercept and every step.
Slope m = 2, y-intercept b = 1
The line is y = 2x + 1 with slope 2 and y-intercept 1. Point-slope form: y − 3 = 2(x − 1). Standard form: 2x − y = −1.
Related lines and forms
Show steps
- Slope: m = (y₂ − y₁)/(x₂ − x₁) = (9 − 3)/(4 − 1) = 6/3 = 2.
- Point-slope form with the first point: y − 3 = 2(x − 1).
- Find b by putting the first point into y = mx + b: 3 = 2 × 1 + b, so b = 3 − 2 = 1.
- Slope-intercept form: y = 2x + 1. Check with the second point: 2 × 4 + 1 = 9 = y₂.
- For standard form, move the x term to the left and make the x coefficient positive: 2x − y = −1.
Check any point by putting its x into y = mx + b: you should get its y.
How to use the equation of a line calculator
- Pick what you know: Two points, a Point & slope, the Slope & intercept, a line to be Parallel / perpendicular to plus a point, the two Intercepts, or any equation to Convert.
- Enter whole numbers, decimals or fractions such as 2/3. For a vertical line, type “undefined” as the slope.
- Read the slope-intercept, point-slope, standard, general and intercept forms, with the slope, both intercepts and the angle the line makes with the x-axis.
- Check the graph (gold dashes show rise over run) and open Show steps for the full working.
The three forms of a line equation
| Form | Equation | Best when you know |
|---|---|---|
| Slope-intercept | y = mx + b | the slope m and the y-intercept b; best for graphing |
| Point-slope | y − y₁ = m(x − x₁) | the slope and any point (x₁, y₁) |
| Standard | Ax + By = C | whole-number coefficients; finding intercepts; solving systems |
In standard form, A, B and C are integers with no common factor, and A is usually made positive. Two more forms appear in the results: the general form Ax + By + C = 0, and the intercept form x/a + y/b = 1, where a and b are the x- and y-intercepts.
Every form describes the same line, so you can move between them with algebra. Starting from y = −2x + 11, add 2x to both sides to get the standard form 2x + y = 11.
Equation of a line from two points
- Find the slope: m = (y₂ − y₁)/(x₂ − x₁). For (1, 3) and (4, 9): m = 6/3 = 2.
- Put one point into y = mx + b to find b: 3 = 2(1) + b, so b = 1.
- Write the equation: y = 2x + 1.
- Check with the other point: 2(4) + 1 = 9. It works.
If both points have the same x-coordinate, the run is 0 and the slope is undefined. The line is vertical, written x = c. Through (3, −1) and (3, 6), the line is x = 3. If both points have the same y-coordinate, the slope is 0 and the line is horizontal, such as y = 4.
Equation of a line from a point and a slope
With slope −2 through (3, 5), point-slope form gives y − 5 = −2(x − 3) right away. Distribute and add 5: y = −2x + 6 + 5 = −2x + 11. In standard form, 2x + y = 11.
From the slope and the y-intercept, write the answer directly. Slope 2 and y-intercept −3 give y = 2x − 3. A line that passes through (0, 4) and rises 3 for every 1 step right has m = 3 and b = 4, so y = 3x + 4; the point (2, 10) is on it because 3(2) + 4 = 10.
Parallel and perpendicular lines
Parallel lines have equal slopes. Perpendicular lines have slopes that are negative reciprocals, so their product is −1 (flip the fraction and change the sign).
Example: the line perpendicular to y = 2x + 1 through (4, 3) has slope −1/2. Then y − 3 = −(1/2)(x − 4), so y = −(1/2)x + 5, or x + 2y = 10 in standard form. A line perpendicular to a vertical line is horizontal, and the other way round.
| Given slope | Parallel slope | Perpendicular slope |
|---|---|---|
| 2 | 2 | −1/2 |
| −3/4 | −3/4 | 4/3 |
| 1 | 1 | −1 |
| 0 (horizontal) | 0 | undefined (vertical) |
Equation of a line from its intercepts
If a line crosses the x-axis at (a, 0) and the y-axis at (0, b), its intercept form is x/a + y/b = 1 and its slope is −b/a. With intercepts 3 and −6, the slope is 6/3 = 2 and the line is y = 2x − 6, or 2x − y = 6.
Common mistakes
- Mixing the order in the slope formula: subtract y-values and x-values in the same order.
- Sign errors in point-slope form: through (−4, 1) it is y − 1 = m(x + 4), not m(x − 4).
- Using the reciprocal without the sign change (or the sign change without the reciprocal) for perpendicular lines.
- Calling a vertical line’s slope 0. Vertical lines have an undefined slope; horizontal lines have slope 0.
- Leaving fractions in standard form. Multiply through so A, B and C are whole numbers.
Equation of a Line practice quiz: 10 questions
Test yourself with 10 multiple-choice questions. Choose an answer and press Submit to see if you are right and why. Your score appears at the end.
Multiply by 3: 3y = 2x − 12. Move 2x left: −2x + 3y = −12, then multiply by −1 to make A positive: 2x − 3y = 12.
The given line is y = −2x + 7/2, slope −2. The negative reciprocal of −2 is 1/2.
Both points have x = 4, so the run is 0. The slope is undefined and the line is vertical: x = 4.
Through (5, 0) and (0, −10): m = (−10 − 0)/(0 − 5) = 2. Also −b/a = 10/5 = 2.
Quiz complete
Frequently asked questions
What is the formula for finding the equation of a line?
The most used formula is y = mx + b, where m is the slope and b is the y-intercept. If you know a point instead of the intercept, start from point-slope form y − y₁ = m(x − x₁).
How do you calculate the equation of a line with two points?
Compute the slope m = (y₂ − y₁)/(x₂ − x₁), substitute one point into y = mx + b to find b, then write y = mx + b. For (1, 3) and (4, 9), m = 2 and b = 1, so y = 2x + 1.
What does it mean to find the equation of a line?
It means writing a rule that every point on the line satisfies and no other point does. For y = 2x + 1, the point (4, 9) works because 2(4) + 1 = 9, while (4, 8) does not.
How do you find the equation of a line from a slope and a point?
Substitute into y − y₁ = m(x − x₁) and simplify. With slope −2 through (3, 5), y − 5 = −2(x − 3), which becomes y = −2x + 11.
How do you find the equation of a perpendicular line?
Take the negative reciprocal of the given slope and use it with the point. Perpendicular to y = 2x + 1 through (4, 3): the slope is −1/2 and the line is y = −(1/2)x + 5.
How do you calculate the equation of a line in Excel?
Put the x-values in one column and the y-values in another, then use =SLOPE(y_range, x_range) for m and =INTERCEPT(y_range, x_range) for b. With exactly two points, this gives the line through them; with more points, it gives the best-fit line.
Related calculators
- Slope calculator
- Point-slope form calculator
- Standard form calculator
- Distance and midpoint calculator
- Graphing calculator
More algebra calculators
Related to This Article
More math articles
- 5th Grade M-STEP Math Worksheets: FREE & Printable
- 4th Grade SBAC Math Practice Test Questions
- 8th Grade PARCC Math Worksheets: FREE & Printable
- How to Divide Exponents? (+FREE Worksheet!)
- Professions related to mathematics
- The Best Grade 7 ELA Practice Tests for Rhode Island Students
- Obama and the Affordable Care Act: Policy and Partisanship
- The Best Grade 4 Math Book for Missouri Students
- Federalists and Anti-Federalists: Power, Representation and Rights
- How to Find Fractional and Decimal Percentages




What people say about "Equation of a Line Calculator With Graph & Steps"?
No one replied yet.