Tools · Math & Statistics

Slope & Line Equation Calculator

Give two points and get the slope, the y-intercept, and the line written three ways — slope-intercept, point-slope and standard form — along with the distance between the points, their midpoint, and the angle the line makes with the horizontal.

Vertical lines reported as undefined, not infiniteHow it worksInputs stay on this device
Your inputs

Two points on the line

The across coordinate of the point you start from.

The up coordinate of that same point. Point-slope form is anchored here.

The across coordinate of the second point. Matching it to x₁ makes the line vertical.

The up coordinate of the second point. Matching it to y₁ makes the line level.

Your inputs are calculated locally and are not stored.
Slope2

The line climbs 6 for every 3 it runs across — an inclination of 63.4349° from the horizontal.

Slope-intercept form
y = 2x
Point-slope form
y - 2 = 2(x - 1)
Standard form
2x - y = 0
y-intercept
0
Rise (y₂ − y₁)
6
Run (x₂ − x₁)
3
Distance between the points
6.708204
Midpoint
(2.5, 5)
Angle of inclination
63.4349°
Formula & methodology

Rise over run, and what follows

Slope is one idea stated as a ratio: how far the line climbs for each unit it travels sideways. Every other figure on this page is that ratio put to work, or the geometry of the two points on their own.

m = (y₂ − y₁) ÷ (x₂ − x₁)  •  b = y₁ − m·x₁  •  θ = arctan m
m
The slope — rise per one unit of run
b
The y-intercept, where the line crosses x = 0
θ
The inclination, measured from the horizontal

The three equation forms are the same line dressed three ways. Slope-intercept, y = mx + b, is built to be graphed: it hands you a starting height and a rate. Point-slope, y − y₁ = m(x − x₁), is built to be written down the moment you know one point and the slope, with no intercept to work out first. Standard form, Ax + By = C, is built to be solved alongside another equation, and it is the only one of the three that can describe a vertical line.

Standard form here is computed straight from the coordinates — A = y₂ − y₁, B = x₁ − x₂, C = Ax₁ + By₁ — with no division anywhere in that sequence. Whole-number coordinates therefore give whole-number coefficients, which are then divided by their greatest common divisor and signed so the leading coefficient is positive. Going through the decimal slope first would turn the exact line x − 3y = −3 into y = 0.333333x + 1 and back out as something that no longer passes through the points you typed.

The distance between the points is Pythagoras on the rise and the run, √(rise² + run²), and the midpoint is the plain average of the two x values paired with the average of the two y values. Neither depends on the slope, which is why both are still reported for a vertical line.

Worked example

The line through (1, 2) and (4, 8)

The rise is 8 − 2 = 6 and the run is 4 − 1 = 3, so the slope is 6 ÷ 3 = 2: the line climbs two units for every one it moves across. The y-intercept is 2 − 2×1 = 0, which puts the line through the origin, so slope-intercept form is simply y = 2x. Anchored on the first point, point-slope form is y − 2 = 2(x − 1). For standard form, A = 6, B = −3 and C = 6×1 − 3×2 = 0; all three divide by 3, giving 2x − y = 0.

The geometry of the pair follows separately. The distance is √(3² + 6²) = √45 = 6.708204. The midpoint is ((1 + 4) ÷ 2, (2 + 8) ÷ 2) = (2.5, 5). The inclination is arctan 2 = 63.4349° above the horizontal — steep, but nothing like the 90° a vertical line would sit at.

Now move the first point to (3, 2) and the second to (3, 8). The run becomes 3 − 3 = 0, and the slope formula asks for 6 ÷ 0. This is where most calculators quietly hand back Infinity. The honest answer is that the line has no slope, no y-intercept unless it happens to be the y-axis itself, and no slope-intercept or point-slope form at all — but it does have a standard form, x = 3, and a perfectly ordinary distance of 6 and midpoint of (3, 5).

Assumptions

What this calculator assumes

  • The two points are different. A single point lies on infinitely many lines, so the calculator asks you to move one rather than inventing a slope for it.
  • Standard form is reduced to whole numbers only when the coordinates are whole numbers. There is no integer form to reduce to when a coordinate is 1.5, so the coefficients are printed as decimals instead.
  • The angle is the inclination, reported from 0° up to but not including 180°, measured counter-clockwise from the positive x-axis. A falling line therefore reads 116.5651° rather than −63.4349°; they describe the same line.
  • Figures are rounded to six decimal places, and the angle to four. A slope of one third displays as 0.333333, but the equation forms are built from the exact coordinates, not from that rounded value.
  • Coordinates are limited to ±10,000,000 so that the standard-form coefficients stay inside the whole numbers a computer can hold exactly. Two points closer together in x than the arithmetic can distinguish from equal are refused rather than given a slope of ten trillion.
  • The plane is flat and the units are yours. Slope is unitless only when the two axes share a unit — a grade of 0.06 on a road is metres up per metre along.
Common questions

Slope and line equation FAQ

Why is a vertical line's slope undefined rather than infinite?

Because slope is a ratio — rise per one unit of run — and a vertical line has no run at all. The question 'how much does it climb per step across?' has no answer when there is no step across to take, and that is a different thing from the answer being enormous. Calling it infinite also breaks the arithmetic that follows: two vertical lines would have equal slopes yet no defined difference, and the perpendicular rule (m₁ × m₂ = −1) would need infinity times zero. Most calculators divide by zero anyway, get the floating-point value Infinity, and print it. This one reports the slope as undefined and gives you the one equation form that still works: x = c.

What does a negative slope mean, and what does a zero slope mean?

A negative slope means the line falls as you read left to right: every step across takes you down. A slope of −2 falls two units for every one across. Zero slope means the line is level — it climbs nothing over any distance, so the equation collapses to y = b, a constant height. The two are genuinely different from an undefined slope: zero is a number the line has, undefined is the absence of one. A road sign reading 6% grade is quoting a slope of 0.06; the same hill descending is −0.06.

How do I turn slope-intercept form into standard form?

Multiply out any fractions, then move the x term to the left. Starting from y = 0.333333x + 1, the exact fraction is one third, so multiply both sides by 3 to get 3y = x + 3, then subtract to get x − 3y = −3. That is why this calculator computes standard form from the coordinates directly rather than from the decimal slope: 0.333333 is not one third, and reducing it would give x − 3.000003y = −3 instead. Standard form is conventionally written with whole-number coefficients that share no common factor and a positive leading coefficient, which is what you get here whenever the points you type are whole numbers.

How is the angle of inclination related to the slope?

The slope is the tangent of the angle. A line rising 2 for every 1 across makes an angle whose tangent is 2, so the angle is arctan 2 = 63.4349°. Run it the other way and a 45° line has slope tan 45° = 1 exactly. The angle is reported here between 0° and 180°, measured counter-clockwise from the positive x-axis, because a line has no direction — arctan(−2) returns −63.4349°, and adding a half turn gives 116.5651° for the same line. A vertical line sits at exactly 90°, which is the one angle arctan can never produce, and is another way of seeing why its slope is undefined.

Does it matter which point I enter first?

Not for the slope, the distance, the midpoint or the equation. Swapping the points negates both the rise and the run, and a negative divided by a negative is the same ratio. It does change two things on this page: the rise and run rows show the signed differences in the order you gave them, and point-slope form is anchored on whichever point you entered first — y − 2 = 2(x − 1) and y − 8 = 2(x − 4) describe exactly the same line.

Primary sources

Sources and review notes

  1. OpenStax, College Algebra 2e §4.1 — slope-intercept and point-slope form, and the definition of slope as rise over run
  2. OpenStax, College Algebra 2e §2.1 — the distance and midpoint formulas used for the pair of points
  3. Wolfram MathWorld, Slope — slope as the tangent of the angle of inclination

The arithmetic here is exact and has no data behind it to go stale: a ratio, a square root, an average and an arctangent. The sources are cited for the naming conventions — which form is called standard, and how the angle of inclination is measured — rather than for the calculation.