Skip to main content
Skip to calculator
Advertisement

Last updated: August 1, 2026

Line Equation from Two Points Calculator

Quick Answer

This calculator builds the 2D equation of a line from two distinct points. It computes slope when possible, handles vertical lines correctly, reports the y-intercept for non-vertical cases, and also provides an equivalent standard form.

The line through the two points is {equation}.

Helpful
Not helpful
Save as image
Share
Embed
Cite
Write feedback

Formula

For non-vertical lines, slope m = (y₂ - y₁)/(x₂ - x₁) and point-slope form is y - y₁ = m(x - x₁). Vertical lines use x = x₁.

Where:

  • x₁=X-coordinate of the first point
  • y₁=Y-coordinate of the first point
  • x₂=X-coordinate of the second point
  • y₂=Y-coordinate of the second point
  • m=Line slope
Line Equation from Two Points CalculatorInputsEnter the known valueswith consistent units.FormulaFor non-vertical lines, slope m = (y₂ - y₁)/(x₂ - x₁) and point-slope form is y - y₁ = m(x - x₁). Vertical lines use x = x₁.OutputsRead the computedline equation and checks.
Visual workflow for the line equation from two points calculator.

Worked Examples

Points (0, 1) and (2, 5)

A rising line with integer slope and intercept.

  1. 1Slope = (5 - 1)/(2 - 0) = 2.
  2. 2Use y = mx + b and point (0,1) to get b = 1.
  3. 3Equation: y = 2x + 1.
Final Answer: y = 2x + 1

Points (3, -1) and (3, 4)

Vertical lines do not have a finite slope.

  1. 1The x-values are equal, so the line is vertical.
  2. 2Vertical lines use x = constant.
  3. 3Equation: x = 3.
Final Answer: x = 3

Points (-1, 4) and (3, 4)

Horizontal lines have zero slope.

  1. 1Slope = (4 - 4)/(3 - (-1)) = 0.
  2. 2A zero slope means the y-value stays constant.
  3. 3Equation: y = 4.
Final Answer: y = 4

Points (-2, 5) and (1, -1)

Negative slopes are handled automatically.

  1. 1Slope = (-1 - 5)/(1 - (-2)) = -6/3 = -2.
  2. 2Use point-slope or solve for b to get b = 1.
  3. 3Equation: y = -2x + 1.
Final Answer: y = -2x + 1

Introduction

Two distinct points determine exactly one line in the coordinate plane. This calculator turns those two points into a readable line equation, the slope, the y-intercept when it exists, and a matching standard form so you can move easily between graphing and algebra.

Start with the slope

For any non-vertical line, the first step is finding slope as rise over run. That slope tells you how fast y changes when x increases by one unit.

  • Subtract the y-values for the rise.

  • Subtract the x-values for the run.

  • Divide rise by run unless the run is zero.

Point-slope form

Once slope is known, substitute one of the points into y - y1 = m(x - x1). This is often the cleanest algebraic form for derivation.

  • Either point works.

  • Point-slope form is especially helpful before simplifying.

  • The calculator converts it into easier-to-read forms.

Slope-intercept form

When the line is not vertical, the calculator rewrites the answer as y = mx + b. That form is useful for graphing because the slope and y-intercept are visible immediately.

  • b = y1 - mx1.

  • Horizontal lines become y = constant.

  • Negative slopes are formatted with a minus sign.

Vertical-line case

If x1 = x2, the run is zero and slope is undefined. In that situation the correct equation is x = constant, not y = mx + b.

  • Vertical lines have no y-intercept unless x = 0.

  • The calculator reports slope as undefined.

  • Standard form stays equivalent to x = constant.

Validation rules

The two points must be distinct. If both coordinates match, there is no unique line because infinitely many lines could pass through a single point.

  • All four inputs must be finite numbers.

  • The point pair cannot be identical.

  • Vertical lines are valid even though slope is undefined.

Common use cases

Line equations are used in graphing, analytic geometry, linear modeling, computer graphics, and checking whether points lie on the same straight path.

  • Plotting a line from measured points.

  • Checking algebra homework.

  • Building linear relationships in spreadsheets or code.

FAQs

Why does a vertical line have undefined slope?

Slope divides rise by run. A vertical line has run equal to zero, and division by zero is undefined.

What if both points are the same?

Then there is no unique line equation, so the calculator returns an error instead of a misleading result.

Why is y = 4 a valid line equation?

A horizontal line is still a line. It simply has slope 0 and keeps the same y-value for every x.

Can I use decimal coordinates?

Yes. The calculator formats decimal slopes and intercepts to a clean six-decimal representation when needed.

Why does the calculator show both equation and standard form?

Different classes and textbooks prefer different representations, so both are provided for convenience.

How can I verify the result?

Substitute both original points into the reported equation. Each point should satisfy the line exactly, subject to rounding for decimals.