(50G) PDQ Algorithm in SRPL and URPL
|
05-04-2015, 04:48 PM
(This post was last modified: 06-15-2017 01:40 PM by Gene.)
Post: #1
|
|||
|
|||
(50G) PDQ Algorithm in SRPL and URPL
PDQ Algorithm in HP 50g System RPL and User RPL, by Joe Horn
Here are two HP 50g versions of the "PDQ Algorithm", fully described HERE. The first version is in System RPL (more or less), and the second is 100% User RPL. They are identical in operation except for speed: the System RPL version is roughly twice as fast as the User RPL version. Example: 5. √ 2 PDQ --> 29/13 SRPL version: 0.37 seconds URPL version: 0.78 seconds Differences from the Prime version linked above: (1) Inputs: Stack level 2: Number to be approximated (as a real decimal, integer ratio, or string). Stack level 1: Tolerance (as a real decimal, or integer ratio). Allowing the inputs to be in the form of integer ratios or strings is what lets the user tap the "infinite precision" of the algorithm (see examples below). (2) Outputs: Stack level 2: Exact best fraction Stack level 1: Exact error (tagged "N" or "X") "N" means "Normal" (principal) convergent "X" means "eXtra" (intermediate) convergent Examples: 3.14159265359 7 PDQ --> 75948/24175, X:-9602153/96700000000000 What this means: The input means, "What is the simplest fraction within ±1/10^7 of 3.14159265359?" The answer is 75948/24175, which is an intermediate convergent of the input (that's what the "X" indicates). The answer differs from the input by exactly -9602153/96700000000000. '31415926535897932384626/10000000000000000000000' '1/800' PDQ --> 179/57, X:exact error (ratio of two large integers) "3.1415926535897932384626" .00125 PDQ --> same as previous example (3) 'ic' and 'err' global variables are not created. (4) Since the 50g uses 12-digit BCD, and Prime's CAS uses 48-bit binary floating point, real inputs on both machines will usually be slightly different, which can cause PDQ's results to differ on both machines. When their inputs are actually identical (e.g. when they are exact ratios of integers), PDQ's results will also be identical on both machines. PDQ in System RPL BYTES (when assembled): 852. #A4ABh Code: %%HP: T(3)A(R)F(.); PDQ in User RPL BYTES: 818.5 #7596h Code: %%HP: T(3)A(R)F(.); <0|ɸ|0> -Joe- |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
(50G) PDQ Algorithm in SRPL and URPL - Joe Horn - 05-04-2015 04:48 PM
RE: (50g) PDQ Algorithm in SRPL and URPL - brickviking - 08-26-2015, 09:19 PM
RE: (50g) PDQ Algorithm in SRPL and URPL - rprosperi - 08-27-2015, 12:13 AM
RE: (50g) PDQ Algorithm in SRPL and URPL - brickviking - 08-27-2015, 05:14 AM
RE: (50g) PDQ Algorithm in SRPL and URPL - Gerald H - 08-27-2015, 05:19 AM
RE: (50g) PDQ Algorithm in SRPL and URPL - Joe Horn - 08-27-2015, 01:57 PM
RE: (50g) PDQ Algorithm in SRPL and URPL - Gerald H - 08-27-2015, 04:24 PM
RE: (50g) PDQ Algorithm in SRPL and URPL - Han - 09-11-2015, 06:08 PM
RE: (50g) PDQ Algorithm in SRPL and URPL - Joe Horn - 09-12-2015, 03:58 AM
RE: (50g) PDQ Algorithm in SRPL and URPL - Gerald H - 09-12-2015, 04:59 AM
RE: (50G) PDQ Algorithm in SRPL and URPL - cdmackay - 02-23-2019, 09:09 PM
RE: (50G) PDQ Algorithm in SRPL and URPL - Joe Horn - 02-24-2019, 07:54 AM
RE: (50G) PDQ Algorithm in SRPL and URPL - cdmackay - 02-24-2019, 05:19 PM
|
User(s) browsing this thread: 3 Guest(s)