Derivatives

How can a curve have a slope at a single point, when a slope needs two points?

The idea

Take a second point a step hh away, on either side, and measure the slope of the line through both points, the secant. If that slope approaches the same finite number from both sides as hh shrinks to zero, that number is the derivative: the slope of the tangent line at the point.

Builds on Functions.

Functions has no page here yet. Read OpenStax, Calculus Volume 1, Section 1.1: Review of Functions.

Ready? For f(x) = (x³ − 3x)/2, what is f(2)?

Show the answer

f(2) = (8 − 6)/2 = 1.

The picture

Slope is rise over run, and that takes two points. So take two: the point on the curve, and a second one a step hh to its right. The line through them is the secant. Its slope, (f(x+h)−f(x))/h(f(x+h) - f(x))/h, is the curve's average steepness over that step, and a long step averages over a whole stretch of curve.

Shrink hh and the secant pivots about the point until it settles on a single line, the tangent, which grazes the curve there. The tangent's slope is the derivative, f′(x)f'(x): the steepness at the point itself, not across a stretch.

The lens magnifies the neighbourhood of the point, more as hh shrinks. Magnify a smooth curve enough and it looks straight; that straight line is the tangent. The chart underneath draws f′(x)f'(x) at every xx at once: above zero where the curve rises, below zero where it falls, and exactly zero where the tangent lies flat. A corner, like the one in ∣x∣|x| at zero, never straightens however far you zoom.

In machine learning the curve is a model's loss and xx is one of its parameters. The derivative says which way to nudge that parameter to lower the loss, and how strongly the loss responds.

Predict first

On f(x)=(x3−3x)/2f(x) = (x^3 - 3x)/2, with a hill at x=−1x = -1 and a valley at x=1x = 1, the point sits at x=0.5x = 0.5 and the secant runs one step right, to x=1.5x = 1.5. That secant rises, with slope 0.1250.125. As the step hh shrinks toward 0, what happens to its slope?

The mathematics

Definition (derivative). The derivative of ff at xx is

f′(x)=lim⁡h→0f(x+h)−f(x)h.f'(x) = \lim_{h \to 0} \frac{f(x+h) - f(x)}{h}.

The fraction

f(x+h)−f(x)h\frac{f(x+h) - f(x)}{h}

is a secant slope: the average rate of change over the step. When the limit exists, from both sides and to the same finite number, it is the tangent slope. Steps from the right alone do not establish it.

Once you know f′(x0)f'(x_0), the tangent line at x0x_0 is

y=f(x0)+f′(x0)(x−x0).y = f(x_0) + f'(x_0)(x - x_0).

For a positive step hh, the left, right and central quotients at the same point are

D−(h)=f(x)−f(x−h)h,D+(h)=f(x+h)−f(x)h,Dc(h)=f(x+h)−f(x−h)2h=D−(h)+D+(h)2.\begin{aligned} D_-(h) &= \frac{f(x)-f(x-h)}{h}, \\ D_+(h) &= \frac{f(x+h)-f(x)}{h}, \\ D_c(h) &= \frac{f(x+h)-f(x-h)}{2h} = \frac{D_-(h)+D_+(h)}{2}. \end{aligned}

The derivative exists when D−(h)D_-(h) and D+(h)D_+(h) tend to the same finite limit as hh shrinks. For a smooth function, the one-sided quotients miss f′(x)f'(x) by an amount proportional to hh, while the central quotient's leading errors cancel and it misses by an amount proportional to h2h^2. The central quotient can mislead at a corner: for ∣x∣|x| at zero, D+=1D_+ = 1 and D−=−1D_- = -1 at every hh, yet Dc=0D_c = 0 at every hh.

Try it

First a worked example, then one to finish, then problems on your own. Check your answer before you look at the solution. Answers typed here are not kept when you leave.

  1. 1 · Worked example

    The slope at x = 0.5, from the definition

    For f(x)=(x3−3x)/2f(x) = (x^3 - 3x)/2, find f′(0.5)f'(0.5) as the limit of the secant's slope.

    1. Rise. Expand (x+h)3=x3+3x2h+3xh2+h3(x+h)^3 = x^3 + 3x^2h + 3xh^2 + h^3, so f(x+h)−f(x)=12(3x2h+3xh2+h3−3h)f(x+h) - f(x) = \tfrac{1}{2}(3x^2h + 3xh^2 + h^3 - 3h).

    Say the next step to yourself first.
  2. 2 · Finish it

    Average both sides

    Instead of one secant to the right, take the line from x−hx - h to x+hx + h, which is the average of the left and right secants. With x=0.5x = 0.5 and h=0.1h = 0.1, finish the estimate of f′(0.5)f'(0.5).

    1. Right point. f(0.6)=(0.216−1.8)/2=−0.792f(0.6) = (0.216 - 1.8)/2 = -0.792.

    2. Left point. f(0.4)=(0.064−1.2)/2=−0.568f(0.4) = (0.064 - 1.2)/2 = -0.568.

    3. Rise across both sides. f(0.6)−f(0.4)=−0.224f(0.6) - f(0.4) = -0.224.

    4. Your turn.

  3. 3 · On your own

    A ten-times-smaller step

    At x=0.5x = 0.5 with h=0.1h = 0.1, the one-sided secant misses f′(0.5)f'(0.5) by 0.080.08 and the two-sided average misses by 0.0050.005. Shrink hh to 0.010.01. Roughly how far off is each now?

    Choose one

  4. 4 · On your own

    Which way is downhill?

    Suppose f(x)=(x3−3x)/2f(x) = (x^3 - 3x)/2 is a model's loss and xx its one parameter, currently 0.50.5, where f′(0.5)=−1.125f'(0.5) = -1.125. Training nudges xx a small amount at a time to lower the loss. Which way should it move, and where do many small nudges end up?

    Choose one

The code

The definition, run with shrinking steps on sin⁡x\sin x at x=1.2x = 1.2, where the true slope is cos⁡1.2≈0.362\cos 1.2 \approx 0.362.

import numpy as np

f = lambda x: np.sin(x)
df_true = lambda x: np.cos(x)

x0 = 1.2
for h in [1.0, 0.3, 0.1, 0.03, 0.01]:
    df_est = (f(x0 + h) - f(x0)) / h
    print("h=", h, "secant=", df_est, "true=", df_true(x0))

The secant's slope climbs from −0.124-0.124 at h=1h = 1 to 0.3580.358 at h=0.01h = 0.01. Each ten-fold shrink of hh cuts the gap about ten-fold: 0.0470.047 at h=0.1h = 0.1, 0.00470.0047 at h=0.01h = 0.01.

Keep it

  1. Zoom in far enough on a smooth curve at one point. What do you see, and what is its slope?

    Answer from memory, then check

    A straight line: the tangent. Its slope is the derivative f′(x)f'(x), the steepness of the curve at that point.

  2. You shrink hh ten times. How does the miss change for a one-sided secant, and for the average of both sides?

    Answer from memory, then check

    On a smooth curve the one-sided miss shrinks about ten times (in step with hh). The average's miss shrinks about a hundred times (like h2h^2), because the leading errors of the two sides cancel.

  3. True or false: wherever f′(x)=0f'(x) = 0, the curve has a peak or a valley.

    Answer from memory, then check

    False. Peaks and valleys of a smooth curve do have f′(x)=0f'(x) = 0, but x3x^3 is flat at 00 and keeps rising through it. A zero slope says where to look, not what you will find.

  4. Why does ∣x∣|x| have no derivative at x=0x = 0?

    Answer from memory, then check

    The right secant has slope 11 and the left has slope −1-1 at every hh. Zooming in never makes them agree, so no single tangent fits. Their average, 00, is steady but describes neither side.

  5. Why does training a model need derivatives at all?

    Answer from memory, then check

    The derivative of the loss with respect to a parameter says which way, and how strongly, the loss changes when that parameter is nudged. A small step against it lowers the loss; without it, every nudge would be a blind guess.

Recalling an answer from memory makes it last longer than rereading it (Roediger and Karpicke, 2006). Add these 5 cards and they come back tomorrow, then after gaps of 3, 7, 16, 35 and 75 days while you still remember them. They stay in this browser only.

The edge

Everything here assumed a smooth curve, but the networks trained in practice are full of corners. ReLU, max⁡(0,x)\max(0, x), has exactly the corner of ∣x∣|x| at zero, where no derivative exists. Software simply picks a slope there, usually 0, and training works anyway. For convex functions the choice is justified by subgradients: any slope of a line that touches the function from below without crossing it. For deep networks the theory is still being built. At some points, automatic differentiation of such programs can return a value that is neither the derivative nor any subgradient. Bolte & Pauwels (2020) show that such points form a negligible set and give a framework for reasoning about them, but which slopes training actually needs there is not settled. In practice the choice still matters: in the 32- and 16-bit arithmetic used for training, the slope chosen for ReLU at zero can measurably change the result (Bertoin et al., 2021).

Next thoughtThe derivative says which way is downhill. How big a step should you take, and what goes wrong when the step is too big?Gradient Descent →
The full instrument: predict the hidden tangent, and compare both sides step by step on |x| and |x − 1|

Limits of this page

  • One input only. With many parameters, each gets a slope like this one, and together they form the gradient.
  • The curves are chosen by hand, and nothing on this page is learned.
  • The figure's smallest step is h=0.001h = 0.001, and a limit is a statement about every step near zero; no finite list of readings proves one exists.
  • On a computer, a very small hh eventually makes a difference quotient worse, not better, because rounding errors are divided by hh.
  • The Python runs on your machine, not in the page.

Sources

  1. Deisenroth, Faisal, and Ong (2020). Mathematics for Machine Learning.

    Grounds derivatives and vector calculus as part of the mathematical toolkit needed for machine learning.

  2. Bolte and Pauwels (2020). A mathematical model for automatic differentiation in machine learning.

    NeurIPS 2020. A nonsmooth calculus for what automatic differentiation returns at corners such as ReLU's; the values that are not derivatives occur only on a set of measure zero.

  3. Bertoin et al. (2021). Numerical influence of ReLU'(0) on backpropagation.

    NeurIPS 2021. The value chosen for ReLU's slope at zero changes backpropagation outputs in 16- and 32-bit arithmetic (not in 64-bit) and can change the result of training.

What the claims rest on

Central claim: The derivative is an instantaneous rate of change: the slope you get when a secant line becomes a tangent line.

Each claim below lists the passages it cites and how far it has been checked against them. These are the site’s own checks, not independent replication.

Claim (checked against the cited passages): For a differentiable one-variable real function, the derivative at x is the limit of the difference quotient as h approaches 0: secant slopes over [x,x+h] converge to the tangent slope, a local one-variable rate-of-change signal used by gradient-based optimization.

Sources: Mathematics for Machine Learning

What the sources support: MML's vector calculus chapter defines the derivative as the limit of a difference quotient, explains the secant-to-tangent picture for differentiable functions, and notes derivatives/gradients give steepest-change information later used in gradient descent and continuous optimization.

On this page: the note on Mathematics for Machine Learning, Equation 1, Equation 2, Code example 1, the figure

Caveat: Covers differentiable functions of one variable, secants with positive h, and the sign of a one-variable gradient. Corners, subgradients, partial derivatives and finite-difference error are outside this check.

Connections

Builds on Functions.

Leads to Chain Rule and Gradient Descent.

Cite this page

Continuous Function. “Derivatives.” Revised 2026-10-09. https://continuousfunction.ai/domains/calculus/derivatives/

BibTeX
@misc{cf-derivatives,
  title = {Derivatives},
  author = {{Continuous Function}},
  year = {2026},
  note = {Revised 2026-10-09},
  url = {https://continuousfunction.ai/domains/calculus/derivatives/}
}