Estimating a Derivative with a Forward Difference
A forward difference divides the change in a function over a step by the step length.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace a quadratic
For \(f(x)=x^2\), \((f(2+h)-f(2))/h=4+h\) in exact arithmetic. With \(h=0.1\), that gives 4.1 instead of the exact derivative 4. See relative and absolute error.
Choose the step thoughtfully
At a step of one hundredth the exact approximation is 4.01. A smaller step reduces this truncation error, but floating-point subtraction can lose information when sampled values become too close. See cancellation.[1][2]
Derive the approximation's error on a quadratic
For \(f(x)=x^2\), the forward difference at two is \(\big((2+h)^2-4\big)/h=4+h\) in exact arithmetic. With \(h=0.1\) the estimate is 4.1. The derivative is four. See the symmetric central difference.
h=0.1 → estimate 4.1
h=0.01 → estimate 4.01
Exact error in this example equals h
Choose size with rounding as well as truncation in mind
In finite precision, two nearly equal evaluations can subtract inaccurately, and a step so small that \(2+h\) rounds to two gives no progress. Test steps at several scales to locate both regimes.