From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: where is the mistake
Date: Sun, 27 Feb 2011 11:30:23 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 14
Message-ID: <ikdckf$c3g$>
References: <ikbqin$4gr$> <ikbtod$q12$> <ikcln2$k52$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1298806223 12400 (27 Feb 2011 11:30:23 GMT)
NNTP-Posting-Date: Sun, 27 Feb 2011 11:30:23 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: comp.soft-sys.matlab:712674

"Nena Kabranski" wrote in message <ikcln2$k52$>...
> Thank you very much for your response. It was very thorough and clear. I hope you teach somewhere so that more people benefit from your ability to explain.
- - - - - - - - -
  It should be pointed out that one way around your round-off error problem is to compute your iteration backwards.  This way the effect of initial errors will decrease rather than increase as the iteration proceeds.  Of course the difficulty with that is not knowing what initial value to use to start the iteration.  The remedy for that is to start a number of entries beyond the point where sufficiently accurate results are to be obtained and begin with an initial zero.  It can be shown that by abandoning the top 18, the remaining p values will be accurate out to something like 14 or 15 decimal places.  (Actually 18 may be overly cautious.)  You can use the following code to get p values from p(1) to p(n) for an arbitrary n:

 p = zeros(n+18,1); % The zero at the top end initiates the iteration
 for k = n+17:-1:1
  p(k) = (exp(1)-p(k+1))/(k+1); % Your iteration going backwards
 p = p(1:n);  % Discard the top 18 entries

  With regard to teaching, many years ago I did give lectures in some college-level math courses but I have been retired for a long time now, so this newsgroup acts as a substitute to keep the little octogenarian "gray cells" active.

Roger Stafford