The Derivative as a Rate of Change
Learning Objectives
- Define the derivative of at a point as the limit of a difference quotient, and compute it from the definition for simple functions.
- Interpret in three equivalent ways: an instantaneous rate of change with units, the slope of the tangent line, and the coefficient of the best local linear approximation.
- Write the tangent line at a point and use it to estimate nearby values, with an idea of how large the error is.
- Recognize the four standard ways a derivative fails to exist (corner, vertical tangent, discontinuity, oscillation), and state how differentiability relates to continuity.
- Explain why a computer estimates derivatives with a small but not too small step, and why the central difference is the better default.
Context & Motivation
The previous lesson, continuity-and-the-intermediate-value-theorem, was about whether a small change in the input produces a small change in the output. This lesson is about how small. Two functions can both be continuous and still differ enormously in how violently they respond to a nudge: barely moves when moves, and swings a thousand times as far. The derivative is the number that measures that sensitivity at a point.
The idea is older than any formula. A car's odometer records position, while a speedometer reports a different quantity, speed. Speed at an instant is not a position reading: it is the limit of average speeds over shorter and shorter windows. Turning that sentence into mathematics is the whole definition of the derivative.
For computing, the derivative is the quantity that optimization runs on. Training a model means choosing parameters to make an error small, and the sign and size of the derivative of the error say which way to move a parameter and how far to trust the move. The lesson gradients-extending-derivatives-to-several-variables collects one such number per parameter into a vector; each entry there is an ordinary derivative of the kind defined here, taken with the other variables held fixed. Getting the single-variable idea right first, including where it breaks, is what makes that extension straightforward.
Core Theory
From average rate to instantaneous rate
For a function , the average rate of change over is the difference quotient
Geometrically it is the slope of the secant line through and . The derivative of at is what that slope settles to as the window shrinks:
provided the limit exists as a finite number. Equivalent form: . When is defined on both sides of , the two one-sided limits ( and ) must agree. In Leibniz notation, is the same number; the notation is a reminder that the units of the derivative are the units of divided by the units of (meters per second, dollars per unit sold, loss per unit of parameter).
Three readings of the same number
Rate of change. If is position, is velocity. The derivative is the instantaneous version of "how much does the output change per unit of input".
Slope of the tangent line. The tangent line at is the line through with slope :
Best local linear approximation. Rewriting the definition, the error is not merely small, it is small compared with :
So for small , and no other line through has this property. The next lesson, differentiation-rules-and-the-chain-rule, turns this reading into the chain rule.
The derivative as a function
Computing at a general produces a new function , defined at every point where the limit exists. Three computations from the definition that later lessons reuse:
- : .
- , for : .
- , for : multiplying by the conjugate gives . At the function is defined only on one side and the quotient is , which grows without bound, so has no derivative at .
When the derivative does not exist
A derivative exists at only if the difference quotient has a finite limit. Four standard failures are:
- Corner. at : the quotient is , which is for and for . The two sides disagree.
- Vertical tangent. (real cube root) at : the quotient is , which is about at , at , at , and grows without bound from both sides. The graph is continuous and its tangent is vertical, with no finite slope.
- Discontinuity. If jumps at , the quotient blows up.
- Oscillation. with is continuous at , but the quotient is , which takes the value at and at for every positive integer , so it has no limit.
Theorem. If is differentiable at , then is continuous at .
The proof is one line. For , . As the first factor goes to and the second to the finite number , so the product goes to , which is continuity.
The converse is false: is continuous at and not differentiable there. Differentiability is a stronger property than continuity, not an equivalent one. The contrapositive is useful in practice: a function with a jump cannot have a derivative at the jump, so the derivative rules of the next lessons cannot be applied there.
Worked Examples
Example 1: velocity of a falling object
An object dropped from rest falls meters in seconds, ignoring air resistance. Find its velocity at .
Average velocity over , computed from :
texth average velocity (m/s) 0.5 31.85 0.1 29.89 0.01 29.449 0.001 29.4049
The pattern is explained by the algebra: . As the extra term vanishes, so m/s. The units come from the quotient: meters divided by seconds. Over a short window the object really is moving at about m/s, and the tangent line predicts position near .
Example 2: estimating with the tangent line
From the computation above, has and . The tangent line is , so
The true value is , an error of about . Shrinking the step shows the error falling faster than :
texth sqrt(4+h) 2 + h/4 error 0.4 2.097618 2.100000 2.4e-03 0.1 2.024846 2.025000 1.5e-04 0.01 2.002498 2.002500 1.6e-06
Cutting by a factor of cuts the error by about , here roughly . The approximation is only trustworthy near , and the curvature of the function sets how fast it degrades. A tangent line to lies above the curve, which is why the estimate is slightly high.
Example 3: estimating a derivative numerically
A program that can evaluate but not differentiate it may use the forward difference or the central difference . Take at , where the true derivative is exactly , in double precision:
texth forward error central error 1e-01 1.5e-03 2.0e-05 1e-02 1.6e-04 2.0e-07 1e-04 1.6e-06 2.1e-11 1e-05 1.6e-07 1.6e-12 1e-06 1.6e-08 7.6e-11 1e-07 1.5e-09 4.1e-10 1e-08 2.4e-08 1.3e-08 1e-10 2.1e-08 2.1e-08 1e-12 2.2e-05 2.2e-05 1e-16 2.5e-01 2.5e-01
Two effects compete. For larger the error comes from the approximation: forward error shrinks in proportion to , central error in proportion to . For smaller the error comes from rounding: and agree in most of their digits, so their difference loses precision, and dividing by a tiny magnifies what is left. At the sum rounds back to exactly, the quotient is , and the error is the whole derivative. The best step is neither the smallest nor the largest. For this function the central difference reaches an error near at a step near , while the forward difference does no better than about , at a step near . The exact figures depend on the function and the machine, and the shape of the curve does not.
Common Misconceptions & Pitfalls
- "The derivative is the slope of a secant line." A secant has finite width ; the derivative is the limit of secant slopes. Putting directly into the quotient gives , which is why a limit is needed.
- "Continuous implies differentiable." and are continuous at and have no derivative there. The true direction is the theorem above: differentiable implies continuous.
- "A smaller step always gives a more accurate numerical derivative." Example 3 shows the opposite below roughly for the central difference and for the forward difference. Rounding takes over.
- "The tangent line approximation is good everywhere." It is good near , with error that shrinks faster than . Far from it can be wildly wrong: for at , the tangent line predicts at , where the true value is , an error of .
- " is the derivative of the constant ." The derivative of a constant is . means differentiate first, then evaluate at . Reversing the order gives instead.
Summary
The derivative of at is the limit of the difference quotient as , when that limit is a finite number. It is simultaneously an instantaneous rate of change with units, the slope of the tangent line, and the coefficient of the best linear approximation, in the sense that the approximation error is small compared with . From the definition, has derivative , has derivative for , and has derivative for . Differentiability implies continuity, and the converse fails at corners and vertical tangents. Numerically, a step small enough to approximate the limit but large enough to avoid rounding is needed, and, while truncation error dominates and , the central difference is more accurate than the forward difference at the same step. When rounding dominates the two are no better than each other, and for at the two formulas are identical. The next lesson, differentiation-rules-and-the-chain-rule, replaces repeated limit computations with rules.