50g User RPL Micro-Challenge: Fraction to a Power
|
10-09-2017, 10:26 AM
Post: #1
|
|||
|
|||
50g User RPL Micro-Challenge: Fraction to a Power
The 50g in exact mode takes a very long time to raise a fraction (ratio of integers) to integer powers. Example: 11/12 to the 115th power:
11/12 115 << ^ EVAL >> takes about 40 seconds to return the exact answer. Micro-Challenge: Generate that same answer in less than 1 second, using only vanilla User RPL (no System RPL or SYSEVALs or FLASHEVALs etc). The fastest program wins. <0|ɸ|0> -Joe- |
|||
10-09-2017, 11:16 AM
(This post was last modified: 10-09-2017 11:17 AM by Gerald H.)
Post: #2
|
|||
|
|||
RE: 50g User RPL Micro-Challenge: Fraction to a Power
My suggestion:
0.2197s Code: « SWAP OBJ→ 5. |
|||
10-09-2017, 11:20 AM
(This post was last modified: 10-09-2017 11:54 AM by Werner.)
Post: #3
|
|||
|
|||
RE: 50g User RPL Micro-Challenge: Fraction to a Power
The date on my IPOW.RPL file reads 2006 ;-)
Edit: but it can't get it done in less than 1 second, so Gerald's idea is the way to go! Werner 41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE |
|||
10-09-2017, 12:15 PM
(This post was last modified: 10-09-2017 02:11 PM by John Keith.)
Post: #4
|
|||
|
|||
RE: 50g User RPL Micro-Challenge: Fraction to a Power
While Gerald H's program is probably unbeatable, I'm guessing this
Code: \<<SWAP OBJ\-> DROP2 UNROT OVER ^ UNROT ^ / \>> is closer to what Joe has in mind, since it takes around 945ms on my HP 50. John |
|||
10-09-2017, 12:46 PM
(This post was last modified: 10-09-2017 12:50 PM by Gerald H.)
Post: #5
|
|||
|
|||
RE: 50g User RPL Micro-Challenge: Fraction to a Power
With John's better stack manipulation:
: .2186 Code: « SWAP OBJ→ 5. |
|||
10-09-2017, 12:48 PM
Post: #6
|
|||
|
|||
RE: 50g User RPL Micro-Challenge: Fraction to a Power
I don't know where the face came from - I entered ":s:" without quotes.
|
|||
10-09-2017, 01:17 PM
Post: #7
|
|||
|
|||
RE: 50g User RPL Micro-Challenge: Fraction to a Power | |||
10-09-2017, 02:34 PM
Post: #8
|
|||
|
|||
RE: 50g User RPL Micro-Challenge: Fraction to a Power
Faster:
:s: .1831 Code: « SWAP COMP→ 5. |
|||
10-09-2017, 02:35 PM
Post: #9
|
|||
|
|||
RE: 50g User RPL Micro-Challenge: Fraction to a Power
Thank you, Gerson, it worked.
|
|||
10-09-2017, 02:46 PM
(This post was last modified: 10-09-2017 02:47 PM by Gerald H.)
Post: #10
|
|||
|
|||
RE: 50g User RPL Micro-Challenge: Fraction to a Power
Faster?
:s: .1825 Code: « SWAP COMP→ 5. |
|||
10-09-2017, 03:22 PM
(This post was last modified: 10-09-2017 03:24 PM by Gilles59.)
Post: #11
|
|||
|
|||
RE: 50g User RPL Micro-Challenge: Fraction to a Power
Code: << SWAP FXND UNROT OVER ^ UNROT ^ / >> 0.9282s Gerald solution is very fast ! (but needs development Library ;D ) I wonder why it s so fast ? |
|||
10-09-2017, 03:30 PM
Post: #12
|
|||
|
|||
RE: 50g User RPL Micro-Challenge: Fraction to a Power
It's the division that's so slow.
|
|||
10-09-2017, 03:34 PM
Post: #13
|
|||
|
|||
RE: 50g User RPL Micro-Challenge: Fraction to a Power
This version is about as fast as my last try:
Code: « SWAP FXND UNROT |
|||
10-09-2017, 03:44 PM
(This post was last modified: 10-09-2017 03:50 PM by Gilles59.)
Post: #14
|
|||
|
|||
RE: 50g User RPL Micro-Challenge: Fraction to a Power | |||
10-09-2017, 06:24 PM
Post: #15
|
|||
|
|||
RE: 50g User RPL Micro-Challenge: Fraction to a Power
Average over 100 runs
.182s Code: « SWAP COMP→ DROP 4 |
|||
10-09-2017, 09:39 PM
Post: #16
|
|||
|
|||
RE: 50g User RPL Micro-Challenge: Fraction to a Power
Replacing ->ALG by EVAL increases the time my program Needs (.2163s) to .9723s.
Arno |
|||
10-09-2017, 10:01 PM
Post: #17
|
|||
|
|||
RE: 50g User RPL Micro-Challenge: Fraction to a Power
(10-09-2017 12:15 PM)John Keith Wrote: While Gerald H's program is probably unbeatable, I'm guessing this I had these two in mind (both contain 8 commands): << SWAP OBJ-> DROP ->LIST SWAP ^ EVAL / >> << SWAP FXND UNROT OVER ^ UNROT ^ / >> ... but both suffer from the division at the end (yes, Gilles, division simplifies fractions, which isn't needed here). That's why Gerald's program is so fast. <0|ɸ|0> -Joe- |
|||
10-09-2017, 10:37 PM
Post: #18
|
|||
|
|||
RE: 50g User RPL Micro-Challenge: Fraction to a Power
(10-09-2017 10:26 AM)Joe Horn Wrote: The 50g in exact mode takes a very long time to raise a fraction (ratio of integers) to integer powers. Example: 11/12 to the 115th power: On my calculator, putting that onto the stack and using this: [RSHIFT] →NUM gives me the answer in less than a second. (Although in saying that, if I hit EVAL instead, that takes a while, and gives me a fraction with really REALLY long numbers.) I don't know if my answer counts as RPL or not. (whistles innocently) (Post 113) Regards, BrickViking HP-50g |Casio fx-9750G+ |Casio fx-9750GII (SH4a) |
|||
10-10-2017, 01:20 AM
Post: #19
|
|||
|
|||
RE: 50g User RPL Micro-Challenge: Fraction to a Power
I tried
<< (11^115)/(12^115) EVAL>> TEVAL which took 2.5 sec. Seems like a lack of optimization in the expression parser. |
|||
10-10-2017, 04:12 AM
Post: #20
|
|||
|
|||
RE: 50g User RPL Micro-Challenge: Fraction to a Power
(10-09-2017 10:37 PM)brickviking Wrote:(10-09-2017 10:26 AM)Joe Horn Wrote: The 50g in exact mode takes a very long time to raise a fraction (ratio of integers) to integer powers. Example: 11/12 to the 115th power: Not the exact answer, which is what was specified. <0|ɸ|0> -Joe- |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)