Post Reply 
Programming Exercise (HP-15C, 15C LE - and others)
04-06-2014, 11:24 AM (This post was last modified: 04-06-2014 12:17 PM by Gerson W. Barbosa.)
Post: #99
RE: Programming Exercise (HP-15C, 15C LE - and others)
(04-06-2014 06:24 AM)Thomas Klemm Wrote:  Now we have 3 different ways to calculate the same thing:
  1. Borwein's formula using tangent numbers
  2. Convergence acceleration using Euler's transformation
  3. Gerson's method using continued fractions

Do you have a proof of your formula or is it still a conjecture? Congratulations to your discovery! Your method appears to be more efficient than the other two.

No, the proof has yet to be found (in case there isn't one already), by someone more capable than I. I only found this empirically, using the WP 34S in double precision and the sum of the first 10000 terms of the series, the difference to ln(2) being found to be 1/20001 + (1/20001 + 4/(20001 + 9/(20001 + 16/(20001 + ... Then I assumed the next numerators to be 25, 36, 49...

(04-06-2014 06:24 AM)Thomas Klemm Wrote:  
Quote:The first parameter is the number of terms in the continued fraction, minus one.
This parameter is ignored. Instead the 2nd parameter is used twice (cf. lines 14-15).

Thank you very much! The timings and results were indeed strange. I ought to have checked them more carefully. I think I got it right this time. Faster, and only one step longer:

Code:

01 LBL A
02 STO I
03 STO 0
04 CLx
05 LBL 0
06 RCL I
07 DSE 
08 RCL I
09 *
10 1/x
11 +
12 DSE  
13 GTO 0
14 RCL 0   
15 2
16 *
17 1
18 +
19 STO 0
20 Rv
21 x<>y
22 x<>I
23 LBL 1
24 RCL 0
25 +
26 RCL I
27 x^2
28 x<>y
29 /
30 DSE
31 GTO 1
32 RCL 0
33 +
34 1/x
35 +
36 RTN

4 10 GSB A --> 0.6931471806 ( 9 s )

5 8 GSB A --> 0.6931471805 ( 8.9 s )

6 8 GSB A --> 0.6931471806 ( 9.6 s )

10 4 GSB A --> 0.6931471808 ( 11 s )

7 6 GSB A --> 0.6931471805 ( 8.6 s )

6 6 GSB A --> 0.6931471807 ( 8.4 s )

Cheers,

Gerson.

P.S.: My HP-15C (2905B29505) is somewhat slower:

4 10 GSB A --> 0.6931471806 ( 10.2 s )

Code:

01 LBL A
02 STO I
03 STO 0
04 CLx
05 LBL 0
06 RCL I
07 DSE I
08 RCL* I
09 1/x
10 +
11 DSE I
12 GTO 0
13 2   
14 RCL* 0
15 1
16 +
17 STO 0
18 Rv
19 x<>y
20 x<> I
21 LBL 1
22 RCL+ 0
23 RCL I
24 x^2
25 x<>y
26 /
27 DSE I
28 GTO 1
29 RCL+ 0
30 1/x
31 +
32 RTN

On the other hand the HP-15C LE might do it in about 70 ms :-)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Programming Exercise (HP-15C, 15C LE - and others) - Gerson W. Barbosa - 04-06-2014 11:24 AM



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