c c Numerical Analysis: c The Mathematics of Scientific Computing c D.R. Kincaid & E.W. Cheney c Brooks/Cole Publ., 1990 c c Section 2.3 c c Example of unstable sequence c c c file: unstab1.f c dimension x(0:15),y(0:15),e(0:15),f(0:15) double precision y c print * print *,' Unstable sequence' print *,' Section 2.3, Kincaid-Cheney' print * print 4,'n','x(n)','true','error','rel. error' c x(0) = 1.0 x(1) = 1.0/3.0 y(0) = 1.d0 y(1) = 1.d0/3.d0 c do 2 n=1,14 x(n+1) = (13./3.)*x(n) - (4./3.)*x(n-1) y(n+1) = (1.d0/3.d0)**(n+1) 2 continue c do 3 n=0,15 e(n) = real(dble(x(n)) - y(n)) f(n) = abs(e(n)/real(y(n))) print 5,n,x(n),real(y(n)),e(n),f(n) 3 continue c 4 format (a6,a10,a15,a16,a19) 5 format(1x,i5,4(2x,e13.6)) stop end