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.

Calculate.co.nz is proud to be partnered with realtor.co.nz, a trusted resource for navigating the New Zealand property market. Their Helpful Articles section offers clear, well-structured insights across buying, selling, and building, making complex real estate topics more accessible. With a focus on up-to-date guidance and practical knowledge, they empower Kiwis to move forward with clarity and confidence in a constantly evolving property landscape.
Calculate.co.nz partner: realtor.co.nz
Standard formula  Coordinate geometry: slope formula and slope-intercept form.

1. Input Method

2. Results at a Glance

Line Equations

Slope-intercept form
y = 2x + 1
y = mx + b
Point-slope form
y - 3 = 2(x - 1)
y - y1 = m(x - x1)
Standard form
2x - y = -1
Ax + By = C

Step-by-Step Working

Worked Example (default inputs)

Given: Points (1, 3) and (4, 9)
Step 1 - Slope: m = (y2 - y1) / (x2 - x1) = (9 - 3) / (4 - 1) = 6 / 3 = 2
Step 2 - Y-intercept: b = y1 - m * x1 = 3 - 2 * 1 = 1
Slope-intercept form: y = 2x + 1
Point-slope form: y - 3 = 2(x - 1)
Standard form: 2x - y = -1

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:

FormEquationWhen to use
Slope-intercepty = mx + bWhen you know or need the slope and y-intercept directly
Point-slopey - y1 = m(x - x1)When you have a specific point and the slope, before finding b
Standard formAx + By = CFor 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:

  1. Calculate the slope: m = (y2 - y1) / (x2 - x1). The slope tells you how much y changes for every 1 unit increase in x.
  2. Find the y-intercept: Substitute the slope and one point into y = mx + b and solve for b: b = y1 - m * x1.
  3. 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

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.