📊 Section 1 — Interactive Simulation
Pick a function, drag $h$ toward zero, and watch the secant rotate into the tangent. The slope $f'(a) = \displaystyle\lim_{h\to 0}\frac{f(a+h)-f(a)}{h}$ emerges as a number.
Animation
Function Preset
Parameters
Display Options
Tips
• Press ▶ Play to animate $h$ shrinking.
• Toggle Symmetric for $\frac{f(a+h)-f(a-h)}{2h}$ — error is $O(h^2)$ instead of $O(h)$.
• For $\abs{x}$ at $a=0$: left slope $=-1$, right slope $=+1$ — not differentiable.
💡 Section 2 — The Idea, Step by Step
One idea, climbing gently from a car's speedometer to the formal limit.
Picture driving. Your speedometer reads 54 km/h right now — at this single instant. But "speed" is supposed to be distance divided by time, and a single instant has no stretch of distance and no stretch of time. So how can the needle point at a number at one frozen moment? That puzzle is exactly what the derivative answers: it's the speed of any changing quantity at a single instant.
The trick is to refuse to use one instant. Instead, look at a short interval and measure the ordinary, everyday "average rate" — how much the output changed, divided by how much the input changed. For a function $f$, starting at a point $a$ and stepping forward by a small amount $h$, that average rate is the slope of the line through two points on the graph (a secant line):
Try a real number. Let $f(x)=x^2$ and watch the rate near $a=1$. From $x=1$ to $x=1.1$ the rise is $1.21-1=0.21$ over a run of $0.1$, giving $2.1$. Shrink the step: from $1$ to $1.01$ the rate is $\frac{1.0201-1}{0.01}=2.01$. Shrink again and you get $2.001$. The numbers are clearly homing in on $2$ — they just never are exactly $2$ for any real step.
So take the last step honestly: let the run shrink toward zero and ask what value the rates approach. That limit is the derivative, written $f'(a)$:
For $f(x)=x^2$ this works out to $f'(a)=2a$, so $f'(1)=2$ — matching the numbers above. Geometrically, as $h\to 0$ the secant line through the two points stops being a chord and becomes the tangent line just kissing the curve at $a$; the derivative is that tangent's slope. In the sim above, the a slider sets where you measure, the h slider is the run (on a log scale so you can push it tiny), and the readouts compare the secant slope against the exact answer.
Try this in the sim above. (1) Keep $f(x)=x^2$, press ▶ Play, and watch the orange secant rotate until it lands on the tangent while the "error" readout collapses toward zero. (2) Turn on the Symmetric toggle and shrink $h$ again — the error drops far faster, because the symmetric quotient is accurate to $O(h^2)$ instead of $O(h)$. (3) Choose $f(x)=\abs{x}$ at $a=0$: the left slope reads $-1$ and the right slope reads $+1$, they never agree, so the limit — and the derivative — simply does not exist at that corner.
📐 Section 3 — Definition & Derivation
From average rate of change to instantaneous rate via the limit.
Let $f$ be defined on an open interval containing $a$. The derivative of $f$ at $a$ is $$f'(a) \;=\; \lim_{h \to 0}\frac{f(a+h)-f(a)}{h} \;=\; \lim_{x \to a}\frac{f(x)-f(a)}{x-a},$$ provided this limit exists. If it does, $f$ is differentiable at $a$.
Geometrically: $f'(a)$ is the slope of the tangent line to $y=f(x)$ at the point $(a, f(a))$.
Symbol Table
| Symbol | Meaning | Type |
|---|---|---|
| $f$ | The function under study | $D \to \R$ |
| $a$ | Point of differentiation | Real, interior of $D$ |
| $h$ | Secant offset, $h \to 0$ | Real, $\neq 0$ |
| $\Delta f$ | Rise: $f(a+h)-f(a)$ | Real |
| $\Delta f / h$ | Difference quotient (secant slope) | Real |
| $f'(a)$ | Derivative — limit of secant slopes | Real (or DNE) |
| $f'_-(a),\,f'_+(a)$ | Left/right derivatives | Real or DNE |
Derivation — $\dfrac{d}{dx}x^n = n x^{n-1}$ from First Principles
Simulation ↔ Symbol Mapping
slider a | point $a$ where the derivative is evaluated |
slider h | secant offset $h$ (logarithmic, $10^{-6}$ to $10^{0.3}$) |
slider direction | $+1$ uses $h>0$ (right secant), $-1$ uses $h<0$ (left secant) |
readout secant slope | $\frac{f(a+h)-f(a)}{h}$ — current value of difference quotient |
readout f′(a) analytic | known closed-form derivative for the chosen preset |
readout error | $\abs{\text{secant} - f'(a)}$ — shrinks $O(h)$ forward, $O(h^2)$ symmetric |
readout left/right slope | $f'_-(a),\ f'_+(a)$ from samples at $h=\pm 10^{-7}$ |
toggle Symmetric | switches to $\frac{f(a+h)-f(a-h)}{2h}$, central difference |
Worked Example — $f(x)=\sqrt{x}$ at $a=4$
$f'(4) = \displaystyle\lim_{h\to 0}\dfrac{\sqrt{4+h}-2}{h}$. Multiply by conjugate $\dfrac{\sqrt{4+h}+2}{\sqrt{4+h}+2}$:
$=\displaystyle\lim_{h\to 0}\dfrac{(4+h)-4}{h(\sqrt{4+h}+2)}=\lim_{h\to 0}\dfrac{1}{\sqrt{4+h}+2}=\dfrac{1}{4}.$
$\boxed{f'(4)=\tfrac{1}{4}}$, matching $f'(x)=\tfrac{1}{2\sqrt{x}}$ at $x=4$.
❓ Section 4 — Frequently Asked Questions
For any specific $h$, $\frac{f(a+h)-f(a)}{h}$ is a secant slope, not a tangent slope — it depends on which $h$ you chose. The derivative is a single number characteristic of $f$ at $a$, independent of any $h$. The limit collapses the family of all secants into one tangent.
Key takeaway: secant slopes approximate; the derivative is the exact tangent slope.Floating-point catastrophic cancellation. When $h\approx 10^{-9}$, $f(a+h)-f(a)$ subtracts two nearly-equal doubles, losing ~9 of ~16 digits. Below $h\approx 10^{-8}$ the secant slope oscillates randomly. Optimal $h$ for the forward quotient is $h^*\approx \sqrt{\eps_{\text{mach}}}\approx 1.5\times 10^{-8}$. The error graph shows the U-shape: truncation error decreases, then roundoff increases.
Key takeaway: in math $h\to 0$; in numerics there's a sweet spot $h^* \sim \sqrt{\eps_{\text{mach}}}$.Velocity = derivative of position; acceleration = derivative of velocity (Newton). Marginal cost in economics is $dC/dq$. Machine learning trains neural networks via gradient descent — every weight update is $w \leftarrow w - \eta\,\partial L/\partial w$. Image-processing edge detection uses derivatives (Sobel filter). PID controllers anticipate overshoot via derivative-of-error. Population growth, chemical reaction rates, Bayesian belief updates — all derivatives.
Key takeaway: any "rate of change" is a derivative — physics, economics, ML, control all live on derivatives.Yes. Take $f(x)=x^2\sin(1/x)$ for $x\neq 0$ and $f(0)=0$. By squeeze, $f'(0)=\lim_{h\to 0}h\sin(1/h)=0$. But for $x\neq 0$, $f'(x)=2x\sin(1/x)-\cos(1/x)$ — the $\cos(1/x)$ term oscillates as $x\to 0$, so $\lim_{x\to 0}f'(x)$ does not exist. So $f'$ is defined everywhere yet discontinuous at $0$. (Darboux's theorem: $f'$ still has the intermediate value property — derivatives can't have jump discontinuities even when discontinuous.)
Key takeaway: differentiable everywhere ⇏ derivative is continuous — but it always has IVT (Darboux).Taylor: $f(a+h)=f(a)+h f'(a)+\tfrac{h^2}{2}f''(a)+\tfrac{h^3}{6}f'''(a)+\cdots$. Forward quotient $=f'(a)+\tfrac{h}{2}f''(a)+O(h^2)$, error is $O(h)$. Symmetric quotient $=f'(a)+\tfrac{h^2}{6}f'''(a)+O(h^4)$, error is $O(h^2)$. With $h=0.01$, forward gives ~3 correct digits, symmetric gives ~6. Optimal $h$: forward $\sim \sqrt{\eps_{\text{mach}}}$, symmetric $\sim \eps_{\text{mach}}^{1/3}$.
Key takeaway: symmetric difference is the right default — same code, double the digits.$f$ is differentiable at $a$ iff there's a constant $L$ with $f(a+h)=f(a)+Lh+o(h)$, where $o(h)/h\to 0$. The derivative is the unique linear map best approximating $f$ near $a$. Generalizes verbatim to $\R^n$: $f:\R^n\to\R^m$ differentiable at $a$ means $\exists$ linear $L:\R^n\to\R^m$ with $f(a+h)=f(a)+Lh+o(\norm{h})$. That $L$ is the Jacobian. The 1D limit definition is just the scalar case.
Key takeaway: the derivative IS the best linear approximation — that's why it generalizes to gradients and Jacobians.One-sided difference quotients: $f'_+(0)=\lim_{h\to 0^+}\abs{h}/h=\lim h/h=1$. $f'_-(0)=\lim_{h\to 0^-}\abs{h}/h=\lim (-h)/h=-1$. The two one-sided derivatives exist but disagree, so the two-sided limit doesn't exist. At the corner of the V, no single tangent line — left tangent has slope $-1$, right has slope $+1$.
Key takeaway: corners are continuous but not differentiable — left and right slopes disagree.