Single-Variable Calculus Refresher
Chapter 5 does not teach calculus. It generalises it: the derivative becomes a gradient, the chain rule becomes backpropagation, the second derivative becomes a Hessian, and the Taylor series becomes a multivariate Taylor series. Each of those is a one-variable idea with more indices.
So this page is the one-variable version, done properly — rules derived from the limit definition, not listed, because a rule you have derived once is a rule you can rebuild when you forget it.
What you’ll learn
Section titled “What you’ll learn”- Every derivative rule, obtained from the difference quotient.
- Why the chain rule is the one that matters most, and how to spot the “outer” function.
- What higher derivatives measure, and what the second derivative tells you about a minimum.
- Integration in its two guises — area, and undoing differentiation — and why they are the same thing.
- The Taylor series, which is the single most reused idea in the whole module.
Intuition: the derivative is a rate, and it is local
Section titled “Intuition: the derivative is a rate, and it is local”The derivative of at is the slope of the line that best matches near . “Near” is doing real work in that sentence: the derivative knows nothing about far away.
That locality is the whole reason gradient descent needs many small steps rather than one big one. The gradient tells you which way is downhill here; walk too far and you leave the region where that was true. Everything frustrating about learning rates traces back to this one property.
A real-life example: the speedometer
Section titled “A real-life example: the speedometer”Your car’s odometer records position . The speedometer shows — the rate at which position changes. Over the whole trip, average speed is total distance over total time: a secant. The speedometer reading right now is a tangent. Calculus is the machinery for turning the first into the second, by shrinking the interval to nothing.
And the reverse trip is integration: given the speedometer trace for the whole journey, the distance covered is the area under it. Two operations, one relationship, and that relationship is the Fundamental Theorem.
flowchart LR S["position s(t)"] -->|"differentiate"| V["velocity s'(t)"] V -->|"differentiate"| A["acceleration s''(t)"] A -->|"integrate"| V V -->|"integrate"| S V -.->|"slope of the graph"| G["tangent line"] V -.->|"area under the graph"| D["distance covered"]
The math
Section titled “The math”The definition, and the two rules that fall straight out of it
Section titled “The definition, and the two rules that fall straight out of it”Linearity. Substituting and into the quotient and splitting the fraction gives
Both are immediate, because a limit of a sum is the sum of the limits. This is the same linearity that has, and it is why a loss summed over a dataset can be differentiated term by term — the fact §5.2 relies on to make minibatch gradients legitimate.
The power rule, derived
Section titled “The power rule, derived”For with a positive integer, the binomial theorem gives
so
Every surviving term after the first still carries at least one factor of , so as they all vanish and
That is the whole derivation, and it is worth having done once: the rule is not a convention, it is what the binomial expansion leaves behind.
The product rule, derived
Section titled “The product rule, derived”The trick is to add and subtract the same thing:
Let . The first factor by continuity, and the two quotients become derivatives:
The interpolation step — adding and subtracting — is the entire idea. It appears again in the proof of the multivariate chain rule in §5.2, so it is worth recognising.
The chain rule, and why it is the important one
Section titled “The chain rule, and why it is the important one”Read it as: the rate of change of the whole is the rate of the outer, evaluated where the inner puts you, times the rate of the inner. Rates multiply.
Sketch of why: write and
As the second factor becomes and the first becomes . (The step is invalid when the denominator is zero, which a careful proof handles separately, but the mechanism is exactly this.)
The quotient rule
Section titled “The quotient rule”Derivable from the product and chain rules by writing :
Worth remembering, but if it will not come: rewrite as a product and use the two rules you do remember.
The rules worth having memorised
Section titled “The rules worth having memorised”| note | ||
|---|---|---|
| a constant has no rate | ||
| holds for all real , not just integers | ||
| the function that is its own derivative | ||
| for | ||
| note the sign | ||
| the logistic derivative |
The last row earns its place. The logistic sigmoid’s derivative is expressible in terms of the sigmoid itself, so a network that has already computed in its forward pass gets the derivative for one multiply. That is not an aesthetic nicety — it is why the formula is worth deriving:
It also shows the problem: the maximum of is at , and it decays towards zero in both tails. Every sigmoid layer multiplies the backward signal by at most , so ten stacked sigmoids attenuate a gradient by a factor of at least . That is the vanishing-gradient problem, quantified from one derivative.
Higher derivatives
Section titled “Higher derivatives”is the derivative of : the rate at which the rate is changing, which is curvature.
| shape at a stationary point | |
|---|---|
| curving up — a local minimum | |
| curving down — a local maximum | |
| inconclusive; look further |
This is the second-derivative test, and §5.7 generalises it: in many variables becomes the Hessian matrix, and “positive” becomes “positive definite”. A stationary point where the Hessian has both positive and negative eigenvalues is a saddle — the multivariate case that has no one-variable analogue, and the one that dominates high-dimensional optimisation.
Integration, twice over
Section titled “Integration, twice over”As area. is the signed area between the graph and the axis, defined as the limit of rectangle sums:
Note what that is: a sum, with the limit taken. Everything from the sums page applies — linearity, splitting, factoring constants out — which is why needs no separate proof.
As antiderivative. is an antiderivative of when .
The Fundamental Theorem of Calculus says these two are the same thing:
Compare that with the telescoping identity from the sums page: . Same statement. The interior cancels and the endpoints survive; the Fundamental Theorem is telescoping with the step size taken to zero.
Chapter 6 integrates constantly — a density integrates to one, an expectation is an integral, a marginal is an integral over the variable being removed — and every one of those is this operation.
Taylor series
Section titled “Taylor series”The most reused idea in the module:
Truncate after the linear term and you have the tangent line: the linearisation of at . Truncate after the quadratic term and you have the best local parabola — which is exactly the model Newton’s method minimises at each step (§7.1), and exactly the object whose curvature the Hessian describes (§5.7).
Two standard expansions worth knowing by sight, both around :
The second is why for small , an approximation that turns up whenever a log-likelihood is expanded around its maximum.
Worked example by hand
Section titled “Worked example by hand”Differentiate and check it numerically at .
By the product rule with and . The chain rule gives , and , so
At : , and , so
Numerically, with the central difference :
| central difference | absolute error | |
|---|---|---|
Read the error column carefully. It falls by a factor of each time falls by — the central difference is second-order accurate, error proportional to — until , where it gets worse. At that point subtracting two nearly equal numbers has destroyed most of the significant digits, and rounding error dominates the truncation error.
That U-shape is the single most useful thing to know about numerical differentiation, and §5.5 uses it as the basis of gradient checking: pick near the bottom of the U, around to in double precision.
See it move
Section titled “See it move”Drag the number of rectangles and watch the Riemann sum climb towards the true integral. Drag the second knob to switch which corner of each rectangle sets its height — left, right, or midpoint.
Two things to notice. On the left rule the rectangles all sit below the curve and the sum is an underestimate; on the right rule they all poke above it. On the midpoint rule each rectangle is too low on one half of its base and too high on the other, and those errors cancel — so at the same it is dramatically more accurate. That cancellation is the same mechanism that makes the central difference beat the forward difference for derivatives.
On real data
Section titled “On real data”Reading the plot
Section titled “Reading the plot”The second figure is the one to keep. Its left branch is mathematics — the truncation error of the formula, falling like for the forward difference and for the central one, which is why the central curve is steeper. Its right branch is floating point — subtracting two numbers that agree to fifteen digits leaves noise, and dividing that noise by a tiny amplifies it.
The minimum sits where the two effects balance. For the central difference in float64 that is around , with an achievable error near — while the forward difference bottoms out four orders worse, at about , and only at . If you ever “verify” an analytic gradient by setting to be safe, this plot is why the check fails.
Pitfalls
Section titled “Pitfalls”Compare
Section titled “Compare”| operation | one variable | many variables (Chapter 5) |
|---|---|---|
| first derivative | , a number | , a vector — §5.2 |
| chain rule | Jacobian product — §5.2, §5.6 | |
| second derivative | , a number | Hessian , a matrix — §5.7 |
| minimum test | positive definite — §5.7 | |
| linearisation | tangent line | tangent plane — §5.8 |
| Taylor series | powers of | powers with tensors — §5.8 |
| integral | area under a curve | volume, and expectations — §6.4 |
-
The derivative of the logistic sigmoid can be written in terms of the sigmoid itself. What is its largest possible value?
Sigma times one minus sigma is maximised when sigma is one half, giving one quarter. Every sigmoid layer therefore multiplies a backward signal by at most 0.25, which is the vanishing-gradient problem in one line.
pch.quizShowAnswer
B — One quarter — Sigma times one minus sigma is maximised when sigma is one half, giving one quarter. Every sigmoid layer therefore multiplies a backward signal by at most 0.25, which is the vanishing-gradient problem in one line.
-
Why does making the step size in a numerical derivative smaller and smaller eventually make the answer worse?
Truncation error falls with the step size while rounding error grows, giving a U-shaped total. The usable step size sits at the bottom, around 1e-5 for a central difference in double precision.
pch.quizShowAnswer
B — Subtracting two nearly equal floating-point numbers destroys significant digits, and dividing by a tiny step amplifies the leftover noise — Truncation error falls with the step size while rounding error grows, giving a U-shaped total. The usable step size sits at the bottom, around 1e-5 for a central difference in double precision.
-
What is the relationship between the Fundamental Theorem of Calculus and the telescoping sum identity?
Both say the same thing: sum a difference of consecutive values and everything interior cancels, leaving the two endpoints. Shrinking the step to zero turns the sum into an integral.
pch.quizShowAnswer
B — The Fundamental Theorem is the telescoping identity with the step size taken to zero — Both say the same thing: sum a difference of consecutive values and everything interior cancels, leaving the two endpoints. Shrinking the step to zero turns the sum into an integral.
-
At the same number of rectangles, the midpoint rule is far more accurate than the left or right endpoint rules. Why?
Sampling at the midpoint makes each rectangle's error split into two pieces of opposite sign that largely cancel. That buys an extra order of accuracy — the same mechanism that makes the central difference beat the forward difference.
pch.quizShowAnswer
B — Each rectangle is too low over half its base and too high over the other half, so the errors cancel — Sampling at the midpoint makes each rectangle's error split into two pieces of opposite sign that largely cancel. That buys an extra order of accuracy — the same mechanism that makes the central difference beat the forward difference.
🧪 Try It Yourself
Section titled “🧪 Try It Yourself”Exercise 1 – The power rule by numerical check
Section titled “Exercise 1 – The power rule by numerical check”Exercise 2 – The sigmoid derivative in terms of itself
Section titled “Exercise 2 – The sigmoid derivative in terms of itself”Exercise 3 – The chain rule compounds
Section titled “Exercise 3 – The chain rule compounds”Exercise 4 – Find the bottom of the U
Section titled “Exercise 4 – Find the bottom of the U”Exercise 5 – Taylor, one order at a time
Section titled “Exercise 5 – Taylor, one order at a time”Recall card
Section titled “Recall card”- The derivative is local — it describes near a point and says nothing far away, which is why gradient descent takes many small steps.
- Differentiation is linear, so a loss summed over a dataset differentiates term by term.
- The power rule is what the binomial expansion leaves behind once every term carrying an has vanished.
- The product rule comes from adding and subtracting the same interpolating term — a trick reused in the multivariate chain-rule proof.
- The chain rule multiplies rates, so composing layers multiplies derivatives — which is vanishing and exploding gradients in one line.
- The sigmoid derivative is at most one quarter, so ten stacked sigmoids attenuate a gradient by a factor of about a million.
- The second derivative is curvature, and positive curvature at a stationary point means a minimum; in many variables that becomes a positive definite Hessian.
- An integral is a sum with the limit taken, which is why integrals inherit linearity for free.
- The Fundamental Theorem is telescoping with the step size taken to zero.
- Numerical differentiation has a U-shaped error curve — truncation error falls with , rounding error grows, and the usable is at the bottom, near .
- The midpoint rule beats the endpoint rules by an order because each rectangle’s two half-errors cancel.
Next: the one thing a real matrix can do that real numbers cannot describe — Complex Numbers in One Page.
pch.coffeeTagline
pch.coffeeCtapch.feedbackHeading
pch.feedbackSubheading