Post Reply 
[VA] SRC #016 - Pi Day 2024 Special
03-24-2024, 02:54 PM
Post: #29
RE: [VA] SRC #016 - Pi Day 2024 Special
I was curious to see the impact of digit counts with Appearance 6, so I put together two separate RPL versions to check it. These were then run on an emulated 50g for testing.

The first uses built-in (standard) RPL commands to compute a 50-character hex string result:

«
  ""                                    @ hex string initial result
  0.                                    @ x0
  1. 50. FOR x                          @ loop x for 50 hex digits
    16. *                               @ 16x(n-1)
    [120 -89 16] x PEVAL                @ numerator polynomial evaluated
    [512 -1024 712 -206 21] x PEVAL     @ denominator polynomial evaluated
    / +                                 @ compute fraction, accumulate value
    FP                                  @ we only need the fractional part
    
    DUP                                 @ leave a copy of x(n) for next pass
    16. * IP                            @ IP(16x)                                                       
    10. OVER >                          @ convert digit value to ascii character
    48. 55. IFTE
    + CHR
    
    ROT SWAP + SWAP                     @ append character to hex string
  NEXT
  DROP                                  @ x no longer needed
»



This provided the following result, yielding 9 accurate digits:
243F6A8882 396F57BAB5...

RPL has no built-in multi-precision utilities for floating-point calculations, so I opted to use the LongFloat library to see what kind of impact the digit count had on the final result:

\<<
  ""
  0. R\<-\->F
  1. 50. FOR x
    16. R\<-\->F FMULT
    '(120*x^2-89*x+16)/(512*x^4-1024*x^3+712*x^2-206*x+21)' \->FNUM
    FADD FFP
    DUP
    R\<-\->F 16. * IP
    10. OVER >
    48. 55. IFTE
    + CHR ROT SWAP + SWAP
  NEXT
  DROP
\>>


Repeated runs with increasing numbers of multiple-precision digits showed improvements, as expected:

MP Digit Count    Hex string matching digits
--------------    --------------------------
12                9
25                20
34                26
40                32
50                40
60                49
62                50

I'm curious as to how the MP digit count compares with other implementations (Python, Lua, etc.). Has anyone else tried this?
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: [VA] SRC #016 - Pi Day 2024 Special - DavidM - 03-24-2024 02:54 PM



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