Boneyard Tools

Slope and Line Calculator

Enter two points and this calculator returns the slope, the y-intercept, the equation of the line, the distance between the points, their midpoint and the angle the line makes with the x-axis. Every value updates as you type.

How to use the slope calculator

  1. Type the x and y coordinates of the first point.
  2. Type the x and y coordinates of the second point.
  3. Read the slope, equation, distance, midpoint and angle from the result cards.

Examples

Slope from two points

Point 1 = (0, 0), Point 2 = (2, 4)
Slope = 2, equation y = 2x, distance ≈ 4.4721

Vertical line

Point 1 = (3, 1), Point 2 = (3, 9)
Slope is undefined, equation x = 3

Frequently asked questions

How do you calculate the slope from two points?

Slope is the change in y divided by the change in x: m = (y2 − y1) / (x2 − x1). It tells you how steep the line is and whether it rises (positive) or falls (negative) from left to right.

Why is the slope of a vertical line undefined?

A vertical line has two points with the same x value, so the run (x2 − x1) is zero. Dividing the rise by zero is undefined, so there is no slope and the line is written as x = c instead of y = mx + b.

How is the equation of the line found?

Once the slope m is known, the y-intercept is b = y1 − m·x1, which gives the equation y = mx + b. A horizontal line becomes y = c and a vertical line becomes x = c.

How are the distance and midpoint computed?

The distance between the points is sqrt((x2 − x1)² + (y2 − y1)²) from the Pythagorean theorem. The midpoint is the average of the coordinates: ((x1 + x2) / 2, (y1 + y2) / 2).

What does the angle mean?

The angle is the direction of the line measured from the positive x-axis, computed with atan2(rise, run) and shown in degrees. A 45 degree angle means the line rises one unit for every unit it moves right.

Is my data sent anywhere?

No. Every calculation runs in your browser, so the coordinates you type are never uploaded or stored.

Related tools