Equation of a Line Calculator
An equation of a line calculator builds slope m, y-intercept b, slope-intercept form, point-slope form, standard form, and the x-intercept from two points, from a point plus slope, or from m and b directly. Vertical segments report x = constant with undefined slope.
How to find the equation of a line
- Choose Start from: two points, point and slope, or slope and y-intercept.
- Enter the fields that appear. Default two points are (0, 1) and (2, 5).
- Read slope m, y-intercept b, x-intercept, slope-intercept, point-slope, and standard form.
- If both x values match, read the vertical equation x = constant. Open intercepts or slope pages for related jobs.
Equation of a Line Calculator
Plane line from points or slope data
| Slope formula | m = (y2 - y1) / (x2 - x1) when x1 != x2 |
|---|---|
| Y-intercept | b = y1 - m x1 |
| X-intercept | -b / m when m != 0 |
| Slope-intercept form | y = mx + b |
| Point-slope form | y - y1 = m(x - x1) |
| Vertical line | x = x1 when both points share the same x |
What an equation of a line calculator returns
An equation of a line calculator describes the unique non-vertical line through known data as y = mx + b, plus matching point-slope and standard forms. Slope m is rise over run. 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, point-slope, and standard forms
Slope-intercept writes the line with slope and the intercept on the y-axis: y = mx + b. Point-slope keeps the same slope but anchors at a known point: y - y1 = m(x - x1). Standard form here rearranges to Ax + By = C from y = mx + b (with B = -1). All three describe the same geometry when the line is not vertical.
How this page builds the equation
From two distinct points, the engine computes m = (y2 - y1)/(x2 - x1) when x differs, then b = y1 - m x1. From a point and slope it recovers b the same way. From m and b it starts in slope-intercept form. When x1 equals x2 it returns x = that shared value and marks slope undefined. Coincident points raise an error because they do not determine a unique line. Horizontal lines (m = 0) report y = b and no x-intercept.
Equation of a line worked examples
Two points (0, 1) and (2, 5): m = (5 - 1)/(2 - 0) = 2, b = 1, so y = 2x + 1. Point-slope through the first point: y - 1 = 2(x - 0). X-intercept = -1/2 = -0.5. Standard form: 2x + (-1)y = -1.
Vertical: points (3, 1) and (3, 8) give x = 3 with undefined slope.
Horizontal: m = 0 and b = 4 give y = 4 with no x-intercept.
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. Coefficients stay in decimal float form (no forced integer clearing). IEEE floating point applies. CZNull does not receive the numbers.