Slope Calculator
Free slope calculator: enter two points and get slope m, y-intercept b, rise, run, and angle in degrees, with the full slope-intercept equation y = mx + b.
Slope Calculator
Background.
The slope calculator turns two Cartesian coordinates into the single number geometers, builders, drivers, and calculus students all reach for first — the rise over the run. Type the coordinates of any two points (x₁, y₁) and (x₂, y₂) and the tool returns the slope m using the classical two-point formula m = (y₂ − y₁) / (x₂ − x₁), the y-intercept b that completes the equation y = mx + b, the inclination angle θ in degrees, and the raw rise and run values so you can sanity-check the arithmetic by hand.
Behind that one number sits four hundred years of analytic geometry — the discipline René Descartes opened in 1637 when he laid an algebraic grid over Euclid's plane and showed that every line could be reduced to a linear equation. The slope is the modern way of saying how steep, how fast, or how strong: a roof pitched at 6/12 has a slope of 0.5, an interstate highway in the United States rarely exceeds a 6% grade (slope 0.06) because freight trucks lose speed climbing anything steeper, and the Americans with Disabilities Act caps wheelchair-ramp slopes at 1:12 — a slope of about 0.083, or 4.76° — so that someone using a manual chair can propel themselves up without help. In statistics the slope is the regression coefficient that tells you how much one variable moves when another moves by one unit; in physics it is velocity on a position-vs-time graph and acceleration on a velocity-vs-time graph; in calculus it is the limiting case that becomes the derivative dy/dx the moment you let the two points slide together.
Vertical lines are the one exception the formula cannot handle: when x₁ equals x₂ the run is zero, division by zero is undefined, and we say the slope does not exist — this calculator flags that case explicitly with an isVertical indicator and returns 90° as the line's inclination so downstream consumers don't silently treat a wall as a floor. Horizontal lines, by contrast, are perfectly well-defined and produce a slope of exactly 0, an intercept equal to the shared y-coordinate, and an angle of 0°.
Parallel lines share the same slope; perpendicular lines have slopes whose product is −1 (negative reciprocals); and any three points lie on a common line if and only if every pair of them yields the same slope — three quick rules that turn slope from a number into an entire toolkit for plane geometry, drafting, navigation, and data analysis. Whether you are building a deck, checking a ramp for ADA compliance, fitting a regression line, or working through a coordinate-geometry homework problem, this is the calculator that does the algebra so you can think about the geometry.
What is slope calculator?
The slope of a straight line is the ratio of vertical change to horizontal change between any two points on the line — universally written as m = (y₂ − y₁) / (x₂ − x₁). Conceptually it answers a single question: for every one unit you move to the right along the x-axis, how many units does the line move up (or down) along the y-axis? A slope of 2 means up two for every one across; a slope of −0.5 means down half a unit for every one across; a slope of 0 means perfectly horizontal; an undefined slope means perfectly vertical. Slope is a dimensionless number when both axes share the same unit, but in applied settings it carries the units of dy/dx — so a position-time graph has slope in metres per second (velocity), a cost-output graph has slope in dollars per widget (marginal cost), and a topographic profile has slope as a grade or percentage. Slope is the foundational quantity of analytic geometry, the building block of linear regression in statistics, and the gateway to the derivative in calculus — every tangent line at every point on every smooth curve is just a line with a slope.
How to use this calculator.
- Pick any two distinct points that lie on the line and read off their coordinates as (x₁, y₁) and (x₂, y₂). The order doesn't matter as long as you keep it consistent — swapping both pairs gives the same slope.
- Type x₁ and y₁ into the first two fields. Negative numbers and decimals are fine.
- Type x₂ and y₂ into the next two fields. The calculator runs the moment all four values are present — there's no submit button.
- Read the primary result — Slope (m) — at the top of the results panel. This is the rise-over-run value plugged into the formula.
- Use the y-intercept (b) to write the line in slope-intercept form: y = mx + b. If you'd rather use point-slope form, plug m into y − y₁ = m(x − x₁).
- Check the Angle output if you need the line's inclination — useful for ramps, roofs, and roadway grades. Multiply slope by 100 to convert to a percentage grade (a slope of 0.06 = a 6% grade).
- Watch the isVertical flag. If it reads 1 the slope is mathematically undefined and the slope and intercept outputs are sentinels (zero) rather than real values — the line is vertical and its equation is simply x = x₁.
The formula.
The slope formula m = (y₂ − y₁) / (x₂ − x₁) is a direct algebraic restatement of the geometric idea of "rise over run". The numerator (y₂ − y₁) is the rise — the signed vertical distance you climb (or descend) between the two points. The denominator (x₂ − x₁) is the run — the signed horizontal distance you travel between them. Their ratio is the constant rate at which y changes with respect to x along the line, and because every pair of points on a straight line produces the same ratio, m is a property of the line itself, not of the points you happened to pick. Once you have m, the y-intercept follows from rearranging y = mx + b at either known point: b = y₁ − m·x₁ (equivalently b = y₂ − m·x₂ — both yield the same b). Together m and b complete the slope-intercept equation y = mx + b, the canonical algebraic description of a non-vertical line. The inclination angle θ — the angle the line makes with the positive x-axis — is recovered from the slope by θ = arctan(m), measured in radians and converted to degrees with the factor 180/π. This calculator uses the two-argument arctangent atan2(rise, run) and then normalises the result into the half-open interval (−90°, 90°] so the angle always describes the line's tilt rather than a directed bearing — a line going up-and-right at 30° and the same line traversed in the opposite direction (down-and-left at 30°) report the same inclination. The vertical-line case (x₁ = x₂) is the formula's one true exception: the run is zero, division is undefined, and no real number m exists. We flag this with isVertical = 1, return 90° for the angle (which is geometrically correct), and emit zeros for the slope and intercept as sentinel values you can detect and handle in downstream code.
A worked example.
Take the points (0, 0) and (4, 3) — the classic 3-4-5 right-triangle setup with the right-angle vertex at the origin. The rise is y₂ − y₁ = 3 − 0 = 3 and the run is x₂ − x₁ = 4 − 0 = 4, so the slope is m = 3 ÷ 4 = 0.75. Because point 1 sits at the origin, the y-intercept is b = 0, and the line's equation is y = 0.75x — it passes through the origin and climbs three units for every four units to the right. The inclination angle is θ = arctan(0.75) ≈ 36.87° (this is the famous 3-4-5 triangle angle and the same angle a roof with a 9-in-12 pitch makes with the horizontal). In comparison, take a vertical example: from (2, 1) to (2, 5) the run is 2 − 2 = 0 and the formula breaks — the slope is undefined, the equation collapses to x = 2, the calculator sets isVertical = 1, and the reported angle is 90°. Use that flag in any spreadsheet or script that consumes these outputs so you can branch on the vertical case explicitly instead of mishandling a sentinel zero as a real horizontal slope.
Frequently asked questions.
Why is the slope of a vertical line undefined?
What does it mean when two lines have the same slope?
How do I know if two lines are perpendicular from their slopes?
What is the difference between point-slope form and slope-intercept form?
How is slope related to the derivative in calculus?
What slope counts as steep for a roof, a ramp, or a road?
Does the order of the two points matter?
What is the slope of a horizontal line?
How do I convert slope to a percentage grade or to an angle?
Can I use the slope formula for non-straight curves?
References& sources.
- [1]Descartes, R. (1637). La Géométrie. Discours de la méthode, Appendix III — original publication introducing the Cartesian coordinate system and the algebraic treatment of straight lines.
- [2]Euclid (c. 300 BC). Elements, Book I — definitions and postulates of plane geometry on which all later coordinate treatments of lines depend.
- [3]U.S. Access Board (2010). 2010 ADA Standards for Accessible Design, §405.2 Slope — maximum ramp slope of 1:12 for new construction.
- [4]Federal Highway Administration (2016). Highway Capacity Manual, 6th Edition — design grade guidance for Interstate and primary highways (typical maximum 6% in mountainous terrain).
- [5]NIST Digital Library of Mathematical Functions (2024). §1.7 Inequalities and §4.24 atan2 — definitions of the arctangent and two-argument arctangent used to convert slope to inclination angle.
- [6]Wolfram MathWorld. Slope — concise reference for the two-point slope formula and its corollaries (parallel, perpendicular, collinearity).
How this page was produced
- Published by
- Quanta Calculator
- Primary sources
- 6 cited below
- Method
- m = (y₂ − y₁) ⁄ (x₂ − x₁)
- Published
- Last verified
Built with AI assistance and verified by automated tests against the cited sources — every worked example on this page is computed by the same code that runs the calculator. How we build and check calculators.
In this category
Embed
Quanta Pro
Paid features are coming later.
- All 1560 calculators remain free
- No billing is enabled