↗ Linear Equation from Two Points

Find the slope and y-intercept of a line passing through two points.

No ratings yet — be the first

Enter details

Line through two points
A,B,
  • x₁ (first point)
  • y₁ (first point)
  • x₂ (second point)
  • y₂ (second point)

Log in or create a free account to save your inputs and results, so you don't have to enter them again next time.🔒 No spam, ever. We never sell or share your details, and you can delete your history or account at any time. Privacy policy

Fill in the details and click Calculate to see your results.

Rate this calculator

Was it useful? A quick star rating helps others — and you can leave a comment too.
Rate it: ★ ★ ★ ★ ★

📘 About the Line Equation Calculator

Two points are enough to fix a straight line. This calculator finds its slope and y-intercept and writes the equation three ways: slope-intercept form y = mx + b, point-slope form and standard form Ax + By = C.

It also gives the x-intercept, the distance between the points, the midpoint and the angle the line makes with the x-axis, with the working shown.

🧮 Formula

Where

  • (x1,y1) = first point
  • (x2,y2) = second point
  • m = slope
  • b = y-intercept
m = (y2 - y1)/(x2 - x1), then b = y1 - mx1.

✏️ Worked examples

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

You enter
x₁ (first point)1
y₁ (first point)3
x₂ (second point)4
y₂ (second point)9
You get
Slope-intercept formy = 2x + 1
Slope m2
y-intercept b1
x-intercept-0.5
Point-slope formy − 3 = 2(x − 1)
Standard form2x − y = -1
Distance between the points6.708203932
Midpoint(2.5, 6)
Angle with the x-axis63.4349°

y = 2x + 1.

Points (−2, 5) and (3, −5)

You enter
x₁ (first point)-2
y₁ (first point)5
x₂ (second point)3
y₂ (second point)-5
You get
Slope-intercept formy = −2x + 1
Slope m-2
y-intercept b1
x-intercept0.5
Point-slope formy − 5 = -2(x + 2)
Standard form2x + y = 1
Distance between the points11.18033989
Midpoint(0.5, 0)
Angle with the x-axis-63.4349°

y = −2x + 1; 2x + y = 1.

🧭 How to use this calculator

What you enter

  • x₁ (first point)
  • y₁ (first point)
  • x₂ (second point)
  • y₂ (second point)

What you get

  • Slope m
  • Y-intercept b

💡 Important

  • The two x-values must be different.
  • A vertical line has undefined slope and is not handled by this formula.

❓ Frequently asked questions

How do you find the equation of a line from two points?

Find the slope m = (y₂ − y₁) ÷ (x₂ − x₁), then the intercept b = y₁ − m·x₁, and write y = mx + b.

What is point-slope form?

y − y₁ = m(x − x₁). It uses the slope and one point directly.

What if x₁ = x₂?

The line is vertical: its equation is x = x₁ and the slope is undefined.