Skip to main content

Equation of a Line Calculator

Enter two distinct plane points. The page returns slope m, y-intercept b, slope-intercept form y = mx + b, and point-slope form through the first point. Vertical segments report x = constant instead.

Rated 4.8 out of 5 based on 291 reviews

Results

How to find the equation of a line

  1. Enter the first point as x1 and y1. The default first point is (0, 1).
  2. Enter the second point as x2 and y2. The default second point is (2, 5).
  3. Read slope m, y-intercept b, slope-intercept form, and point-slope form under the form.
  4. If the x values match, read the vertical equation x = constant. Slope stays undefined for that case.
  5. Open the intercepts or slope pages when you already know m and b instead of two points.

Equation of a line

Plane line from two Cartesian points

Slope formulam = (y2 - y1) / (x2 - x1) when x1 ≠ x2
Y-interceptb = y1 - m x1
Slope-intercept formy = mx + b
Point-slope formy - y1 = m(x - x1)
Default example(0, 1) and (2, 5) give m = 2 and y = 2x + 1
Vertical linex = x1 when both points share the same x

What an equation of a line represents

A non-vertical line in the plane is the set of points that satisfy y = mx + b. Slope m is rise over run between any two points on the line. The y-intercept b is where the line crosses the vertical axis. The default points (0, 1) and (2, 5) give m = 2 and y = 2x + 1.

Slope-intercept and point-slope forms

Slope-intercept writes the line with slope and the intercept on the y-axis. Point-slope keeps the same slope but anchors the equation at one known point. Both describe the same geometry when the line is not vertical. This page prints both so you can match a homework format without rewriting by hand.

How this page builds the equation

The engine requires two distinct finite points. When x1 equals x2 it returns x = that shared value and marks slope undefined. Otherwise it computes m from the two points, recovers b from the first point, and formats slope-intercept and point-slope strings. Coincident points raise an error because they do not determine a unique line.

When to use this calculator

Check algebra homework that names two points, turn a CAD sketch edge into y = mx + b, or confirm a trend line before you graph it. Great-circle paths and 3D space lines are not this form.

Limits

Plane Cartesian only. No polar form and no parametric vector form. IEEE floating point applies. CZNull does not receive the numbers.

Equation of a line questions

What equation do (0, 1) and (2, 5) produce?
Slope m = 2 and y-intercept b = 1, so y = 2x + 1. Point-slope through the first point is y - 1 = 2(x - 0).
What happens when both points share the same x?
The page reports a vertical line x = that value. Slope is undefined and y = mx + b does not apply.
Why must the two points be distinct?
One point alone does not fix a unique line. Identical coordinates raise an error so the form stays determined.
Does this page also print the x-intercept?
No. Use the x and y intercepts calculator once you have m and b, or rearrange y = mx + b yourself.
Is point-slope the same as slope-intercept?
They describe the same non-vertical line. Slope-intercept isolates b. Point-slope keeps an explicit known point.
Can I enter three points?
No. This form takes exactly two endpoints. A third point would be a collinearity check, which is a different job.