Re: Points sampled by N[Derivative[]]

*To*: mathgroup at smc.vnet.net*Subject*: [mg71993] Re: Points sampled by N[Derivative[]]*From*: "Andrew Moylan" <andrew.j.moylan at gmail.com>*Date*: Thu, 7 Dec 2006 06:25:56 -0500 (EST)*References*: <ej72s5$ita$1@smc.vnet.net><el68sd$300$1@smc.vnet.net>

Yep I see what's happening now, thanks Paul. I think it's strange for Mathematica to transparently employ such a strangely non-adaptable algorithm for this purpose, rather than using e.g. ND from the NumericalMath`NLimits` package. What do you think? Cheers, Andrew On Dec 6, 9:17 pm, Paul Abbott <p... at physics.uwa.edu.au> wrote: > In article <ej72s5$it... at smc.vnet.net>, > "Andrew Moylan" <andrew.j.moy... at gmail.com> wrote: > > > > > 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.Rationalize 0.05263157894736836 and you obtain 1/19 -- and so you may be > able to work out what is happening here. If you multiply your list by 19 > the sampling pattern is clear. > > Cheers, > Paul > > _______________________________________________________________________ > Paul Abbott Phone: 61 8 6488 2734 > School of Physics, M013 Fax: +61 8 6488 1014 > The University of Western Australia (CRICOS Provider No 00126G) > AUSTRALIA http://physics.uwa.edu.au/~paul