Ralph G Selfridge wrote: > I'm not sure what the problem really is. If this converges it is to one of > 3, 5 or 100. Purely experiment says 3 and 5 are unstable in convergamce. I > kind'a doubt that carrying more significant figures will fix that, but I'm > lazy enough not to do the epsilon/delta paper work. While not impossible > it seems unlikely that more digits will change anything. > > On the other hand re-structuring the function might change the convergance > value, while not really changing f > This example is designed to illustrate how rules of thumb for eliminating rounding error can lead one astray, and that you really cannot avoid error analysis. In particular
- there are no usual suspects like cancellation and tiny divisors - significance arithmetic and random rounding fail - increasing the precision to a 64-bit mantissa will give the correct result for the particular initial conditions given, but you can easily change them to defeat this, too. Although the recurrence does not look especially unstable, it is, as an analytic solution shows. The general solution g(n) is given by (h n+1)%(h n) where h=:3 : '(a,b,c) +/ . * 3 5 100^y' and (a,b,c) is determined by the initial conditions up to a nonzero scalar multiple. Thus g(n)->100 if c~:0 g(n)->5 if c=0 and b~:0 g(n)->3 if c=0 and b=0 For the initial conditions given, a=b and c=0. Rounding errors using a 53-bit mantissa cause the recurrence to behave as though c~:0. As Roger and Raul have indicated, doing the calculation exactly in rationals will give the correct answer: however, this is not an option for most practical numerical problems. As Ralph suggests, restructuring the problem is the solution. Best wishes, John ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
