keisoku

Line Through Two Points

Find the equation of the line through two points: slope, y-intercept, general form ax+by+c=0, distance and midpoint, plotted on a coordinate plane.

Input

Enter two points to compute the slope, y-intercept, general form and distance of the line through them, shown on a graph.

Point 1

Point 2

Result

(1, 2)(4, 8)

Slope m

2

y = 2 x + 0

y-intercept

0

x-intercept

-0

General form

6 x + -3 y + 0 = 0

Distance

6.708204

Midpoint

(2.5, 5)


The slope is m = (y2 - y1) / (x2 - x1) and the y-intercept is b = y1 - m x1. Equal x-coordinates are treated as a vertical line.

How it works

  • The slope is m = (y2 - y1) / (x2 - x1). When the two x-coordinates are equal the line is vertical and the slope is undefined.
  • The y-intercept is b = y1 - m times x1.
  • The general form a x + b y + c = 0 uses a = y2 - y1, b = x1 - x2, and c = x2 times y1 minus x1 times y2.
  • The distance between the points is sqrt((x2 - x1) squared plus (y2 - y1) squared).
  • If the two points coincide, the line is not uniquely determined and cannot be computed.

Reviews

Tell us what you think of this calculator.

Write a review

  1. Home
  2. Line Through Two Points