Post Reply 
Monte-Carlo Pi
01-14-2022, 08:31 PM
Post: #17
RE: Monte-Carlo Pi
(01-14-2022 09:03 AM)Ángel Martin Wrote:  ... and here's the HP-41 version of Valentín's brilliant HP-71 code. It uses SEED and RNDM, both functions from the AMC_OS/X module

Just enter the number of points and press R/S.
Obviously very slow on a real HP-41, but very reasonable using V41 in Turbo mode.

Code:
01  LBL "MCPI"
02  STO 00
03  0
04  SEED
05  FIX 0
06  LBL 00
07  RNDM
08  RNDM
09  /
10  RND
11  2
12  MOD
13  -
14  DSE  Y
15  GTO 00
16  FIX 9
17  RCL 00
18  /
19  -4
20  *
21  1
22  +
23  END

The AMCOSX module is missing in i41CX+ here (probably accidentally deleted), but it runs on Free42:

Code:


00 { 41-Byte Prgm }
01▸LBL "MCPI"
02 STO 00
03 1
04 SEED
05 FIX 00
06▸LBL 00
07 RAN
08 RAN
09 ÷
10 RND
11 2
12 MOD
13 -
14 DSE ST Y
15 GTO 00
16 FIX 09
17 RCL 00
18 ÷
19 -4
20 ×
21 1
22 +
23 END

145000 XEQ "MCPI" -> 3.141627586 ( ~ 2 seconds)

BTW, here’s an alternative to Valentin’s “faster, very precise, approximate way” (to get pi). Something more accurate than Free42 might be necessary to verify it is not exactly pi, though:

ln(((4001-1/(8002–1/(4001^2+(24006-5/8002-1)/4)))/5)^6-24)/sqrt(163)

where all the constants greater than 163 are 4001 or multiples thereof.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Monte-Carlo Pi - Ángel Martin - 01-11-2022, 11:37 AM
RE: Monte-Carlo Pi - Albert Chan - 01-11-2022, 12:19 PM
RE: Monte-Carlo Pi - Andres - 01-11-2022, 12:51 PM
RE: Monte-Carlo Pi - J-F Garnier - 01-11-2022, 01:11 PM
RE: Monte-Carlo Pi - Gerson W. Barbosa - 01-19-2022, 09:07 PM
RE: Monte-Carlo Pi - Ángel Martin - 01-29-2022, 10:37 AM
RE: Monte-Carlo Pi - Gerson W. Barbosa - 01-29-2022, 02:58 PM
RE: Monte-Carlo Pi - KeithB - 01-11-2022, 02:12 PM
RE: Monte-Carlo Pi - ttw - 01-12-2022, 10:18 AM
RE: Monte-Carlo Pi - Dave Shaffer - 01-13-2022, 03:30 AM
RE: Monte-Carlo Pi - Csaba Tizedes - 01-11-2022, 05:40 PM
RE: Monte-Carlo Pi - C.Ret - 01-12-2022, 05:33 PM
RE: Monte-Carlo Pi - Ángel Martin - 01-12-2022, 01:50 PM
RE: Monte-Carlo Pi - ttw - 01-13-2022, 01:04 AM
RE: Monte-Carlo Pi - C.Ret - 01-13-2022, 06:14 PM
RE: Monte-Carlo Pi - KeithB - 01-13-2022, 01:58 PM
RE: Monte-Carlo Pi - Gerson W. Barbosa - 01-13-2022, 10:10 PM
RE: Monte-Carlo Pi - Ángel Martin - 01-14-2022, 09:03 AM
RE: Monte-Carlo Pi - C.Ret - 01-14-2022, 05:53 PM
RE: Monte-Carlo Pi - Gerson W. Barbosa - 01-14-2022 08:31 PM
RE: Monte-Carlo Pi - Joe Horn - 01-15-2022, 05:52 AM



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