Points sampled by N[Derivative[]]
- To: mathgroup at smc.vnet.net
- Subject: [mg71267] Points sampled by N[Derivative[]]
- From: "Andrew Moylan" <andrew.j.moylan at gmail.com>
- Date: Sun, 12 Nov 2006 06:48:13 -0500 (EST)
Hi all, I am trying to understand the way in which Mathematica automatically computes numerical approximations to derivatives which cannot be differentiated symbolically. Consider the following function: f[(x_)?NumericQ] := (Sow[x]; 1/(x - 1)^2) By supplying a numerical argument to Derivative[f], we can see the points at which f is sampled by Mathematica when approximating the derivative: Reap[f'[0.5]] gives: {15.997945911907477, {{0.5, 0.5526315789473684, 0.6052631578947368, 0.6578947368421053, 0.7105263157894737, 0.763157894736842, 0.8157894736842105, 0.868421052631579, 0.9210526315789473, 0.4473684210526316, 0.39473684210526316, 0.34210526315789475, 0.2894736842105263, 0.2368421052631579, 0.1842105263157895, 0.13157894736842107, 0.07894736842105265}}} It's useful to see the points relative the central point (0.5): %[[2]] - 0.5 gives: {{0., 0.05263157894736836, 0.10526315789473684, 0.1578947368421053, 0.21052631578947367, 0.26315789473684204, 0.3157894736842105, 0.368421052631579, 0.42105263157894735, -0.05263157894736842, -0.10526315789473684, -0.15789473684210525, -0.21052631578947367, -0.2631578947368421, -0.3157894736842105, -0.3684210526315789, -0.42105263157894735}} Why does the number 0.05263157894736836 appear here? A little testing shows that this constant appears frequently when Mathematica automatically computes numerical approximations to derivatives. Does Mathematica use the built-in function ND to compute the approximation to the derivative? It appears not, because (i) ND is a one-sided approximation to the derivative, and (ii) ND samples its argument at a geometrically-spaced set of abscissae, not a linearly-spaced set as N[Derivative[]] seems to: Needs["NumericalMath`NLimit`"] Reap[ND[f[x], x, 0.5, Scale -> 0.1]] gives: {16.0000000007074, {{0.5, 0.6, 0.55, 0.525, 0.5125, 0.50625, 0.503125, 0.5015625}}} Can anyone explain the way N[Derivative] works? Cheers, Andrew