Post Reply 
Programming exercise (RPL/RPN) - Reciprocal Fibonacci Constant
02-18-2017, 01:26 AM
Post: #20
RE: Programming exercise (RPL/RPN) - Reciprocal Fibonacci Constant
(02-18-2017 12:53 AM)Joe Horn Wrote:  
(02-16-2017 08:29 PM)Gerson W. Barbosa Wrote:  7 RFC --> 3.23525641025

Many of the programs submitted in this thread suffer from avoidable roundoff error due to summing the reciprocals starting with the largest and ending with the smallest, which is always a Bad Thing to do. For example, the above value is incorrect (the last digit should be 6), but if the reciprocals are summed in the opposite order, beginning with 1/F(7) and ending with 1/F(1), then the correct result is obtained.

In general, the following RFC(n) when obtained by summing 1/F(1) through 1/F(n) are incorrect (in a 12-digit mantissa machine), but when obtained by summing 1/F(n) through 1/F(1) they are correct (rounded to 12 significant digits of course):

RFC 7; 8; 13-24; 27-29; 31-36; and all n>=38.

Both summation orders fail only for RFC 25 & 37; higher precision methods are required for those two values of n. For reference, here are their correct rounded values:
RFC(25) = 3.35986409965
RFC(37) = 3.35988559927

Yes, I do remember this fact from another program exercise I first did in 1984 when I was studying Pascal, exercise 8.3 in Systematic Programming, An Introduction, by Prof. Niklaus Wirth. :-)

That's one of the reasons, along with Kahan's sum in the built-in summation command, that Paul Dale's first wp34s program gives all 34 correct digits. I had tried REVLIST after INV in Claudio L.'s program and noticed some improvement in accuracy.

Doing the sum backwards make programs longer, however. But your are right, accuracy-wise, that's the method that should be used.

Thank you!

Gerson.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Programming exercise (RPL/RPN) - Reciprocal Fibonacci Constant - Gerson W. Barbosa - 02-18-2017 01:26 AM



User(s) browsing this thread: 1 Guest(s)