Slope Calculator

Type the (x, y) coordinates of two points. The calculator returns the slope of the line through them plus the full line equation, midpoint, straight-line distance and the angle the line makes with the x-axis.

#math#geometry#slope#gradient#line-equation

Slope (m)

m = 2 → y = 2x

Rise (Δy = y₂ − y₁)
6
Run (Δx = x₂ − x₁)
3
y-intercept (b)
0
Distance between points
6.71
Midpoint x
2.5
Midpoint y
5
Angle of line (°)
63.43

Slope m = (y₂ − y₁) / (x₂ − x₁). The line equation y = mx + b uses b = y₁ − m·x₁. Distance between the points is √(Δx² + Δy²) by Pythagoras; midpoint is the mean of each coordinate; angle is arctan(m).

How to use this calculator

Enter the (x, y) coordinates of two points on a line. The calculator immediately returns the slope m, the full line equation y = mx + b, the midpoint, the straight-line distance between the points, and the angle the line makes with the positive x-axis.

How the calculation works

For two distinct points (x₁, y₁) and (x₂, y₂), the slope is m = (y₂ − y₁) / (x₂ − x₁) — "rise over run". Plugging one point back into y = mx + b gives the y-intercept b = y₁ − m·x₁. The straight-line distance is √((x₂ − x₁)² + (y₂ − y₁)²) by Pythagoras, the midpoint is ((x₁ + x₂)/2, (y₁ + y₂)/2), and the angle of inclination is arctan(m). Vertical lines (x₁ = x₂) have an undefined slope and are written as x = constant; horizontal lines have slope 0 and equation y = constant.

Worked example

Take the default points (1, 2) and (4, 8). Rise = 8 − 2 = 6. Run = 4 − 1 = 3. Slope m = 6 / 3 = 2. y-intercept b = 2 − 2·1 = 0, so the line equation is y = 2x. Distance = √(3² + 6²) = √45 ≈ 6.708. Midpoint = (2.5, 5). Angle of inclination = arctan(2) ≈ 63.43°.

Frequently asked questions

What does the slope of a line actually measure?

Slope is the rate of vertical change per unit of horizontal change — "rise over run". A slope of 2 means y increases by 2 for every 1 unit increase in x. Slope 0 is a horizontal line, slope "undefined" is a vertical line, and negative slopes run downhill left-to-right.

What if the two points are the same?

Two identical points do not define a unique line — infinitely many lines pass through a single point. The calculator detects this and tells you no line is defined rather than reporting an indeterminate 0/0.

What if x₁ = x₂ (a vertical line)?

A vertical line has run = 0, so slope = rise / 0 is undefined. The calculator reports "Undefined" and writes the line as x = constant. Distance, midpoint and angle (90°) are still well-defined for a vertical segment.

How do I get the line equation in y = mx + b form?

Once you have the slope m, pick either of your two points (x₁, y₁) and solve b = y₁ − m·x₁. Put it together as y = mx + b. The calculator does both steps for you and shows the cleaned-up equation right under the slope value.

What is the distance formula?

The straight-line (Euclidean) distance between (x₁, y₁) and (x₂, y₂) is √((x₂ − x₁)² + (y₂ − y₁)²). It is a direct application of the Pythagorean theorem to the right triangle formed by the horizontal and vertical gaps between the two points.

What angle does the calculator report?

The angle of inclination — the angle the line makes with the positive x-axis, measured anti-clockwise, in degrees. It is arctan(slope). Slope 1 gives 45°, slope 0 gives 0°, slope −1 gives −45°, and a vertical line is reported as 90°.