Line Equation Calculator
Writing a Line Down to Its Equation
Two points are all it takes to pin down a straight line completely — the slope tells you how steeply it rises or falls, and the intercept tells you where it crosses the y-axis. This calculator takes either two coordinate pairs, or a slope and a single point, and reduces them to the familiar y = mx + b form so the line can be graphed, compared, or plugged into further algebra.
The Formula
From two points, the slope comes first, then the intercept is solved from either point:
b = y1 − m × x1
Equation: y = mx + b
Given a slope and a single point instead, the same intercept step applies directly: b = y − m×x. If x1 equals x2, the slope is undefined and the result is a vertical line, x = x1, which cannot be expressed in slope-intercept form.
Worked Example
For the points (1, 2) and (3, 8):
| Step | Calculation | Result |
|---|---|---|
| Slope | (8 − 2) / (3 − 1) | 3 |
| Intercept | 2 − 3 × 1 | −1 |
| Equation | — | y = 3x − 1 |
Where This Comes Up
- Trend lines — fitting a straight-line relationship between two measured data points, such as cost versus quantity.
- Physics motion problems — position versus time when velocity is constant produces a line whose slope is the velocity.
- Coordinate geometry proofs — establishing a line's equation is often the first step before checking parallelism, perpendicularity, or intersections.
- Graphing and plotting software — converting raw coordinate data into an equation that a plotting tool or spreadsheet can use directly.
How to Use This Calculator
- Choose the calculation mode: From Two Points or From Slope and a Point.
- For two points, enter X1, Y1, X2, and Y2.
- For slope and a point, enter the slope (m), then X and Y for the known point.
- Select Calculate to get the line's equation in
y = mx + bform, or the vertical-line form if applicable.
Related Calculations
Once you have a line's equation, check the Parallel Line Calculator or Perpendicular Line Calculator to build a related line through a different point.