Post Reply 
Stoneham's series
06-18-2024, 05:42 AM (This post was last modified: 06-18-2024 05:49 AM by Gerson W. Barbosa.)
Post: #20
RE: Stoneham's series
(06-14-2024 05:42 PM)Gerson W. Barbosa Wrote:  P. P. S.: Stack-only, k≥2:

Code:


00 { 70-Byte Prgm }
01▸LBL "VWπ"
02 DSE ST X
03 2
04 0
05 N!
06▸LBL 00
07 2
08 STO× ST Z
09 RCL+ ST L
10 SQRT
11 ×
12 DSE ST Z
13 GTO 00
14 RCL÷ ST Y
15 1/X
16 X<>Y
17 112.5
18 ×
19 X↑2
20 2.1
21 -8
22 Y↑X
23 3
24 -
25 10
26 ÷
27 X↑2
28 X↑2
29 16
30 -
31 X↑2
32 X↑2
33 X<>Y
34 ÷
35 RCL+ ST Y
36 X<>Y
37 END

43 XEQ "VWπ" ->

Y: 3.141592653589793238462643383279500
X: 3.141592653589793238462643316488386


On the HP-42S:

2 XEQ "VWπ" ->

Y: 3.15140913388
X: 2.82842712476


3 XEQ "VWπ" ->

Y: 3.14221296121
X: 3.06146745893


10 XEQ "VWπ" ->

Y: 3.14159265358
X: 3.14158772527


I've finally found the correction factor for the Vieta's formula for \(\pi\) I was looking for, which turns the previous programs obsolete. The correction factor is


\(c = 1 + \frac {1}{\frac{96}{\pi^2 }4^\left(n-1\right)}\)

This simplifies to

\(c = 1 + \frac {\pi^2\times 2^\left(-2n-3\right)}{3}\)

where n is the number of iterations and \(\pi\) is the approximated value obtained at loop exit

The program uses a more compact version of the latter for size-optimization.

Code:

00 { 39-Byte Prgm }
01▸LBL "VWπ"
02 2
03 0
04 SIGN
05▸LBL 00
06 2
07 STO× ST Z
08 RCL+ ST L
09 SQRT
10 ×
11 DSE ST Z
12 GTO 00
13 1/X
14 STO× ST Y
15 X↑2
16 6
17 +
18 RCL÷ ST L
19 RCL× ST Y
20 END


32 XEQ "VWπ" ->

Y: 3.141592653589793238462607815493113
X: 3.141592653589793238462643383279503

Notice that from 22 correct decimal digits the correction factor gets another eleven, a 50 % increase in this case.


On the HP-42S:

1 XEQ "VWπ" ->

Y: 2.82842712475
X: 3.06412938514


2 XEQ "VWπ" ->

Y: 3.06146745894
X: 3.13619104715


3 XEQ "VWπ" ->

Y: 3.12144515227
X: 3.14124564095


4 XEQ "VWπ" ->

Y: 3.13654849054
X: 3.14157081551


5 XEQ "VWπ" ->

Y: 3.14033115695
X: 3.14159128636


9 XEQ "VWπ" ->

Y: 3.14158772526
X: 3.14159265356
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Stoneham's series - ttw - 06-04-2024, 01:31 PM
RE: Stoneham's series - KeithB - 06-04-2024, 02:20 PM
RE: Stoneham's series - Nigel (UK) - 06-04-2024, 03:37 PM
RE: Stoneham's series - Thomas Klemm - 06-04-2024, 03:34 PM
RE: Stoneham's series - Thomas Klemm - 06-04-2024, 07:57 PM
RE: Stoneham's series - Albert Chan - 06-04-2024, 08:44 PM
RE: Stoneham's series - Thomas Klemm - 06-05-2024, 04:20 AM
RE: Stoneham's series - Johnh - 06-07-2024, 07:55 PM
RE: Stoneham's series - Albert Chan - 06-07-2024, 08:54 PM
RE: Stoneham's series - Johnh - 06-08-2024, 03:07 AM
RE: Stoneham's series - Johnh - 06-08-2024, 05:02 AM
RE: Stoneham's series - Albert Chan - 06-08-2024, 05:16 PM
RE: Stoneham's series - Gerson W. Barbosa - 06-09-2024, 10:36 PM
RE: Stoneham's series - Albert Chan - 06-11-2024, 05:12 PM
RE: Stoneham's series - Gerson W. Barbosa - 06-12-2024, 07:01 PM
RE: Stoneham's series - Gerson W. Barbosa - 06-14-2024, 05:42 PM
RE: Stoneham's series - Gerson W. Barbosa - 06-18-2024 05:42 AM
RE: Stoneham's series - Namir - 06-09-2024, 10:55 PM
RE: Stoneham's series - Gerson W. Barbosa - 06-09-2024, 11:04 PM
RE: Stoneham's series - Gerson W. Barbosa - 06-11-2024, 02:31 AM



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