Trading Dev AcademyFree quant education

Free lesson · Differential calculus

The derivative: from an average slope to an instantaneous rate

Open interactive lessonPractice calculationsExplore labs

Start with the idea

  • Average change divides the output difference by an input difference.
  • The derivative is the limit of that ratio as the input difference shrinks.
  • It measures local sensitivity, not the whole future path.
Symbols, units & horizon
  • x: input at which slope is measured
  • h: nonzero input increment before taking the limit
  • f′(x), df/dx: derivative of f with respect to x
  • Δf: finite output change
  • lim h→0: limiting slope as the increment shrinks
  • ⇒: implies for the stated function

When and why to use this

Use a derivative for instantaneous rates and local sensitivities. Open the slope lab to move the observation point and shrink the secant interval.

  • A secant line joins two points on a curve.
  • A tangent captures the limiting slope at one point when a finite derivative exists.
  • For position as a function of time, average slope is average velocity and the derivative is instantaneous velocity.
  • A derivative has output units divided by input units.
  • Differentiability implies continuity, but continuity alone is not enough: the absolute-value function has a corner at zero, with left slope −1 and right slope +1.
f′(x)=limh→0⁡f(x+h)−f(x)h,f(x)=x2 ⇒ f′(x)=2x
Calculus: derivation and arithmetic

The derivative: from an average slope to an instantaneous rate

  1. For f(x)=x², expand f(x+h)=(x+h)²=x²+2xh+h².
  2. Subtract f(x)=x² and divide by nonzero h: (2xh+h²)/h=2x+h.
  3. As h approaches zero, the h term disappears, leaving f′(x)=2x. At x=3 the tangent slope is 6.
Work it by hand

At x=3, a forward step h=.1 gives slope (3.1²−3²)/.1=6.1. With h=.01 the slope is 6.01. The derivative is exactly 6.

An analogy to remember

An average journey speed uses two odometer readings. A speedometer approximates what the rate is at the present instant.

How this becomes a building block

This is a complete slope formula and also a component inside larger models. Option delta is a derivative of price with respect to spot. A cost model’s derivative is marginal cost: the extra estimated expense for a small increase in order size. Neither derivative forecasts the input change.

Python implementation

Self-contained teaching example. Python 3.10+; dependencies and input conventions are shown in the code and notation. Run in your own Python environment.

def square(x): return x*x

def square_derivative(x): return 2*x

def forward_slope(function, x, h):
    if h == 0: raise ValueError("Use a nonzero step")
    return (function(x+h)-function(x))/h

print(square_derivative(3), forward_slope(square,3,.1))

Continue learning

Differential Calculus: Limits & Derivatives — all lessons
  1. Start with a straight line: input, output and slope
  2. Functions, limits and continuity
  3. The derivative: from an average slope to an instantaneous rate
  4. Core derivative rules: constants, powers and sums
  5. Derivative rules: powers, products, quotients and compositions
  6. Second derivatives, Taylor expansions and numerical error
  7. Stationary points, optimisation and Newton’s method

Quantitative finance and development glossary · Python resources and libraries · Research sources and limitations