Re: A problem about numerical precision

*To*: mathgroup at smc.vnet.net*Subject*: [mg52633] Re: A problem about numerical precision*From*: Peter Pein <petsie at arcor.de>*Date*: Sun, 5 Dec 2004 02:08:10 -0500 (EST)*References*: <cos0o0$dhf$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Guofeng Zhang wrote: > Hi, > I met one problem when I do some iteration: By increasing numerical > precision, the results are so different from the original one! I > don't know what went wrong, and hope to get some answers. > > The code is > > delta = 1/100; > a = 9/10; > b = -3*1.4142135623730950/10; > A = { {1,0}, {b,a} }; > B= { {-1,1}, {-b,b} }; > > f[v_,x_] := If[ Abs[ (10^20)*v-(10^20)*x]>(10^20)*delta, 1, 0 ]; > > M = 3000; > it = Table[0, {i,M}, {j,2} ]; > it[ [1] ] = { -delta/2, (a+b)*(-delta/2) }; > > For[ i=1, i<M, it[ [i+1]] = A.it[[i]]+f[ it[ [i,1] ], it[ [i,2] ] > ]*B.it[ [i] ]; i++ ]; > temp = Take[it, -1000]; > > ListPlot[ temp ]; > > By evaluating this, I got an oscillating orbit. I got the same using > another program. However, if I increase the numerical precision by > using > b = -3*1.4142135623730950``200/10; > to substitute the original b, the trajectory would converge to a fixed > point instead of wandering around! > > I don't know why. I am hoping for suggestions. Thanks a lot. > > Guofeng > MatrixNorm[A]>1 and approximations are represented by a finite number of digits. So what did you expect? b.t.w.: setting the precision to a higher value will give your oscillating orbit again: delta = 1/100; a = 9/10; b = -3*Sqrt[2.`2000]/10; A = {{1, 0}, {b, a}}; B = {{-1, 1}, {-b, b}}; m = 1000; temp = Take[NestList[A . #1 + If[Abs[Subtract @@ #1] > delta, B . #1, 0] & , -{(delta/2), 1/2*(a + b)*delta}, 3*m], -m]; ListPlot[temp, PlotRange -> All, PlotStyle -> AbsolutePointSize[0.001]]; -- Peter Pein 10245 Berlin