Numerical Differentiation

Approximate numerical formulae can be derived using Taylor series.

For all the definitions below, hh is a small positive number, and is called the step size.

First Order Derivative

Taylor series expansion of f(x0+h)f(x_0+h) around x0x_0, truncated after 1st1^{\text{st}} derivative.

f′(x0)=f(x0+h)−f(x0)h+h2!f(2)(ϵ)f'(x_0) = \frac{f(x_0+h) - f(x_0)}{h} + \frac{h}{2!} f^{(2)}(\epsilon)

Error is bounded by:

M∣h∣2\frac{M \lvert h \rvert}{2}

Forward Difference Formula

f′(x0)=f(x0+h)−f(x0)h+O(h)f'(x_0) = \frac{f(x_0+h) - f(x_0)}{h} + O(h)

Here MM is a bound on f(2)(x)f^{(2)}(x) between x0x_0 and x0+hx_0 + h.

Backward Difference Formula

f′(x0)≈f(x0)−f(x0−h)h+O(h)f'(x_0) \approx \frac{f(x_0) - f(x_0 - h)}{h} + O(h)

Here MM is a bound on f(2)(x)f^{(2)}(x) between x0x_0 and x0−hx_0 - h.

Centered Difference Formula

Also known as three-point mid point formula. Truncated after 2nd2^{\text{nd}} derivative.

f′(x0)=f(x0+h)−f(x0−h)2h+O(h2)f'(x_0) = \frac{f(x_0 + h) - f(x_0 - h)}{2h} + O(h^2)

Error is in order of O(h2)O(h^2) which is better than O(h)O(h).

Second Order Derivatives

Second Forward Difference Formula

f(2)(x0)=1h2[f(x0+2h)−2f(x0+h)+f(x0)]+O(h)f^{(2)}(x_0) = \frac{1}{h^2} \Big[ f(x_0 + 2h) - 2f(x_0 + h) + f(x_0) \Big] + O(h)

Second Backward Difference Formula

f(2)(x0)=1h2[f(x0)−2f(x0−h)+f(x0−2h)]+O(h)f^{(2)}(x_0) = \frac{1}{h^2} \Big[ f(x_0) - 2f(x_0 - h) + f(x_0 - 2h) \Big] +O(h)

Second Centered Difference Formula

f(2)(x0)=1h2[f(x0+h)−2f(x0)+f(x0−h)]+O(h2)f^{(2)}(x_0) = \frac{1}{h^2} \Big[ f(x_0 + h) - 2f(x_0) + f(x_0 - h) \Big]+ O(h^2)

Higher Order Derivatives

For nn-th derivative, Taylor series is truncated after nthn^{\text{th}} derivative.

n-th Forward Difference Formula

f(n)(x)=1hn∑i=0n(−1)n−i(ni)f(x+ih)+O(h)f^{(n)}(x) =\frac{1}{h^n} \sum_{i=0}^{n} (-1)^{n-i} \binom{n}{i} f(x + ih)+ O(h)

n-th Backward Difference Formula

f(n)(x)=1hn∑i=0n(−1)i(ni)f(x−ih)+O(h)f^{(n)}(x)=\frac{1}{h^n} \sum_{i=0}^{n} (-1)^i \binom{n}{i} f(x - ih)+ O(h)

n-th Centered Difference Formula

f(n)(x)=1hn∑i=0n(−1)i(ni)f(x+(n2−i)h)+O(h2)f^{(n)}(x)=\frac{1}{h^n} \sum_{i=0}^{n} (-1)^i \binom{n}{i} f\left(x + \left(\frac{n}{2} - i\right)h\right)+ O(h^2)

Accuracy

The accuracy of these divided difference formulas can be increased by including additional terms in the Taylor series. In each step the accuracy is improved by a power of hh.

f′(x0)=1h[−32f(x0)+2f(x0+h)−12f(x0+2h)]+O(h2)f'(x_0) = \frac{1}{h} \left[ -\frac{3}{2} f(x_0) +2f(x_0+h) -\frac{1}{2}f(x_0+2h) \right] +O(h^2)

Wolfram Mathematica notebook

The summary notebook defines every function used in this module, with documentation and no examples, as a starting point for your own problems.

Written by October 17, 2026 1 min read
Was this helpful?