|Programming Challenge: Powers and Roots|
Message #1 Posted by Patrick on 19 Mar 2003, 3:05 p.m.
Through the evil of eBay, I recently managed to pick up a pristine copy of the HP-15C Advanced Functions Handbook. I've only had a half hour or so to read it so far, but it appears to be quite excellent.
One of the interesting numerical oddities that they point out surrounds the function obtained by taking the square root of a number 50 times and then taking the square or the result 50 times. While mathematically you should end up with the identity function (f(x) = x, for x >= 0), numerically you end up with something quite different.
The little challenge that I propose is to write the shortest program to compute the function described. You may only use square roots, squares and arithmetic functions. No y^x, no log/ln, no e^x, etc.
In order to make the problem non-trivial, I impose the additional constraint that you may not use any conditional tests, such as [x=0?], [ISG], [DSE], or [F?].
A secondary question is how large the number 50 can be increased to on your selected platform using only these self same functions.
Since I only know RPN, not RPL, I'd be primarily interested in seeing the solution done using the former method. I suggest the HP-11C and HP-15C as the platforms to use since I happen to like them the best, but others would work equally well.