Happy Pi Day!
|
03-14-2020, 12:17 PM
(This post was last modified: 06-20-2020 10:53 PM by Gerson W. Barbosa.)
Post: #3
|
|||
|
|||
RE: Happy Pi Day!
314 decimal places might be a more adequate number of places, but it takes 3613 seconds on the HP 50g, or roughly one hour. 100 places takes only 70 seconds, but that's too few digits -- there are people who know those by heart -- so I chose 200, which takes reasonable 10 minutes. Well, reasonable time considering we are using Wallis Product here.
For more digits, you might want to try the algorithm on programming languages that have arbitrary precision extension. Here are 997 digits of pi using Decimal BASIC, which is limited to 1000 digits: Code:
number of digits: 997 n = 748 3.1415926535 8979323846 2643383279 5028841971 6939937510 5820974944 5923078164 0628620899 8628034825 3421170679 8214808651 3282306647 0938446095 5058223172 5359408128 4811174502 8410270193 8521105559 6446229489 5493038196 4428810975 6659334461 2847564823 3786783165 2712019091 4564856692 3460348610 4543266482 1339360726 0249141273 7245870066 0631558817 4881520920 9628292540 9171536436 7892590360 0113305305 4882046652 1384146951 9415116094 3305727036 5759591953 0921861173 8193261179 3105118548 0744623799 6274956735 1885752724 8912279381 8301194912 9833673362 4406566430 8602139494 6395224737 1907021798 6094370277 0539217176 2931767523 8467481846 7669405132 0005681271 4526356082 7785771342 7577896091 7363717872 1468440901 2249534301 4654958537 1050792279 6892589235 4201995611 2129021960 8640344181 5981362977 4771309960 5187072113 4999999837 2978049951 0597317328 1609631859 5024459455 3469083026 4252230825 3344685035 2619311881 7101000313 7838752886 5875332083 8142061717 7669147303 5982534904 2875546873 1159562863 8823537875 9375195778 1857780532 1712268066 1300192787 6611195909 2164201 Runtime: .47 seconds Edited to fix a typo PS: Some algorithm and program optimizations ----------------------------------- HP 50g: 314 %%HP: T(3)A(R)F(.); \<< PUSH RAD -105 CF -3 CF 1 DUP PICK3 3 * 8 + 8 IDIV2 DROP DUPDUP + 1 + OVER 8 * 0 \-> m d c \<< FOR i i DUP 16 * 8 - * DUP SQ SWAP DUP 2 - * 3 - / * m 4 - d m 2 c - / + / 'c' STO 'm' 2 STO- NEXT 2 * 1 c - * \>> EXPAND FXND DUP SIZE R\->I ALOG OVER - PICK3 * SWAP IQUOT + \->STR DUP HEAD 0 I\->R \->STR TAIL + SWAP TAIL + 1 ROT 2 + SUB POP \>> TEVAL -> 3.14159265358979323846264338327950288419716939937510 58209749445923078164062862089986280348253421170679 82148086513282306647093844609550582231725359408128 48111745028410270193852110555964462294895493038196 44288109756659334461284756482337867831652712019091 45648566923460348610454326648213393607260249141273 72458700660631 s:3265.5887 (real HP 50g) 337 bytes, CK = # F36Bh ----------------------------------- TurboBCD: Code:
+---+---------------------+---------------------+ | N | 2*W | 2*W*C | +---+---------------------+---------------------+ | 2 | 2.84444444444444444 | 3.14385964912280701 | | 4 | 2.97215419501133786 | 3.14158816337302932 | | 6 | 3.02317019200136082 | 3.14159266276745771 | | 8 | 3.05058999605551092 | 3.14159265357083669 | |10 | 3.06770380664349896 | 3.14159265358983256 | |12 | 3.07940134316788626 | 3.14159265358979314 | |14 | 3.08790206983111306 | 3.14159265358979321 | +---+---------------------+---------------------+ ----------------------------------- Decimal BASIC: Code:
|
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
Happy Pi Day! - Gerson W. Barbosa - 03-14-2020, 02:08 AM
RE: Happy Pi Day! - pinkman - 03-14-2020, 06:19 AM
RE: Happy Pi Day! - Gerson W. Barbosa - 03-14-2020, 02:53 PM
RE: Happy Pi Day! - rprosperi - 03-14-2020, 05:04 PM
RE: Happy Pi Day! - Jim Horn - 03-14-2020, 05:15 PM
RE: Happy Pi Day! - Gerson W. Barbosa - 03-14-2020 12:17 PM
RE: Happy Pi Day! - Dave Britten - 03-14-2020, 12:47 PM
RE: Happy Pi Day! - BruceH - 03-15-2020, 11:32 AM
RE: Happy Pi Day! - Eddie W. Shore - 03-15-2020, 07:29 PM
RE: Happy Pi Day! - DM48 - 12-12-2021, 06:44 PM
RE: Happy Pi Day! - Albert Chan - 12-12-2021, 11:04 PM
RE: Happy Pi Day! - Gerson W. Barbosa - 12-13-2021, 12:41 AM
RE: Happy Pi Day! - DM48 - 12-13-2021, 01:54 AM
RE: Happy Pi Day! - Gil - 12-13-2021, 01:21 AM
RE: Happy Pi Day! - Gerson W. Barbosa - 12-13-2021, 03:57 AM
|
User(s) browsing this thread: 1 Guest(s)