3 ms·
I quite agree this is not exact and is not automatic differentiation (which would be exact up to round-off). However, for holomorphic functions, contour integr
by kkylin 7y ago
I quite agree this is not exact and is not automatic differentiation (which would be exact up to round-off). However, for holomorphic functions, contour integration can be much more accurate. The reason is that under fairly general conditions, the trapezoid rule for contour integrals is geometrically accurate. Thus, using stepsize h gives errors that are O(e^{-c/h}). (See the Trefethen paper cited in my other comment in this post.) In contrast, standard centered difference has error O(h^2). Moreover, finite differences are unstable: because of loss of precision in taking differences, the relative error tends to blow up as h goes to 0. Contour integration, though more expensive (because it needs many more function evaluations for the same stepsize h), does not, because integration is better behaved numerically.
- eigenspace 7y agoThe reason the the difference in accuracy is that this method has N steps instead of 2. Another poster in the thread mentioned this as well.
- kkylin 7y agoYes and no -- of course if one uses more points the result can be more accurate. The real difference between a center difference and contour integration is that differences suffer from loss of information in finite-precision arithmetic. For example, in (f(x+h) - f(x-h))/(2h), the numerator actually contains very few bits of information when h is small. The Cauchy integral formula, in contrast, behaves quite well so long as the point of evaluation is bounded away from the contour.
- kkylin 7y agoAlso (in case anyone's still looking at this thread) the accuracy is a separate issue from numerical stability. That simple quadrature rules like trapezoid can be so accueate (error is geometric, not just algebraic to high order) is because of the smoothness of the integrand and periodicity. An N-point high-order estimate of the derivative along the real line, using finite differences, would not have these properties.