,

The slope, also called the gradient, of a non-vertical line measures its vertical change per unit of horizontal change. It describes a constant rate, not simply how steep a line happens to look on a screen.

A positive slope rises as the input increases; a negative slope falls. A horizontal line has slope zero. A vertical line has undefined slope because its horizontal change is zero.

On this page

The slope formula

For distinct points A=(x1,y1)A=(x_1,y_1) and B=(x2,y2)B=(x_2,y_2) on a non-vertical line,

m=ΔyΔx=y2−y1x2−x1,x2≠x1.m=\frac{\Delta y}{\Delta x}=\frac{y_2-y_1}{x_2-x_1},\qquad x_2\ne x_1.

The numerator is the signed vertical change, sometimes called the rise. The denominator is the signed horizontal change, or run. Either change can be negative. “Rise over run” is a reminder of the order, not a requirement that both movements be positive.

The ratio is constant along a straight line. Different right triangles built against the same line have proportional legs, so they give the same ratio. This is the geometric basis of the constant rate described in OpenStax’s linear-functions chapter.

Worked examples with positive and negative slopes

A positive slope

For A=(2,1)A=(2,1) and B=(6,9)B=(6,9),

m=9−16−2=84=2.m=\frac{9-1}{6-2}=\frac84=2.

The output rises 2 units for every 1-unit increase in the input. A larger run of 4 units produces a rise of 8 units; both descriptions express the same rate.

Slope is signed rise divided by run

Slope is signed rise divided by runOn y equals two x minus three, a run of four from A to B corresponds to a rise of eight.2468−4−2246810120xyA (2, 1)B (6, 9)run = 4rise = 8
A rise of 8 over a run of 4 gives slope 2.
Diagram explanation and exact data

The plotted line is y = 2x − 3. It extends beyond the selected points. Reversing the endpoint order changes both differences to negative values and preserves their ratio.

Slope is signed rise divided by run: exact reference data
Point or change Exact value
A (2,1)(2,1)
B (6,9)(6,9)
Run 44
Rise 88
Slope 22

A negative slope

For P=(−1,4)P=(-1,4) and Q=(3,−4)Q=(3,-4),

m=−4−43−(−1)=−84=−2.m=\frac{-4-4}{3-(-1)}=\frac{-8}{4}=-2.

As xx increases by 1, yy decreases by 2. The sign communicates direction; the magnitude 2 communicates the rate of change in the chosen units.

Endpoint order must be consistent

Using BB first in the positive-slope example gives

m=1−92−6=−8−4=2.m=\frac{1-9}{2-6}=\frac{-8}{-4}=2.

The result is unchanged because both differences reverse sign. Reversing only the numerator or only the denominator incorrectly reverses the slope. Label the points before substituting when several negative coordinates are involved.

The ratio y/xy/x measures the slope from the origin to (x,y)(x,y) when x≠0x\ne0. It is not the general two-point slope formula. For a line not passing through the origin, ratios of individual coordinates generally differ from its slope.

Zero and undefined slope

A horizontal line through (1,4)(1,4) and (6,4)(6,4) has slope

m=4−46−1=0.m=\frac{4-4}{6-1}=0.

Its equation is y=4y=4. The output stays constant as the input changes.

A vertical line through (3,−2)(3,-2) and (3,5)(3,5) would require 7/07/0. Division by zero is undefined, so its slope is undefined and its equation is x=3x=3. Calling its slope “infinity” does not make it a finite number that can be used in the slope formula.

Identical points are another separate issue: they do not determine a unique line. Both coordinate differences would be zero, so the formula would give 0/00/0 rather than a meaningful slope.

Slope has units in a model

Suppose an idealized tank contains 120 L at time 2 min and 200 L at time 6 min, and its volume changes linearly over that interval. Then

m=200 L−120 L6 min−2 min=20 L/min.m=\frac{200\text{ L}-120\text{ L}}{6\text{ min}-2\text{ min}}=20\text{ L/min}.

More explicitly, the numerator is an 80 L volume change and the denominator is a 4 min time change. A positive result means the volume is increasing. It does not by itself identify whether that is caused by inflow, reduced outflow or some other modelled mechanism.

For a curved graph, the same two-point calculation is an average rate of change over an interval. It need not equal the instantaneous rate at either endpoint. Introduction to Differential Calculus develops that distinction.

Slope and an angle of inclination

On equally scaled perpendicular spatial axes, a non-vertical line making an inclination angle θ\theta with the positive xx-axis satisfies

m=tanθ.m=\tan\theta.

Here 0≤θ<π0\le\theta<\pi, excluding θ=π/2\theta=\pi/2. An inclination between 90∘90^\circ and 180∘180^\circ produces a negative tangent and therefore a negative slope. A vertical line has inclination 90∘90^\circ, where tangent is undefined.

This angle interpretation assumes equal unit lengths on the two axes. Stretching the vertical scale changes a graph’s apparent angle without changing its labelled slope. Always calculate from coordinate values rather than estimating the angle of an arbitrarily scaled image.

Practice questions

  1. Find the slope through (2,1)(2,1) and (6,9)(6,9).
  2. Find the slope through (−1,4)(-1,4) and (3,−4)(3,-4).
  3. Explain why x=3x=3 has undefined slope while y=3y=3 has slope zero.
Check your answers
  1. (9−1)/(6−2)=8/4=2(9-1)/(6-2)=8/4=2.
  2. (−4−4)/(3−(−1))=−8/4=−2(-4-4)/(3-(-1))=-8/4=-2.
  3. On x=3x=3, the horizontal change is zero, so the slope calculation would divide by zero. On y=3y=3, the vertical change is zero but a non-zero horizontal change is possible, giving slope zero.

Related topics

Intercepts of a Line identifies useful anchor points. Combine a point with a slope in Equation of a Straight Line, then compare directions in Parallel and Perpendicular Lines.

Sources and further reading