Finite Difference on Finite Difference
September 05, 2026
I was recently writing a finite-difference test for an analytic acceleration implementation.
Suppose we have a smooth trajectory , and the implementation gives its acceleration . To test it independently, we can estimate velocity with a central difference,
and then finite-difference that estimate again:
The question is how much numerical error to expect in . That determines the finite-difference step sizes and, in turn, the test tolerance.
One Central Difference
For a smooth function ,
So the truncation error is .
Floating-point arithmetic adds another source of error. If we ignore scale factors and other constants, the subtraction carries roundoff, where is machine epsilon. Dividing by turns this into .
A simple error model is therefore
where and collect the truncation and roundoff constants.
The optimal step minimizes . Setting gives
so, up to constants,
The ratio only enters through a cube root, so the optimal step is not very sensitive to moderate errors in these constants. For order-of-magnitude reasoning, treating them as order one is usually enough.
A Naive Nested Error Model
The velocity estimate has error
The acceleration estimate applies another central difference and divides by . If we treat both parts of the inner error as independent perturbations at each time sample, we would get
The problem with this model is that the inner truncation error is not an independent perturbation at each time sample. It has smooth temporal structure.
The Inner Truncation Error Is Smooth
The inner central difference has the more specific expansion
Its leading truncation error is therefore , which varies smoothly with .
Substituting this expansion into the outer central difference gives
Remark
The outer difference is applied to as a function of , which gives
Evaluating and uses the fact that the derivative operator and a constant shift operator commute. The central difference is a combination of two such shifts, so
Each is then a central difference of and , giving and . Substituting recovers the expansion above.
So the truncation error is
The second finite difference does not turn the inner truncation error into .
The outer difference does divide by , but the change in the inner truncation bias between and is itself . The cancels.
Roundoff does not have the same smooth dependence on time. The inner roundoff is , and the outer finite difference introduces another factor of .
The leading error model is therefore
Choosing and
We can choose both step sizes by minimizing this error model.
The optimum satisfies
and
These two equations imply .
So equal inner and outer step sizes are a consequence of this model, not an assumption.
Writing both as ,
Setting gives
Therefore,
For double precision, is roughly .
The constants matter even less here than in the first-derivative case, since their ratio only enters through a fourth root.
At the optimum, the minimum error scales as
This gives the expected numerical floor up to the problem-dependent constants that the simple model leaves out.
For a test, a reasonable workflow is to choose and near this scale, sweep around them numerically, observe the actual error floor, and set the tolerance above that floor with some margin.
Takeaway
The key point is that finite-difference truncation error has temporal structure.
For a smooth trajectory, the leading truncation bias is itself smooth in time. Applying another finite difference therefore differentiates that bias; it does not simply divide its magnitude by the new step size.
That is why the inner truncation error remains , while roundoff picks up the additional .