Skip to main content

Slope Calculator

Enter two points and this tool works out everything about the line through them: the slope, the distance between the points, the midpoint, the x- and y-intercepts, the angle the line makes with the x-axis, and its equation in all three standard forms. The arithmetic is exact — slopes and intercepts are fractions, not rounded decimals — and the special cases are stated honestly: a vertical line reports its slope as undefined, and two identical points are refused, because no single line is defined by one point.

Slope (m)

2

Rise over run: Δy ÷ Δx, exact.

Distance between the points

2√5

≈ 4.472135955 — the radical form is exact.

Midpoint

(2, 4)

Angle of inclination

63.4349488229°

Measured from the positive x-axis, to 10 decimal places.

y-intercept (b)

0

x-intercept

0

Slope-intercept form

y = 2x

Point-slope form

y − 2 = 2(x − 1)

Standard form

2x − y = 0

How it is worked out

  1. Δx = 2, Δy = 4; midpoint = (2, 4); distance = √(Δx² + Δy²) = √20 = 2√5 ≈ 4.472135955.
  2. m = Δy ÷ Δx = 4 ÷ 2 = 2; b = y₁ − m·x₁ = 0.
  3. Slope-intercept form: y = 2x. Standard form: 2x − y = 0.

Embed this calculator on your website →

The formula

m = (y₂ − y₁) ÷ (x₂ − x₁) · distance = √(Δx² + Δy²) · midpoint = ((x₁ + x₂)/2, (y₁ + y₂)/2)

  • slope (m) — rise over run: how much y changes for each unit x changes. Positive climbs, negative falls, zero is flat, and a vertical line has no slope at all (the run is zero, and dividing by zero is undefined — stated, not papered over).
  • three equation forms — slope-intercept y = mx + b (best for graphing), point-slope y − y₁ = m(x − x₁) (built straight from a point), and standard form Ax + By = C, printed integer-normalised: fractions cleared, divided by the common factor, A positive.
  • distance — the Pythagorean theorem on Δx and Δy; exact when the squared distance is a perfect square, otherwise a simplified radical with the decimal beside it.

Worked example: through (1, 2) and (3, 6): Δy ÷ Δx = 4 ÷ 2, so m = 2, midpoint (2, 4), distance 2√5 ≈ 4.472135955, equation y = 2x (standard form 2x − y = 0) — the default in the tool above.

How it works

Slope is a rate. On a graph of distance against time, the slope is speed; of price against quantity, it is the unit price. The number is always “change in y per one unit of x”, which is why the intercept b is the starting value — the y you get at x = 0.

Why standard form is normalised. The same line can be written 2x − y = 0, 4x − 2y = 0, or −2x + y = 0. To keep one canonical answer, this tool clears fractions, divides out the greatest common factor, and fixes the sign so A is positive (or A = 0 with B positive, for horizontal lines) — the convention textbooks use.

Examples

  • (1, 2) to (3, 6) — slope 2, angle of inclination 63.4349488229°, x- and y-intercepts both 0: the line passes through the origin.
  • (2, 1) to (2, 5) — a vertical line: slope undefined, equation x = 2, angle exactly 90°.
  • (0, 3) to (4, 3) — a horizontal line: slope 0, equation y = 3, and no x-intercept to report.

Frequently asked questions

Why is the slope of a vertical line 'undefined' and not infinity?

Slope is Δy ÷ Δx, and a vertical line has Δx = 0. Division by zero has no value — calling it infinity would break the equation forms (there is no b, because the line never crosses the y-axis unless it is the axis itself). The honest report is 'undefined', plus the line's actual equation, x = x₁.

Does the order of the two points matter?

No. Slope, distance, midpoint, and the final equations are identical whichever point you call first — Δy and Δx both change sign together, and their ratio does not. The point-slope form is written from the first point you entered, but it describes the same line.

What is the angle of inclination?

The angle the line makes with the positive x-axis, measured anticlockwise: a flat line is 0°, climbing lines sit between 0° and 90°, a vertical line is exactly 90°, and falling lines give a negative angle here (their slope is negative). It is the arctangent of the slope, printed to 10 decimal places.

Why did the tool refuse my points?

Only one refusal exists: the two points are the same point. Infinitely many lines pass through a single point, so slope, distance direction, and equation are genuinely not defined — the tool asks you to move one point rather than inventing a line.