Equation of a Line Calculator
This calculator works out the equation of a straight line in three standard forms: slope-intercept form (y = mx + b), point-slope form (y - y1 = m(x - x1)), and standard form (Ax + By = C), along with the line's x-intercept. Choose the method that matches what you already know: enter two points on the line, enter one point together with a known slope, or enter a slope and y-intercept directly. The calculator then returns the slope (m), the y-intercept (b), and the x-intercept at a glance, and shows the fully written-out equation in all three forms side by side so you can use whichever suits your working. Below that sits a step-by-step panel showing exactly how the slope and intercept were derived from your figures, along with a worked example using the default points (1, 3) and (4, 9) as a check. This suits checking homework, plotting a line from data points, or converting an equation between forms for further algebra. Two special cases are handled automatically: if your two points share the same x-coordinate the line is vertical, the slope is undefined, and the equation is shown as x equals that constant; if they share the same y-coordinate the line is horizontal with a slope of zero. Results are rounded to six significant figures, so very long decimals appear as close approximations rather than exact fractions.
1. Input Method
2. Results at a Glance
Step-by-Step Working
Worked Example (default inputs)
How to Find the Equation of a Line
A straight line in a two-dimensional plane is described completely by its slope (gradient) and any one point through which it passes. From these two pieces of information, you can express the line in any standard form. The three most common forms are:
| Form | Equation | When to use |
|---|---|---|
| Slope-intercept | y = mx + b | When you know or need the slope and y-intercept directly |
| Point-slope | y - y1 = m(x - x1) | When you have a specific point and the slope, before finding b |
| Standard form | Ax + By = C | For comparing lines, or when integer coefficients are preferred |
Finding the Equation from Two Points
Given two points (x1, y1) and (x2, y2), follow these steps:
- Calculate the slope: m = (y2 - y1) / (x2 - x1). The slope tells you how much y changes for every 1 unit increase in x.
- Find the y-intercept: Substitute the slope and one point into y = mx + b and solve for b: b = y1 - m * x1.
- Write the equation: Substitute m and b into y = mx + b.
Example: points (1, 3) and (4, 9). Slope = (9 - 3) / (4 - 1) = 2. Y-intercept = 3 - 2 * 1 = 1. Equation: y = 2x + 1.
Special Cases
Vertical lines: When two points share the same x-coordinate, the slope is undefined (division by zero). The line is expressed as x = constant, for example x = 3. Vertical lines have no y-intercept unless they pass through the origin.
Horizontal lines: When two points share the same y-coordinate, the slope is 0. The equation is simply y = b, where b is the shared y-value. For example, through (2, 5) and (7, 5): y = 5.
Converting Between Forms
Starting from slope-intercept form y = mx + b, you can convert to standard form by moving all terms to one side: mx - y = -b. To ensure the coefficient of x is positive, multiply through by -1 if needed: -mx + y = b, or equivalently Ax + By = C.
To convert from standard form Ax + By = C back to slope-intercept, solve for y: y = (-A/B)x + C/B.
Using the X-intercept
The x-intercept is the point where the line crosses the x-axis (where y = 0). Set y = 0 in the slope-intercept equation: 0 = mx + b, so x = -b/m. For y = 2x + 1, the x-intercept is x = -1/2 = -0.5.
Related Calculators
- Maths and Stats Calculators: full collection of maths tools.
- Slope Calculator: find the gradient between two points.
- Average Rate of Change Calculator: change in y over change in x.
- Distance Calculator: straight-line distance between two coordinates.
- System of Equations Solver: find where two or more lines intersect.
Sources and method: Coordinate geometry: slope formula m = (y2 - y1) / (x2 - x1); slope-intercept form y = mx + b; point-slope form y - y1 = m(x - x1); standard form Ax + By = C. Standard algebra textbook derivations.
This calculator works with real numbers. Results are rounded to 6 significant figures for display. For lines expressed as fractions, the exact decimal approximation is shown. Vertical lines (undefined slope) are noted but cannot be expressed in slope-intercept or point-slope form.