← Coordinate Geometry /

Slope Calculator

Find the slope from two points or from a point and the slope, with steps. Get slope-intercept, point-slope and standard form plus perpendicular slopes.

Reviewed by Geometry Calculator, Geometry Calculator Developer & Online Math Educator Last updated November 23, 2026

Slope Calculator

ℹ Pick what you know: two points, a point and the slope, or the equation of the line. You get the slope plus the line in slope-intercept, point-slope and standard form.

Formulas Used in Slope Calculator

m = (y₂ − y₁) / (x₂ − x₁)
Parallel: equal slopes
Perpendicular: m₁ × m₂ = −1

In-Depth Tutorial: Slope Calculator

The Geometry Slope Calculator computes the slope of a straight line through two given points. Slope is one of the most fundamental concepts of coordinate geometry — it measures steepness, defines what "parallel" and "perpendicular" mean algebraically, and bridges geometry with algebra (the y = mx + b form) and calculus (the slope of a curve at a point IS the derivative). This tutorial covers what slope means, how the calculator computes it, the parallel/perpendicular tests, and edge cases like vertical and horizontal lines.

The slope formula

Given two points P₁ = (x₁, y₁) and P₂ = (x₂, y₂), the slope of the line through them is:

m = (y₂ − y₁) / (x₂ − x₁)

Often described as "rise over run" — the vertical change (rise) divided by the horizontal change (run). The result tells you how many units the line moves up (or down) for every 1 unit it moves to the right.

What different slopes look like

  • Positive slope (m > 0): line rises from left to right. A slope of 1 means 1 unit up per 1 unit right (45° angle). A slope of 2 is steeper; 0.5 is shallower.
  • Negative slope (m < 0): line falls from left to right.
  • Zero slope (m = 0): horizontal line. y is constant — no rise as you move right.
  • Undefined slope (x₁ = x₂): vertical line. The denominator x₂ − x₁ is 0 — division by zero — so slope cannot be expressed as a real number. Vertical lines have no slope, not "infinite slope".

Worked examples

Example 1 — positive slope: P₁ = (2, 3), P₂ = (5, 9). m = (9 − 3) / (5 − 2) = 6 / 3 = 2. Line rises 2 units for every 1 unit right.

Example 2 — negative slope: P₁ = (1, 4), P₂ = (3, 0). m = (0 − 4) / (3 − 1) = −4 / 2 = −2. Line falls 2 units per 1 unit right.

Example 3 — horizontal: P₁ = (0, 5), P₂ = (7, 5). m = (5 − 5) / (7 − 0) = 0 / 7 = 0. Flat line.

Example 4 — vertical (undefined): P₁ = (3, 0), P₂ = (3, 8). m = (8 − 0) / (3 − 3) = 8 / 0 = undefined. The line is vertical (x always equals 3).

Does the order of the points matter?

No — as long as you are consistent. If you swap which point is "1" and which is "2", both the numerator and denominator change sign. The two negatives cancel:

(y₁ − y₂) / (x₁ − x₂) = −(y₂ − y₁) / −(x₂ − x₁) = (y₂ − y₁) / (x₂ − x₁)

What you cannot do: subtract y₂ − y₁ in the numerator but x₁ − x₂ in the denominator. That would give a slope of the wrong sign.

Parallel lines

Two non-vertical lines are parallel if and only if they have the same slope:

m₁ = m₂

Geometric intuition: same rise/run means same direction of "lean". Two lines with equal slopes never intersect (unless they are the same line). Two vertical lines are also parallel — they share the trivial "undefined slope" classification.

Perpendicular lines

Two lines (neither vertical) are perpendicular if and only if their slopes multiply to −1:

m₁ × m₂ = −1

Equivalently: each slope is the negative reciprocal of the other. If m₁ = 2/3, then a perpendicular line has slope m₂ = −3/2.

Why this works: a line with slope m rotated 90° has slope −1/m. The negative comes from the orientation reversal (rise becomes run, run becomes rise); the reciprocal comes from swapping the roles of horizontal and vertical change.

Edge case: a horizontal line (m = 0) is perpendicular to a vertical line (undefined slope). The product 0 × (undefined) is also undefined, so the m₁ × m₂ = −1 rule is the limit of this case rather than a direct application.

From two points to the equation of the line

Once you have the slope, you can write the equation of the line in point-slope form:

y − y₁ = m(x − x₁)

Or rearrange to slope-intercept form: y = mx + b, where b = y-intercept.

Example: from P₁ = (2, 3) with slope m = 2: y − 3 = 2(x − 2), i.e., y = 2x − 1. The y-intercept is −1; at x = 0, y = −1.

Slope as the angle of inclination

If θ is the angle the line makes with the positive x-axis (measured counterclockwise), then:

m = tan(θ)

So a 45° line has slope tan(45°) = 1. A 60° line has slope tan(60°) = √3 ≈ 1.732. The connection between slope and angle is the foundation of every "angle of inclination" problem in physics (ramp angles, projectile launch angles, etc.).

Real-world applications

  • Road and ramp design. A 10% grade highway has a slope of 0.10 (10 units rise per 100 units run). Wheelchair ramps follow ADA guidelines limiting slope to 1:12 (m ≈ 0.083).
  • Stairs. Building codes specify maximum slope (rise/run) so stairs are walkable. A residential stair might be 7" rise / 11" run, giving m ≈ 0.636.
  • Linear regression. Statistics fits a line through data points; the line's slope is the regression coefficient.
  • Rate of change. In any time-series chart (price over time, temperature over time), slope is the rate of change. A stock chart's slope at a moment is the local price velocity.
  • Calculus. The slope of a curve at a point IS the derivative at that point. Calculus extends "slope" from straight lines to arbitrary differentiable curves.

Common mistakes

  • Subtracting in inconsistent orders. Use the SAME order for x and y. (y₂ − y₁) / (x₂ − x₁), not (y₂ − y₁) / (x₁ − x₂).
  • Writing "infinite" for vertical-line slope. The slope is undefined, not infinite. There is no real number that satisfies the equation.
  • Confusing the slope of x = 3 (vertical) with the slope of y = 3 (horizontal). Vertical has undefined slope; horizontal has slope 0.
  • For perpendicular slopes, forgetting the negative. The product is −1, not +1. Negative reciprocal, not just reciprocal.

Frequently Asked Questions – Slope Calculator

Slope (m) is rise over run: m = (y₂ − y₁) / (x₂ − x₁). Positive slope rises left to right; negative slope falls; zero slope is horizontal.

Two lines are perpendicular if their slopes multiply to −1 (m₁ × m₂ = −1). Each slope is the negative reciprocal of the other.

The slope is undefined — the line is vertical. Vertical lines have no slope in the traditional sense and cannot be expressed in slope-intercept form.

Point-slope form is y − y₁ = m(x − x₁), where m is the slope and (x₁, y₁) is any point on the line. For slope 2 through (1, 4) it is y − 4 = 2(x − 1). Choose "A point and the slope" above to get it with your own numbers.

Distribute m and move y₁ to the right side: y − 4 = 2(x − 1) becomes y = 2x − 2 + 4, so y = 2x + 2. The constant you end up with is the y-intercept b.

Standard form is Ax + By = C with whole numbers A, B and C. Starting from y = (3/4)x + 2, multiply by 4 to get 4y = 3x + 8, then rearrange to 3x − 4y = −8.

Solve the equation for y. In y = mx + b the number in front of x is the slope. For 2x + 3y = 6: 3y = −2x + 6, so y = −(2/3)x + 2 and the slope is −2/3. Choose "The equation of the line" above to do it with your own equation.

Yes — free and unlimited.

Slope, pitch, grade, gradient — same concept, different vocabularies

The mathematical rise/run ratio the calculator computes goes by different names across professional fields, each with its own notation and typical unit. Recognizing the equivalences matters because a "12% grade highway" and "a line with slope 0.12" are the same steepness — just reported differently.

Slope (mathematics): reported as a pure decimal number. A slope of 0.5 means "0.5 units up per 1 unit horizontal." Positive rises left-to-right; negative falls. This is what algebra textbooks and this calculator use.

Grade or gradient (civil engineering, highways): reported as a percentage. A 10% grade means the road rises 10 meters per 100 meters horizontal — slope of 0.10. US Interstate highways cap grades at 6% for main routes; mountain roads may reach 12% or higher. The world's steepest street, Ffordd Pen Llech in Wales, reaches 37.45% grade (slope ≈ 0.375).

Pitch (roofing, carpentry): reported as a ratio like "6:12" meaning 6 inches of vertical rise per 12 inches of horizontal run — slope of 0.5. A "12:12" roof pitch is 45° (slope of 1). Common residential pitches range from 3:12 (shallow) to 12:12 (steep); 6:12 is typical for suburban homes.

Angle of inclination (physics, drafting): reported in degrees or radians. A 30° incline has slope tan(30°) ≈ 0.577. Ramp specifications, screw thread angles, and mechanical drafting all use degree measure. Convert with slope = tan(angle); convert back with angle = arctan(slope).

Gradient (physics, calculus, ML): in single-variable calculus, the "gradient" of a function is the slope of its tangent line at each point. In multi-variable calculus and machine learning, "gradient" generalizes to a vector of partial slopes. When a data scientist says "the gradient of the loss function," they mean a multi-dimensional slope. The English word came from geology (slope of terrain) and got adopted mathematically because the intuition transfers.

All five words describe the same mathematical object. This calculator's decimal output can be converted to any of the domain-specific formats: multiply by 100 for grade percentage, express as a ratio for roof pitch, take arctangent for angle in degrees.

When slope becomes numerically awkward

The slope formula m = (y₂ − y₁) / (x₂ − x₁) divides by a horizontal difference. For lines close to vertical, that denominator is tiny, and small measurement errors in the coordinates get amplified in the resulting slope.

Concrete numbers: two points measured with GPS at (100.005, 50.000) and (100.006, 60.000) have Δx = 0.001 and Δy = 10.000, giving slope 10,000. But if the GPS accuracy is ±0.001 in each coordinate, the true Δx could be anywhere between −0.001 and +0.003, which means the true slope could be anywhere from about 3,333 to negative infinity — a useless answer. Vertical lines are the limiting case where Δx = 0 exactly and slope is undefined altogether.

The fix in computational-geometry libraries is to switch representations. Instead of storing lines as "slope + intercept," store them as either:

  • Direction vector (Δx, Δy): no division, no undefined case, handles vertical lines cleanly. Two lines are parallel if their vectors are scalar multiples; perpendicular if their dot product is zero.
  • Angle of inclination θ = atan2(Δy, Δx): bounded output in (−π, π], well-defined for every line including vertical (which gives ±π/2). Small angular differences are numerically stable.
  • General form Ax + By = C: (A, B) is a normal vector, and parallelism/perpendicularity tests are single multiplications without division.

For pencil-and-paper geometry problems and typical exam inputs, the standard slope formula is fine. For engineering CAD, GIS software, or any calculation involving lines with near-vertical orientations, one of the alternative representations is worth adopting.

Slope-related questions the tutorial doesn't cover

How does linear regression use slope?

Linear regression fits a straight line to a scatter plot of data points, minimizing the sum of squared vertical distances between points and the line. The line's slope is the "regression coefficient" — the number your statistical software calls β or "beta" or just "coef." Its interpretation: for each unit increase in x, the expected value of y increases by β units. In a data set of house sizes (sq ft) vs prices ($), a regression slope of 200 means "each additional square foot adds about $200 to the expected price." The mathematical formula for the least-squares slope is β = Σ((x_i − x̄)(y_i − ȳ)) / Σ((x_i − x̄)²), which reduces to the two-point slope formula when there are only two data points. Regression generalizes the slope calculation from "line through two exact points" to "line best fitting many noisy points."

What's the connection to calculus?

The slope of a tangent line to a curve at a specific point is the definition of the derivative at that point. For a straight line, the tangent is the line itself and the derivative is a constant slope. For a curve, the tangent line changes as you move along the curve, so the derivative varies with position. Calculus extends the "two-point slope" formula by taking a limit as the two points move closer together: slope at x = lim(Δx → 0) [f(x + Δx) − f(x)] / Δx. This produces a slope for each point on the curve — the local rate of change. Every application of calculus in physics, economics, machine learning, and engineering is fundamentally a slope calculation for a function that isn't just a line.

Why is a 100% grade the same as a 45° angle rather than a "totally vertical" road?

Because grade is defined as rise/run × 100%, and when rise equals run, the grade is 100% but the angle is only 45°. A "100% grade" road rises 1 foot for every 1 foot horizontal — steep but not vertical. A truly vertical road would have infinite grade (rise / run = anything/0). The steepest road in the world (Ffordd Pen Llech at 37.45% grade) is only about a 20.5° angle — steep enough to require special braking but far from vertical. Grades over 100% are exotic; a highway with 200% grade would be 63.4° — impassable for most vehicles. The percentage-based reporting makes intuitive sense for typical driving-scale slopes (5% to 15%) but gets misleading when the number approaches or exceeds 100%.

Is the slope of a horizontal line zero, or does it not exist?

Zero — that's a definite numerical value, not "undefined." For a horizontal line, Δy = 0 for any two points on it, so slope = 0/Δx = 0 exactly. The line y = 5 has slope 0 everywhere. Contrast with a vertical line x = 3, where Δx = 0 and the slope formula Δy/0 is undefined. Some students confuse the two cases because both involve a "zero" — the horizontal case has zero in the numerator (fine, gives 0); the vertical case has zero in the denominator (division by zero, undefined). The distinction is that horizontal lines have a defined but zero slope (equivalent to tan(0°) = 0), while vertical lines have no meaningful real-number slope at all (equivalent to tan(90°) = ∞, which isn't a real number).