Search

Search papers and lessons

Derivative

Level 1 · 12 min read

The derivative of a function is its instantaneous rate of change: the slope of the curve at one point, found as the limit of average slopes over shrinking intervals.

On this page

  • Colour = topic mix
  • Calculus
  • Sign in to see your progress

TL;DR

The derivative measures how fast a function is changing at a single point. Geometrically, it is the slope of the curve there. It is defined as the limit of average rates of change over intervals that shrink to nothing, so it needs the idea of a limit.

Derivatives turn a description of a quantity into a description of how that quantity moves, which is most of physics, economics and machine learning.

Where you'll see it: in a car's speed (the derivative of position), in the gradient that trains a neural network, and in every "marginal" cost or profit calculation.

Intuition

A speedometer for a function

A car's odometer tells you how far you have travelled. The speedometer tells you how fast you are going right now. The odometer is a function of time; the speedometer is its derivative. Speed is not "distance divided by time" for the whole trip. It is what the reading would be over the next instant, if you could zoom in far enough.

That is the whole idea. Given a function ff, the derivative at a point xx answers: if I nudge the input a tiny bit, how much does the output move, per unit of nudge?

Why it needs limits

Average rate of change is easy. Between xx and x+hx+h, the output changes by f(x+h)−f(x)f(x+h) - f(x), so the average rate is that change divided by hh. The trouble is that h=0h = 0 gives 0/00/0, which means nothing. The derivative is what this average becomes as hh gets smaller and smaller without reaching zero. That is precisely a limit.

The picture is a secant line (a line through two points on the curve) that slides towards a tangent line (a line that touches the curve at one point). The tangent's slope is the derivative.

−1−0.500.511.522.53−202468xf(x)
  • f(x) = x^2
  • tangent at x = 1
At x = 1 the curve x^2 has slope 2. The dashed tangent line has the same slope and touches the curve only at the marked point.

The math

Definition

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},

whenever this limit exists. If it does, ff is differentiable at xx. The notation f′(x)f'(x) reads "f prime of x"; the equivalent Leibniz notation is dfdx\frac{df}{dx}.

Here hh is a small step added to the input, and f(x+h)−f(x)h\frac{f(x+h) - f(x)}{h} is the average slope of the curve between xx and x+hx+h. The limit asks what that average slope approaches as the step shrinks. The quantity f(x+h)−f(x)f(x+h) - f(x) is the change in output, and dividing by hh puts it per unit of input.

Once f′(x)f'(x) is known, the tangent line at x=ax = a is

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

Basic rules

Computing the limit from scratch every time is slow, so we use rules that are proved once:

ddxxn=nxn−1(power rule, for any real n, with x>0 if n is not an integer)ddxc=0(a constant does not change)ddx(c f(x)+g(x))=c f′(x)+g′(x)(linearity)ddxex=exddxln⁡x=1x(x>0)\begin{aligned} \frac{d}{dx} x^n &= n x^{n-1} && \text{(power rule, for any real } n\text{, with } x \gt 0 \text{ if } n \text{ is not an integer)} \\ \frac{d}{dx} c &= 0 && \text{(a constant does not change)} \\ \frac{d}{dx} \bigl(c\, f(x) + g(x)\bigr) &= c\, f'(x) + g'(x) && \text{(linearity)} \\ \frac{d}{dx} e^x &= e^x \\ \frac{d}{dx} \ln x &= \frac{1}{x} \quad (x \gt 0) \end{aligned}

The last two rows use the exponential and natural logarithm. For products and compositions of functions there are the product rule and the chain rule, which build on these.

Differentiability can fail

The derivative does not exist at every point. The function ∣x∣|x| has a sharp corner at x=0x = 0. The slope from the left is −1-1 and from the right is +1+1, so the two one-sided limits disagree and the limit does not exist. A continuous function can still fail to be differentiable at a corner or a cusp, and a function with a jump is not differentiable there either.

Linear approximation

Near x=ax = a, a differentiable function looks like its tangent line:

f(a+h)≈f(a)+f′(a) hfor small h.f(a + h) \approx f(a) + f'(a)\, h \quad \text{for small } h.

This is the single most useful consequence of the derivative in practice. It lets you estimate hard values from easy ones (see the square-root example below), and it is the reason gradient descent works (the next step is a small move in the direction the derivative points).

Worked examples

Example
The slope of x squared at x = 3

Let f(x)=x2f(x) = x^2 and x=3x = 3. Then f(3)=9f(3) = 9 and

  1. f(3+h)=(3+h)2=9+6h+h2f(3+h) = (3+h)^2 = 9 + 6h + h^2.
  2. f(3+h)−f(3)h=6h+h2h=6+h\dfrac{f(3+h) - f(3)}{h} = \dfrac{6h + h^2}{h} = 6 + h (valid for h≠0h \neq 0).
  3. Let h→0h \to 0: the expression becomes 66.

So f′(3)=6f'(3) = 6. Check it numerically with smaller and smaller steps:

hhf(3+h)−f(3)h\frac{f(3+h)-f(3)}{h}
17
0.16.1
0.016.01
0.0016.001

The numbers approach 6. The general rule gives the same answer: ddxx2=2x\frac{d}{dx} x^2 = 2x, and 2⋅3=62 \cdot 3 = 6.

Interpretation: near x=3x = 3, every unit increase in xx raises ff by about 6 units.

Example
Speed of a falling object at t = 2

A dropped object falls s(t)=5t2s(t) = 5t^2 metres after tt seconds. Its speed at t=2t = 2 is s′(2)s'(2).

  1. Average speed over [2,2+h][2, 2+h]: s(2+h)−s(2)h\dfrac{s(2+h) - s(2)}{h}.
  2. s(2+h)=5(4+4h+h2)=20+20h+5h2s(2+h) = 5(4 + 4h + h^2) = 20 + 20h + 5h^2, and s(2)=20s(2) = 20.
  3. The difference quotient is 20h+5h2h=20+5h\dfrac{20h + 5h^2}{h} = 20 + 5h.
  4. Let h→0h \to 0: the speed is 2020 m/s.

Using the power rule directly, s′(t)=10ts'(t) = 10t, so s′(2)=20s'(2) = 20. Both methods agree.

Interpretation: two seconds in, the object is moving at 20 metres per second, and that speed is still increasing at 10 m/s every second.

Example
Estimating a square root with a tangent line

Estimate 4.02\sqrt{4.02} without a calculator. Let f(x)=xf(x) = \sqrt{x}, so f′(x)=12xf'(x) = \frac{1}{2\sqrt{x}}.

  1. Pick the nearby point a=4a = 4, where f(4)=2f(4) = 2 and f′(4)=12⋅2=14f'(4) = \frac{1}{2 \cdot 2} = \frac{1}{4}.
  2. Here h=0.02h = 0.02. The linear approximation gives f(4.02)≈2+14⋅0.02=2+0.005=2.005f(4.02) \approx 2 + \frac{1}{4} \cdot 0.02 = 2 + 0.005 = 2.005.
  3. The true value is about 2.0049942.004994, so the error is about 0.0000060.000006.

Interpretation: the tangent line at x=4x = 4 tracks the square root curve closely over a small step. The error grows as hh grows, and near x=0x = 0 the square root's derivative blows up, so this trick fails there.

Tradeoffs and failure modes

Derivatives are the right tool when a function is smooth and you need local behaviour. They can mislead when the data or the function does not cooperate.

SituationWhat goes wrongBetter choice
Function has a corner or kink (like ∣x∣\lvert x\rvert)Derivative does not exist at the kinkUse a subgradient, or smooth the function (e.g. a Huber loss)
Estimating a derivative with a very small hh on a computerRound-off error dominates; the quotient is noiseSymbolic differentiation, or automatic differentiation
Differentiating noisy measured dataDifferences of noisy values amplify the noiseSmooth the data first, or fit a model and differentiate the model
Quantity only known at discrete timesNo limit to takeFinite differences, yk+1−ykΔt\frac{y_{k+1} - y_k}{\Delta t}
Large steps are neededLinear approximation is poor far from aaUse higher-order terms, or solve the problem directly

History

Methods for tangent lines came first. Pierre de Fermat had a technique for finding maximum and minimum values in the 1630s that amounted to setting a difference quotient to zero. Isaac Newton developed his "method of fluxions" in the 1660s, treating quantities as flowing in time, and used the idea in his work on motion. Gottfried Wilhelm Leibniz developed the notation dydx\frac{dy}{dx} and published his account in 1684. The notation survived because it makes the chain rule look like cancellation of fractions.

Newton and Leibniz each developed calculus independently, and a long dispute over priority followed. The modern definition using limits took more than a century to settle. Augustin-Louis Cauchy gave a definition in terms of limits in the 1820s, and later nineteenth-century mathematicians, Karl Weierstrass among them, made the epsilon-delta form standard. Once the definition was rigorous, the derivative became the basis for most of applied mathematics.

Check yourself

QuestionRecall: what does the derivative f′(x)f'(x) represent geometrically?Show answer

It is the slope of the tangent line to the graph of ff at the point (x,f(x))(x, f(x)). It is the limit of the slopes of secant lines through (x,f(x))(x, f(x)) and (x+h,f(x+h))(x+h, f(x+h)) as hh goes to zero.

QuestionCompute ddx(4x3−7x)\frac{d}{dx}\left(4x^3 - 7x\right) and evaluate it at x=2x = 2.Show answer

Apply the power rule and linearity term by term: ddx(4x3)=12x2\frac{d}{dx}(4x^3) = 12x^2 and ddx(−7x)=−7\frac{d}{dx}(-7x) = -7. So the derivative is 12x2−712x^2 - 7. At x=2x = 2 this is 12⋅4−7=48−7=4112 \cdot 4 - 7 = 48 - 7 = 41.

QuestionWhy does ∣x∣|x| have no derivative at x=0x = 0, even though it is continuous there?Show answer

Continuity only says the function has no jump. Differentiability needs the difference quotient to settle to one value. From the right, ∣h∣−0h=1\frac{|h| - 0}{h} = 1 for h>0h \gt 0. From the left, ∣h∣h=−1\frac{|h|}{h} = -1 for h<0h \lt 0. The two one-sided limits differ, so the two-sided limit does not exist. The graph has a corner there, and a corner has no single tangent line.

QuestionA ball's height is h(t)=20t−5t2h(t) = 20t - 5t^2 metres. When is its upward speed zero, and what does that moment mean physically?Show answer

The speed is h′(t)=20−10th'(t) = 20 - 10t. Setting this to zero gives t=2t = 2 seconds. At that moment the ball stops rising, which is the top of its path. Its height there is h(2)=40−20=20h(2) = 40 - 20 = 20 metres.

Sources