Post Reply 
N-Queens on 50g (RPL language)
11-20-2014, 10:57 PM
Post: #17
RE: N-Queens on 50g (RPL language)
@Han: Using matrices uses more memory, so memory management starts playing a bigger role. I like the FFT, which is a lot of multiplications but it needs a lot of storage as well.

How about this one: Is the sum of the reciprocal of triangular numbers, which very slowly converges to 2.
The slow convergence is good so we can do thousands of operations without going out of range.
\[ \sum { 2 \over n (n+1) } \]
Here's the code:
Code:

<< 0. 10000. 1. FOR n
   2 n DUP 1. + * / +
   -1 STEP
>>

It has one multiplication, one division and two additions at each step. I chose 10000 terms quite arbitrarily. The last term is in the order 1e-6, so it is still significant even with the 12-digit precision. It takes about 87 seconds on the 50g, so it can be measured comfortably.
Notice that the loop runs backwards, so there's less loss of significant digits.

One drawback I see is that the multiplication is always between two integers...

Any objections or other proposals?
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: N-Queens on 50g (RPL language) - Han - 11-06-2014, 03:29 AM
RE: N-Queens on 50g (RPL language) - Bruno - 09-08-2015, 10:41 AM
RE: N-Queens on 50g (RPL language) - Han - 11-20-2014, 08:53 AM
RE: N-Queens on 50g (RPL language) - Claudio L. - 11-20-2014 10:57 PM



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