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
- Enter x₁.
- Enter y₁.
- Enter x₂.
- Enter y₂.
- Press Calculate to see the result, and use Reset to start again.
| Input | What to enter | Allowed 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.
| Result | Value |
|---|---|
| Equation | y = 2x |
| Slope | 2 |
Example 2
Inputs: x₁ = 0; y₁ = 1; x₂ = 2; y₂ = 0.
| Result | Value |
|---|---|
| Equation | y = -0.5x + 1 |
| Slope | -0.5 |
Example 3
Inputs: x₁ = 3; y₁ = 0; x₂ = 3; y₂ = 9.
| Result | Value |
|---|---|
| Equation | x = 3 |
| Slope | undefined |
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.
| x₁ | Equation | Slope |
|---|---|---|
| 0.5 | y = 1.6x + 1.2 | 1.6 |
| 1 | y = 2x | 2 |
| 2 | y = 4x − 6 | 4 |
| 4 | y = -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.
| Calculator | You enter | It returns |
|---|---|---|
| [Linear Equation Calculator](/math/linear-equation-calculator/) | a, b and c | x |
| [Angle Between Two Vectors Calculator](/math/angle-between-two-vectors/) | vector A and vector B | Angle |
| [Slope Calculator](/math/slope-calculator/) | x₁, y₁ and x₂ | Slope |
| [LCM Calculator](/math/lcm-calculator/) | numbers | Least common multiple |
| [Factor Calculator](/math/factor-calculator/) | number | Factors |
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.
Related calculators
- 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.
- LCM Calculator — Least common multiple of two or more numbers.
- Factor Calculator — List every factor of a positive whole number.
- Quadratic Formula Calculator — Solve ax² + bx + c = 0, including complex roots.
- Rydberg Equation Calculator — Wavelength of a hydrogen spectral line between two energy levels.
- Net Ionic Equation Calculator — Balanced molecular, complete ionic and net ionic equations for common double-displacement reactions in water.
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.