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
How to find the equation of a line
- Enter the first point as x1 and y1. The default first point is (0, 1).
- Enter the second point as x2 and y2. The default second point is (2, 5).
- Read slope m, y-intercept b, slope-intercept form, and point-slope form under the form.
- If the x values match, read the vertical equation x = constant. Slope stays undefined for that case.
- 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 formula | m = (y2 - y1) / (x2 - x1) when x1 ≠ x2 |
|---|---|
| Y-intercept | b = y1 - m x1 |
| Slope-intercept form | y = mx + b |
| Point-slope form | y - y1 = m(x - x1) |
| Default example | (0, 1) and (2, 5) give m = 2 and y = 2x + 1 |
| Vertical line | x = 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.