Skip to content
CalculatorAtlas

Line Equation from Two Points Calculator

Tested

Equation of the line through two points.

Tested, not yet published. The formula for this calculator is implemented and passes its automated checks. This page stays non-indexable until it is reviewed and published.

Results

Enter your values and press Calculate. Results appear here.

  • • Result

Quick answer

Slope m = (y₂ − y₁) ÷ (x₂ − x₁), and the line is y = mx + b. Through (1, 2) and (3, 6) the slope is 2 and the line is y = 2x.

Enter two points. The calculator returns the line equation and slope. Use this line equation from two points calculator to check your own figures.

Related tools: Linear Equation Calculator: Solve ax + b = c for x. Angle Between Two Vectors Calculator: Angle between two vectors. Slope Calculator: Slope, angle, distance and line equation through two points.

How to use the Line Equation from Two Points Calculator

  1. Enter x₁.
  2. Enter y₁.
  3. Enter x₂.
  4. Enter y₂.
  5. Press Calculate to see the result, and use Reset to start again.
Inputs of the Line Equation from Two Points Calculator
InputWhat to enterAllowed values
x₁A number—
y₁A number—
x₂A number—
y₂A number—

Formula and method

Formula

m = (y₂ − y₁) ÷ (x₂ − x₁); y = mx + b

IEEE-754 double precision; shown to at most 6 decimal places.

Slope from the two points, then the intercept.

Worked examples

These examples are verified: each one is an automated test case that the live calculator must reproduce exactly.

Example 1

Inputs: x₁ = 1; y₁ = 2; x₂ = 3; y₂ = 6.

Results of example 1
ResultValue
Equationy = 2x
Slope2

Example 2

Inputs: x₁ = 0; y₁ = 1; x₂ = 2; y₂ = 0.

Results of example 2
ResultValue
Equationy = -0.5x + 1
Slope-0.5

Example 3

Inputs: x₁ = 3; y₁ = 0; x₂ = 3; y₂ = 9.

Results of example 3
ResultValue
Equationx = 3
Slopeundefined

The first line is the headline result (equation). Below it the line Equation from Two Points Calculator lists slope, which describe the same case from other angles. IEEE-754 double precision; shown to at most 6 decimal places.

Steps

m = (6 − 2) ÷ (3 − 1) = 2. Substitute (1, 2): 2 = 2(1) + b, so b = 0. The line passes through the origin.

Special cases

Vertical lines have undefined slope and are reported as x = c. The points must be distinct. For a horizontal line, y₂ = y₁ and the slope is 0.

How the result changes with x₁

Holding every other input at the first worked example, this table changes only x₁. It shows how sensitive the answer is to that one value; each row was produced by running this calculator.

How the result changes with x₁
x₁EquationSlope
0.5y = 1.6x + 1.21.6
1y = 2x2
2y = 4x − 64
4y = -4x + 18-4

What happens with invalid input

These messages are produced by the calculator itself, so you know what to fix.

  • x₂: entering "1" shows "The points must be different." beside that field and no result.

Choosing between the Line Equation from Two Points Calculator and similar calculators

Each row shows what a related calculator on this site asks for and what it returns, so you can pick the one that matches your question.

Choosing between the Line Equation from Two Points Calculator and similar calculators
CalculatorYou enterIt returns
[Linear Equation Calculator](/math/linear-equation-calculator/)a, b and cx
[Angle Between Two Vectors Calculator](/math/angle-between-two-vectors/)vector A and vector BAngle
[Slope Calculator](/math/slope-calculator/)x₁, y₁ and x₂Slope
[LCM Calculator](/math/lcm-calculator/)numbersLeast common multiple
[Factor Calculator](/math/factor-calculator/)numberFactors

Background: algebra

Many algebra calculators rest on the same ideas: write the problem in a standard form, identify the coefficients, apply the formula and check the answer by substituting it back. For a quadratic ax² + bx + c = 0 the roots are (−b ± √(b² − 4ac)) ÷ 2a, and the discriminant b² − 4ac decides the kind of roots: positive gives two real roots, zero gives one repeated root and negative gives two complex conjugate roots.

If a = 0 the equation is linear, not quadratic. A sign slip on the −b term shifts both roots by the same amount, so substitute your roots back to check.

Assumptions and limitations

  • Distinct points
  • Vertical lines reported as x = c

If a required value is empty, not a number, or outside its allowed range, the form marks that field with a message and shows no result instead of a misleading number. The automated checks deliberately try invalid entries for x₂ to confirm this.

Frequently asked questions

What is the line through (0, 1) and (2, 5)?

The slope is (5 − 1) ÷ (2 − 0) = 2 and the intercept is 1, so y = 2x + 1.

What if x₁ = x₂?

It's a vertical line.

How do I find the y-intercept?

Substitute a point into y = mx + b.

What does the Line Equation from Two Points Calculator calculate?

Equation of the line through two points. It returns Equation and Slope.

What formula does the Line Equation from Two Points Calculator use?

m = (y₂ − y₁) ÷ (x₂ − x₁); y = mx + b. Slope from the two points, then the intercept.

What do I need to enter in the line Equation from Two Points Calculator?

You enter x₁, y₁, x₂ and y₂.

How is the result rounded or limited?

IEEE-754 double precision; shown to at most 6 decimal places. Distinct points.

What are the limits of this calculator?

Distinct points. Vertical lines reported as x = c.

What is an example of a line Equation from Two Points result?

With x₁ 1, y₁ 2, x₂ 3 and y₂ 6, the equation is y = 2x.

Sources

  • OpenStax, Algebra and Trigonometry 2e (Rice University): exponents, radicals, logarithms and inverse trigonometric functions

Content last reviewed 2026-11-04. Formulas and worked examples are checked by automated tests against independently computed values.