What is a slope calculator from two points?
This slope calculator finds the direction and rate of change of a straight line determined by two Cartesian points. Enter x₁, y₁, x₂ and y₂ to see the exact slope, the rise and run, the y-intercept and a line equation. The result includes the actual subtraction, division and substitution steps for your entries.
Gradient is another name for the slope of a straight line in this context. The tool is suitable for checking coordinate-geometry working, comparing a result with a textbook exercise or understanding a line before plotting it. It does not require a country setting. Use the Graphing Calculator to plot an equation after you have established the correct line.
How to use the slope and gradient calculator
- Enter the x- and y-coordinate of the first point.
- Enter both coordinates of a second point in the same coordinate system.
- Select Calculate and check whether the points define a finite, vertical or indeterminate result.
- Review the equation and the exact verification for both points.
Ordinary decimal entries can have up to six decimal places. Use a leading minus sign for negative coordinates. Fraction expressions and scientific notation are not accepted; they trigger a visible message rather than being guessed. Results start blank and clear when an input changes. Copy, Download and Print preserve the result and its calculation steps.
Affiliate disclosure: As an Amazon Associate I earn from qualifying purchases.
For an optional arithmetic check with a separate device, you can browse scientific calculators (paid link) on Amazon.com. Confirm the functions supported by the model; not every scientific calculator can reproduce this page's full working. No purchase is required.
Slope formula: rise over run
Rise is the change in y, and run is the change in x. Both differences must use the same point order. Swapping both points reverses both differences and leaves the slope unchanged. Swapping just one subtraction changes the sign and gives an incorrect answer.
The calculation converts accepted decimals into exact rational values and reduces the slope fraction. It does not round the rise or run before dividing. A fraction such as 2/3 is retained as the main answer, with a decimal approximation shown separately. For arithmetic on fractions entered directly, use the existing Fraction Calculator.
Line equation and y-intercept
For a nonvertical line, the calculator finds the intercept from the first point and substitutes both points back into the resulting equation. Parentheses around a fractional slope keep the coefficient unambiguous. The y-intercept is where that line meets x = 0; it need not lie between the two input points.
If you need to solve an equation already written with coefficients rather than build one from points, use the Linear Equation Calculator. These are different workflows. A two-point line also does not fit a trend through a dataset; the Linear Regression Calculator supports that separate statistical task.
Horizontal lines, vertical lines and identical points
Distinct points with the same y-coordinate define a horizontal line. Its rise is zero, its slope is zero, and its equation is y equal to that shared coordinate. Distinct points with the same x-coordinate define a vertical line. The run is zero, the slope is undefined, and the equation is x equal to the shared coordinate.
If both coordinates are identical, there is only one location. Infinitely many lines can pass through it, so the calculator reports no unique line rather than classifying it as horizontal or vertical. These cases are handled before division. Undefined slope is not a numerical answer of infinity, and a 0/0 expression does not justify assigning zero.
Worked slope examples with positive and negative gradients
For points (1, 2) and (4, 8), the rise is 8 − 2 = 6 and the run is 4 − 1 = 3. The slope is 6/3 = 2. The intercept is 2 − 2 × 1 = 0, so the equation is y = 2x. Substituting x = 1 and x = 4 produces the original y-values 2 and 8.
For (0, 4) and (2, 1), the rise is −3 and run is 2, so the slope is −3/2 and the equation is y = (−3/2)x + 4. The negative slope means y decreases as x increases. The line inclination is measured counterclockwise from the positive x-axis; for a negative slope it is between 90° and 180°, not a negative displayed inclination.
Coordinate precision, angles and practical limitations
Each coordinate must lie between negative and positive one billion. Exact rational arithmetic is used for differences, slope, intercept and substitution of the accepted decimal values. The approximate decimal slope and inclination use up to twelve significant digits. A very small nonzero run remains nonzero; it is not silently classified as vertical.
Coordinates need consistent axes and scales. A drawing with visually stretched axes may look steeper or flatter than its mathematical slope. Geographic latitude and longitude are not ordinary planar coordinates for this purpose. This page does not determine road grade, roof pitch, accessibility compliance, structural safety or a fitted trend. For those tasks, choose a tool and method designed for the actual measurements.
Slope Calculator FAQs
Sources and methodology
The linked educational reference explains the underlying mathematical definitions. This independently implemented tool is not affiliated with its publisher. Input limits, precision and special cases are documented on this page.
