Post Reply 
One-liner mini-challenge [HP-71B]
04-22-2015, 10:57 PM (This post was last modified: 04-24-2015 04:14 PM by Gerson W. Barbosa.)
Post: #16
RE: One-liner mini-challenge [HP-71B]
Hello again, Valentin,

(04-20-2015 09:23 PM)Valentin Albillo Wrote:  
(04-20-2015 04:41 PM)Gerson W. Barbosa Wrote:  At page 81 of his book Prime Obsession, John Derbyshire says:

"...if you take the trouble to actually work out the sums and add them up, you see that the first ten terms add up to 5.020997899..., the first hundred add up to 18.589603824..., the first thousand add up to 61.801008765..., the first ten thousand to 198.544645449... and so on."

I followed the link but regrettably page 81 is nowhere to be seen, it belongs in a page gap which isn't visualized so I couldn't check the reference.

It's still working here. There are links that lead to chapters 5 and 6 in page vii (Contents), but I cannot copy them:

5 Riemann’s Zeta Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
6 The Great Fusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82

The other day links to more chapters were available though.

(04-20-2015 09:23 PM)Valentin Albillo Wrote:  
(04-20-2015 04:41 PM)Gerson W. Barbosa Wrote:  But I digress. Back to your very short solution, I would like to point out I get your exact result for n = 1, using this series, disregarding the last term: [...] The sixth term doesn't help much for n = 1, [...]

It's an asymptotic series (and thus divergent) so using more terms improves accuracy only up to some point, adding more terms after that actually degrades the precision. This can be seen in your example for x=1, where the first five terms do help while adding yet another one (or more) does not.

You are right! Although the sixth term improves the result for n = 1, albeit only slightly, the seventh term makes it equal 1.00005029507, which is slightly worse than the two previous results. Curve fitting is an option if we want more accurate results for small numbers, as you can see in the (not so small) HP-42S program.

Best regards,

Gerson.


HP-42S program:

Code:

00 { 138-Byte Prgm }
01>LBL "S"
02 ENTER
03 RCL+ ST X
04 LASTX
05 SQRT
06 ×
07 3
08 ÷
09 3
10 RCL× ST Y
11 RCL÷ ST Z
12 4
13 ÷
14 STO+ ST Y
15 12
16 ÷
17 RCL÷ ST Z
18 STO+ ST Y
19 80
20 ÷
21 RCL÷ ST Z
22 RCL÷ ST Z
23 STO- ST Y
24 24
25 ÷
26 5
27 ×
28 RCL÷ ST Z
29 RCL÷ ST Z
30 +
31 2.07886224977E-1
32 -
33 X<>Y
34 LN
35 -8.03012316627
36 ×
37 1.19449787182
38 RCL÷ ST T
39 -
40 9.07189622971
41 -
42 E^X
43 LN1+X
44 1
45 +
46 ÷
47 .END.

Examples:

1 .... 1.............(.....1....)
2 .... 2.41421356235 (.....6237 )
3 .... 4.14626436995 (.....6994 )
4 .... 6.14626436989 (.....6994 )
5 .... 8.38233234743 (.....4744 )
10.... 22.4682781862 (.....1862 )
100... 671.462947104 (.....7103 )
1.E12. 6.66666666668E17 (....67 )
1.E333 2.10818510678E499 (...78 )


a := 2*n*sqrt(n)/3
b := 3*a/(4*n)
c := b/(12*n)
d := c/(80*n^2)
e := 5*d/(24*n^2)
s := (a + b + c - d + e - 0.207886224977355)/(1 + ln(1 + exp(-8.03012316626854*ln(n) - 9.07189622971032 - 1.19449787181792/n)))



P.S.: On the HP-71B, this hardly fits in two lines:

Code:

1 INPUTN@A=2*N*SQR(N)/3@B=3*A/4/N@C=B/12/N@D=C/80/N/N@E=5*D/24/N/N@S=A+B+C-D+E
2 (S-.207886224977)/(1+LOGP1(EXP(-8.03012316627*LN(N)-9.07189622971-1.19449787182/N)))

? 1
1
? 2
2.41421356235
? 3
4.14626436995
? 4
6.14626436989
? 5
8.38233234743
? 10
22.4682781862
? 100
671.462947104
? 1E12
6.66666666668E17
? 1E333
WRN L1:Underflow
WRN L2:Underflow
2.10818510678E499


P.P.S.: The constant 9.07189622971 in step 40 of the the HP-42S program and in line 2 of the HP-71B program has how been corrected. Previously the second '9' was missing: 9.0718622971. As a result, both programs now return 1 exactly for n = 1. I ought to have noticed 0.99999999882 was way off!
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: One-liner mini-challenge [HP-71B] - Gerson W. Barbosa - 04-22-2015 10:57 PM



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