Lelifi·tools

Equation of a Line Calculator

The equation of a line through two points comes from the slope, then the intercept. For (2, 3) and (6, 11) the slope is 8 / 4 = 2 and the intercept is 3 - 2 x 2 = -1, so the line is y = 2x - 1, which is 2x - y = 1 in standard form.

Give two points, or one point and the slope, or the slope and the y-intercept. The calculator returns the same line in slope-intercept, point-slope and standard form, with both intercepts and the angle it makes with the x-axis.

Point 1

Point 2

Enter two points, a point and a slope, or a slope and an intercept to get the line in slope-intercept, point-slope and standard form, plus both intercepts.

By the Lelifi editors ·

Key takeaways

The line y = 2x - 1 through (2, 3) and (6, 11)01234567-224681012xyrun = 4rise = 8(2, 3)(6, 11)b = -1
The line y = 2x - 1 drawn through (2, 3) and (6, 11), with the rise of 8 and run of 4 that produce a slope of 2.
Slope sign tells you which way the line runsm = 2rises to the rightm = -1falls to the rightm = 0flat, y = 4x = 5vertical, no slope
Slope sign in four panels: a rising line, a falling line, a flat line and a vertical line with no slope at all.
On this page
  1. What the equation of a line calculator gives you
  2. From two points: slope first, then the intercept
  3. Three forms of the same line
  4. One point and a slope, or a slope and an intercept
  5. Fractions, negative slopes and the two lines that break the pattern
  6. Reading the slope and intercept off a real bill
  7. How to check the line before you hand it in

What the equation of a line calculator gives you

A straight line is pinned down by two facts: how steep it is, and where it crosses the y-axis. Hand the calculator either of those, or two points on the line, and it returns every common way of writing that line: slope-intercept, point-slope and standard form, plus the x-intercept and the angle the line makes with the x-axis.

Three input modes cover the cases that show up in homework and at work. Two points is the one people reach for most. Point and slope is what a word problem usually hands you, such as a $65 hourly rate on top of an $85 visit fee. Slope and intercept is the fast path when half the equation is already written.

Negatives and decimals go in as written, so a falling line or a slope of 0.3333 is no harder than a whole number. Standard form is printed with whole numbers when the slope and intercept are clean fractions.

From two points: slope first, then the intercept

Slope is rise over run: m = (y2 - y1) / (x2 - x1). Take the points (2, 3) and (6, 11). The rise is 11 - 3 = 8 and the run is 6 - 2 = 4, so the slope is 8 / 4 = 2. Read that as a walking instruction: go right 1, up 2, and you stay on the line.

With the slope in hand, either point gives the intercept. Put (2, 3) into y = mx + b and you get 3 = 2 x 2 + b, so b = 3 - 4 = -1. The line is y = 2x - 1. Run the same check with the other point: 2 x 6 - 1 = 11, which matches, so both points sit on the line.

Point-slope form gets there without solving for b: y - 3 = 2(x - 2). Distribute the 2 and add 3 and you are back at y = 2x - 1. Same line, different wrapper, and the calculator prints both.

Flip both differences and the slope is unchanged, since -8 / -4 is still 2. Flip only one and you get -2, the most common sign slip in this topic.

Three forms of the same line

Slope-intercept form is the one to reach for when you want to graph by hand: plot the intercept, then step out the slope. Point-slope form is the one to reach for when a problem hands you a point and a slope, because nothing has to be solved to write it. Standard form is the one teachers ask for when they want whole-number coefficients. The free Elementary Algebra 2e (OpenStax, 2020) lays out all three on one page.

Moving between them is bookkeeping, not new math. From y = 2x - 1, subtract 2x and multiply by -1 to reach 2x - y = 1. Add y back to each side and you are where you started. The calculator runs the conversion both ways and keeps the coefficients exact when the slope is a clean fraction.

FormFor the line through (2, 3) and (6, 11)What you can read offBest for
Slope-intercepty = 2x - 1slope 2, y-intercept (0, -1)graphing by hand, quick checks
Point-slopey - 3 = 2(x - 2)the line passes through (2, 3)a point and a slope are given
Standard2x - y = 1x-intercept 0.5, y-intercept -1whole-number coefficients, systems
Horizontaly = 4slope 0, y stays 4flat fees, fixed heights
Verticalx = 5slope undefined, x stays 5walls, fixed quantities

One point and a slope, or a slope and an intercept

When slope and y-intercept are both given, the equation is already written: drop the numbers into y = mx + b and stop. When slope and a point are given, solve b = y1 - m x x1 once. With m = 2 and the point (2, 3), b = 3 - 2 x 2 = -1, so y = 2x - 1.

Two intercepts work the same way with a small twist. The points are (a, 0) and (0, b), so the slope is (b - 0) / (0 - a), which simplifies to -b / a. A line that crosses the x-axis at 0.5 and the y-axis at -1 has a slope of -(-1) / 0.5 = 2, which lands on the same line as the two-point example.

What you knowWrite it asWorked result
Slope and y-intercepty = mx + bm = 2 and b = -1 give y = 2x - 1
Slope and one pointb = y1 - m x x1m = 2 at (2, 3) gives b = -1
Two pointsslope formula, then b(2, 3) and (6, 11) give y = 2x - 1
Two interceptsm = -b / a, then y = mx + bx-intercept 0.5 with y-intercept -1 gives the same line
A graph or a tablepick two clean pointsa line through (0, -1) and (1, 1) gives y = 2x - 1

If the line comes from a chart, pick points where the grid lines cross. Reading (1.7, 2.4) off a screen adds error to the slope and the intercept.

Fractions, negative slopes and the two lines that break the pattern

A fractional slope is still a slope. Through (-2, 5) and (4, 7): the rise is 7 - 5 = 2 and the run is 4 - (-2) = 6, so m = 2 / 6 = 0.3333. Using (4, 7) to pin the intercept, 0.3333 x 4 + 5.6667 = 7, so y = 0.3333x + 5.6667. Standard form tidies the decimals away: x - 3y = -17, and both original points satisfy it.

A negative slope means the line falls as you read left to right. Through (1, 7) and (4, 1): the rise is 1 - 7 = -6, the run is 4 - 1 = 3, so m = -6 / 3 = -2 and b = 7 - (-2) x 1 = 9. The line is y = -2x + 9, and it crosses the x-axis where -2x + 9 = 0, which is x = 4.5.

Two cases escape y = mx + b. A vertical line has a run of zero, so the slope is undefined and the equation is written x = 5. That is not a function of x, which is why it cannot be solved for y. A horizontal line has a rise of zero, so the slope is 0 and the equation is y = 4. The calculator labels both by name instead of forcing a divide-by-zero into a fake decimal.

Units ride along unchanged: if x is hours and y is dollars, the slope reads in dollars per hour, so a slope of $2 an hour for a plumber is a signal to recheck the points.

Reading the slope and intercept off a real bill

A linear equation is a rate plus a starting amount, which is exactly how most household bills are built. A plumber who charges $85 to show up and $65 an hour gives the points (1, 150) and (3, 280). Slope: 130 / 2 = 65, the hourly rate. Intercept: 150 - 65 = 85, the visit fee. The bill for 5 hours is 65 x 5 + 85 = 410.

The same reading works in reverse. A candle 8 inches tall that burns 0.5 inches an hour is y = -0.5x + 8, where the negative slope is the burn rate and the intercept is the starting height. Setting y = 0 gives x = 16, the number of hours before it goes out.

SituationEquationSlope meansIntercept means
Plumber: $85 visit, $65 an houry = 65x + 85$65 per hour$85 to start
Phone plan: $30 base, $0.10 a minutey = 0.10x + 3010 cents per minute$30 monthly base
Taxi: $3.50 flag drop, $2.25 a miley = 2.25x + 3.50$2.25 per mile$3.50 to start the meter
Candle: 8 inches tall, 0.5 inches an houry = -0.5x + 8burns 0.5 inches per hour8 inches at the start
Savings: $500 saved, $75 a weeky = 75x + 500$75 added per week$500 on day one

The phone plan is a fair test: 400 minutes costs 0.10 x 400 + 30 = 70, and 500 more minutes add 50.

How to check the line before you hand it in

Plug both original points into your final equation. If either one fails, the failure points at the culprit: a line that misses both points usually has a slope error, while a line that is parallel and shifted has an intercept error.

Then look at the sign. Points that rise to the right need a positive slope, and points that fall need a negative one. If your equation says y = -2x + 9 while the two points clearly climb, the subtraction order got flipped somewhere.

One caution about spreadsheets. A trendline is a least-squares fit through all the data, not the line through two chosen points. NIST's e-Handbook of Statistical Methods (NIST/SEMATECH, 2012) describes that fit as the slope and intercept that minimize squared residuals, and with more than two points the two methods give different lines. Use this calculator when a line is defined by two points or a stated slope, and a regression when you are summarizing a cloud of measurements.

A last check: put the equation into standard form and substitute. For y = 2x - 1 that is 2x - y = 1, and (2, 3) gives 2 x 2 - 3 = 1.

Frequently asked questions

What is the equation of the line through (2, 3) and (6, 11)?

y = 2x - 1. The slope is (11 - 3) / (6 - 2) = 8 / 4 = 2, and the intercept is 3 - 2 x 2 = -1. In standard form the same line is 2x - y = 1.

How do I find the equation of a line from two points?

Find the slope with the rise over the run, then substitute either point into y = mx + b and solve for b. Two points are enough, because two points fix exactly one straight line. If both points share an x value, the line is vertical and the equation is x = that value.

What if the slope is a fraction?

Nothing changes, and standard form does get cleaner. Through (-2, 5) and (4, 7) the slope is 2 / 6 = 0.3333 and the line is y = 0.3333x + 5.6667, or x - 3y = -17 with whole numbers.

How do I find the y-intercept without graphing?

Use b = y1 - m x x1 with either point. For m = 2 and the point (2, 3): b = 3 - 2 x 2 = -1, so the line crosses the y-axis at (0, -1).

What is the equation of a vertical line through (5, 2)?

x = 5. Every point on that line has an x of 5, the run between any two of them is zero, and the slope is undefined rather than zero. The calculator reports it as a vertical line instead of inventing a slope.

How do I convert y = 2x - 1 to standard form?

Subtract 2x from each side to get -2x + y = -1, then multiply by -1: 2x - y = 1. Standard form is usually written with a positive leading coefficient, which is why the signs get flipped.

What does point-slope form look like for that line?

y - 3 = 2(x - 2), using the point (2, 3) and the slope 2. Distributing and adding 3 returns y = 2x - 1, so the two forms describe the same line.

What is the x-intercept of y = 2x - 1?

0.5. Set y to zero and solve: 0 = 2x - 1, so x = 0.5. The line crosses the x-axis at the point (0.5, 0).

What does the slope mean on a bill?

It is the rate you pay per unit. A plumber charging $85 to show up and $65 an hour is y = 65x + 85, so 5 hours costs 65 x 5 + 85 = 410 dollars, and the 65 is the part that grows with time.

Can I use two points from a spreadsheet to get the trendline?

No. A trendline is a least-squares fit through every point in the data set, which is not the same as the line through two chosen points. With three or more points the two answers differ, and the regression is the one to report.

Does it matter which point I call point 1?

No, as long as you keep the same order in both differences. Using (2, 3) first gives 8 / 4 = 2, and using (6, 11) first gives -8 / -4 = 2. Mixing the order gives -2, which is the wrong line.

Can a line have a slope of zero?

Yes. A horizontal line has no rise, so the slope is 0 and the equation is y = a constant, such as y = 4. That is different from a vertical line, whose slope is undefined.

How many points do I need to define a line?

Two points, as long as they are not the same point. One point leaves infinitely many lines through it, and a slope or a second point is what narrows it to one.

Does the calculator work with decimals and negative coordinates?

Yes. Negative and decimal coordinates go in exactly as written, and results show four decimal places. For (-2, 5) and (4, 7) the slope is 0.3333 and the intercept is 5.6667, which is the same line as x - 3y = -17.

Spotted a wrong number or a broken result?

More Math tools

See all Math tools

Fee schedules, rates and rules change without notice. Always confirm important figures with the official source before you rely on them.