Mathwords logoMathwords

Numerical Differentiation — Definition, Formula & Examples

Numerical differentiation is a technique for estimating the derivative of a function using known function values at specific points, rather than applying symbolic differentiation rules. It is especially useful when the function is defined only by data or is too complex to differentiate analytically.

Given a function ff evaluated at discrete points, numerical differentiation approximates f(x)f'(x) by computing a finite difference quotient. The simplest forms—forward, backward, and central differences—are derived from truncating the Taylor series expansion of ff about xx, yielding approximations with known orders of truncation error in terms of the step size hh.

Key Formula

f(x)f(x+h)f(xh)2hf'(x) \approx \frac{f(x+h) - f(x-h)}{2h}
Where:
  • f(x)f'(x) = Approximate value of the derivative at x
  • ff = The function being differentiated
  • xx = The point at which the derivative is estimated
  • hh = Step size (a small positive number)

How It Works

You choose a small step size hh and evaluate ff at nearby points. The forward difference uses f(x+h)f(x+h) and f(x)f(x); the backward difference uses f(x)f(x) and f(xh)f(x-h); the central difference uses f(x+h)f(x+h) and f(xh)f(x-h). The central difference is generally more accurate because its truncation error is O(h2)O(h^2), compared to O(h)O(h) for forward and backward differences. However, making hh extremely small on a computer can introduce round-off error, so there is a practical tradeoff in choosing hh.

Worked Example

Problem: Estimate f(2)f'(2) for f(x)=x3f(x) = x^3 using the central difference formula with h=0.1h = 0.1.
Step 1: Compute f(x+h)=f(2.1)f(x+h) = f(2.1) and f(xh)=f(1.9)f(x-h) = f(1.9).
f(2.1)=2.13=9.261,f(1.9)=1.93=6.859f(2.1) = 2.1^3 = 9.261, \quad f(1.9) = 1.9^3 = 6.859
Step 2: Apply the central difference formula.
f(2)9.2616.8592(0.1)=2.4020.2=12.01f'(2) \approx \frac{9.261 - 6.859}{2(0.1)} = \frac{2.402}{0.2} = 12.01
Step 3: Compare with the exact derivative f(x)=3x2f'(x) = 3x^2, so f(2)=12f'(2) = 12. The approximation is very close.
Error=12.0112=0.01\text{Error} = |12.01 - 12| = 0.01
Answer: The central difference estimate of f(2)f'(2) is 12.0112.01, with an error of 0.010.01 compared to the exact value of 1212.

Why It Matters

Numerical differentiation is essential when working with experimentally measured data or computer simulations where no closed-form expression exists. Engineers use it to compute stress rates from sensor readings, and it forms the backbone of finite difference methods for solving differential equations in physics and finance.

Common Mistakes

Mistake: Using an extremely small step size hh and expecting better accuracy.
Correction: On computers, very small hh values amplify round-off error. A moderate hh (e.g., h105h \approx 10^{-5} for double precision) often gives the best balance between truncation error and round-off error.