Statistical Methods
Check a numerical derivative across step sizes
Define the task
Identify the input coordinate, its units and the output being differentiated. A numerical derivative describes a local change in that output per unit change in the input. Freeze all other inputs while evaluating the function. A stochastic function needs a reproducible evaluation scheme before differences can be interpreted.
Carry out the check
For a forward difference, subtract f(x) from f(x+h) and divide by h. For a centered difference, use f(x+h) minus f(x−h) divided by twice h. Repeat at smaller steps and compare results. Large steps can hide curvature, while very small steps amplify subtraction error or noise. The centered formula is useful only when both sides are within the function's domain.
Worked hypothetical example
For hypothetical f(x)=x² at x=2 and h=0.1, the three values are 3.61, 4 and 4.41. Forward difference gives 4.1, backward difference gives 3.9 and centered difference gives 4, matching the analytic derivative. Agreement in this quadratic example does not guarantee accuracy for another function. Record the step and evaluation values so another analyst can reproduce the check.
Method checked 14 November 2026 against SciPy documentation: approx_fprime.