Summation on HP 42S
|
09-26-2018, 10:10 AM
Post: #27
|
|||
|
|||
RE: Summation on HP 42S
(09-25-2018 04:47 PM)Dieter Wrote: Simple. Add the (base 10) logs of 1...1000. The integer part of the sum is the tens exponent, 10^(fractional part) is the mantissa. Your program is really elegant as it uses the Y-register for the calculation of the logarithm as well as for decrementing n and counting in one pass. Mine is a bit more clumsy as it uses the X-register for this purpose. The summation of the logarithm is then achieved through stack shifting and the use of LASTX. Code: 01 LBL "FC2" I wouldn't have made the effort to list the code if it was not for the timing of the programs. Interestingly, my code takes for 1000! about 90 seconds while the more elegant code takes about 8 seconds longer in a real HP42S. The result is (real HP42S) 4.02387322958 10^2567 for both codes. That is precise to the 5th decimal place. By using the natural logarithm (LN) instead of the decadic (LOG) the precision is increased by 1 decimal place. Cheers! Frido |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)