Home / Calculus

Derivatives and Slope

The slope of a straight line is easy. The derivative asks a harder question: what is the slope of a curve at a single point? Shrink the gap and watch the answer appear.

Controls

point x2.0
gap h2.000
0.0013

The amber line is the secant through two points. The green line is the true tangent.

Curve, Secant and Tangent

drag the blue point

Live Calculation

secant slope
0
true f′(x)
0
error
0
behaviour
–

Overview

From secant to tangent

Between x and x + h, the average rate of change of f is [f(x+h) − f(x)]/h. The derivative is the limit as h approaches zero, when that limit exists:

f′(x) = limₕ→₀ [f(x+h) − f(x)] / h

For f(x) = x², the difference quotient simplifies to 2x + h. Letting h approach zero gives f′(x) = 2x, so the slope at x = 3 is 6. The visualiser shows this limit by shrinking the gap between two points.

Derivatives and Slope

A derivative is the instantaneous rate of change: the slope a curve approaches at one point.

Read the derivative

A positive derivative means the function is locally increasing; a negative one means locally decreasing. Its magnitude measures steepness in the chosen units. A derivative of zero marks a stationary point, but that point could be a minimum, maximum, or neither. A sharp corner can make the derivative undefined.

In machine learning, derivatives tell how a loss changes when a parameter changes. Gradient descent steps against the gradient to reduce a differentiable objective. See partial derivatives and gradients and the chain rule.

Units and local meaning

A derivative has units of output per unit of input. If distance is measured in metres and time in seconds, ds/dt is measured in metres per second. It describes a local rate near the chosen point, not necessarily the average rate across a large interval. For f(x)=x², the average slope from x=3 to x=3+h is ((3+h)²−9)/h=6+h; as h approaches zero, the slope approaches 6.

A positive derivative means the function is increasing locally, and a negative one means decreasing. A zero derivative is only a candidate for a local extremum: f(x)=x³ has derivative zero at 0 but keeps increasing through it. A corner such as |x| has no single tangent slope at its cusp. Even when a derivative exists, a tangent-line approximation is reliable only near the point and for sufficiently smooth functions. In optimisation, derivatives describe local sensitivity; they do not tell whether a proposed step will reduce the objective unless the direction and step size are chosen appropriately.

Try this above

Move the point along the curve and compare the tangent slope at different locations. Check where the slope is zero and whether the curve actually has a maximum or minimum there.

A derivative can be estimated numerically with a finite difference, [f(x+h)−f(x)]/h, but choosing h is a trade-off. If h is too large, the secant slope differs from the tangent; if h is too small, rounding and cancellation can dominate. Automatic differentiation applies derivative rules through a computation graph and is usually more accurate than finite differences for machine-learning gradients. It still computes derivatives of the implemented function: bugs, discontinuities, or a poorly scaled loss remain problems.

For a position function s(t), the derivative ds/dt is instantaneous velocity and the second derivative is acceleration. This illustrates why the derivative's units depend on both quantities and why an average rate over an interval can differ from the instantaneous value. A derivative describes local behaviour; predicting far into the future requires a model for how the function itself evolves, not just its current slope.

Sources and next steps

Predict, then reveal

About to run: set point x to its minimum (-5). Before it does — what happens to the readout?

Committing to an answer first is the point — the reveal runs the experiment on the visualisation above and reads the real value back, so nothing here is scripted.

Check yourself

0 of 3

Answer without scrolling back up.

  1. The derivative of a function at a point tells you:

  2. At a minimum of a smooth curve, the derivative is:

  3. Gradient descent subtracts the gradient rather than adding it. Why?

Cheat sheet

Derivatives and Slope

Shrink the gap between two points until the secant becomes the tangent — the single idea every gradient-based optimiser is built on.

MATHS · vizlearn.in/maths/derivatives_and_slope.html

About the author

Ashish Jangra builds and maintains VizLearn. Every module here is written and the visualisation behind it hand-built, so the numbers in a readout come from the same code that draws the picture. Corrections are genuinely welcome and get priority over everything else — if a page states something wrong, or an animation misrepresents what the algorithm does, get in touch.