calculator.onl
Categories50

Line through two points calculator

Find a straight-line equation, slope, axis intercepts and distance between two points, including vertical and horizontal lines.

A worked example

Move point B from (4, 4) to (1, 4). Both points now have x = 1, so the line is vertical.

Ax + By = Cy = 2x + 0Slope2y intercept0Distance6.7082
Horizontal coordinate of the first point. x₁: -1000000…1000000

Vertical coordinate paired with that first x value. y₁: -1000000…1000000

Horizontal coordinate of the second point in the same coordinate system. x₂: -1000000…1000000

Vertical coordinate paired with the second x value. y₂: -1000000…1000000

Updates as you type

Use a dot or comma for decimals. No thousands separators.

YOUR RESULT

Ax + By = C

y = 2x + 0

Calculated from your inputs

Slope2
y intercept0
x intercept0
Distance6.7082
The numbers, at a glance

Calculations run in your browser.
UNDERSTAND THE RESULT

A little context. A clearer answer.

↑ Back to calculator

When this calculator is useful

Form A=y2−y1, B=x1−x2 and C=Ax1+By1. The general equation Ax+By=C also represents vertical lines. When x coordinates differ, compute slope and the y intercept. The point distance uses the Euclidean formula. For a related calculation, try Linear regression and residuals.

What to enter

InputWhat it meansExample value
x₁Horizontal coordinate of the first point. x₁: -1000000…1000000 1
y₁Vertical coordinate paired with that first x value. y₁: -1000000…1000000 2
x₂Horizontal coordinate of the second point in the same coordinate system. x₂: -1000000…1000000 4
y₂Vertical coordinate paired with the second x value. y₂: -1000000…1000000 8

How the calculation works

  1. Change the inputs to explore your own scenario. x₁: -1000000…1000000 ; y₁: -1000000…1000000 ; x₂: -1000000…1000000 ; y₂: -1000000…1000000 .
  2. A=y₂−y₁; B=x₁−x₂; C=Ax₁+By₁; Ax+By=C; m=−A/B
  3. Two distinct points define one infinite straight line. Repeated points are rejected. A vertical slope is undefined. A coincident axis has infinitely many intersections. The drawing uses a local coordinate window; it is not a regression fit.
The formulaA=y₂−y₁; B=x₁−x₂; C=Ax₁+By₁; Ax+By=C; m=−A/B

A worked example

(1,2) and (4,8) → y=2x, slope 2, both axis intercepts 0, distance √45≈6.7082039325. Points (3,−1),(3,5) give x=3 and an undefined slope.

Example you can load

What to enter
Result for this example · Ax + By = Cy = 2x + 0

This is a fixed example; changing the form above does not change these numbers.

Assumptions & limits

Two distinct points define one infinite straight line. Repeated points are rejected. A vertical slope is undefined. A coincident axis has infinitely many intersections. The drawing uses a local coordinate window; it is not a regression fit.

Frequently asked questions

Does the calculator fit a line to noisy data?

No. It constructs the exact line defined by two entered points. Use linear regression for a larger measured data set.

What happens for a vertical line?

The equation is x=constant. The slope is unavailable; intersection with the y axis is absent unless the line is the y axis itself.

Why are repeated points rejected?

One distinct point lies on infinitely many lines and cannot determine a unique equation.