Accurate Bernoulli numbers on the 41C, or "how close can you get"?

03212014, 01:37 PM
(This post was last modified: 03212014 06:33 PM by Dieter.)
Post: #26




RE: Accurate Bernoulli numbers on the 41C, or "how close can you get"?
(03212014 05:54 AM)Ángel Martin Wrote: Using MCODE the advantage is obvious, as the coefficients are sort of precompiled. Rational approximations allow simpler operations (basically sum and multiplication), which avoids slower routines even in MCODE. It's also nice to have the same execution time for all arguments. Yes, that's why I like these methods in Pascal and VB. Over the years I have been using customdesigned rational approximations for various applications. BTW this does not require Maple or Mathematica, it can also be done with standard software like Excel. I really like polynomial/rational approximations  but less so in a usercode program. That's why I suggested the idea of a very simple "first guess" rational approximation with subsequent refinement. (03212014 05:54 AM)Ángel Martin Wrote: How does your method hold up in the vicinity of one? That's where the CUDA approach really surpasses any other approximation I tried in the past. There generally is no problem near one if you use the obvious solution: In all the methods I use for the Normal quantile, only the lower half (p<0,5) is considered and the other half is simply evaluated as QF(1p). Easy as that. ;) That's why the results for p close to 1 are as accurate as those for 1p. QF(0,9) = 1,281551566 QF(0,99) = 2,236347874 QF(0,999) = 3,090232306 QF(0,9999) = 3,719016485 QF(0,99999) = 4,264890794 QF(0,999999) = 4,753424309 QF(0,9999999) = 5,199337582 QF(0,99999999) = 5,612001244 QF(0,999999999) = 5,997807015 QF(0,9999999999) = 6,361340902 All these are exact. Which of course does not mean that the 10digit FOCAL routine might not have errors in the last place here and there. In general, it simply does not matter whether QF(0,99999) or QF(0,00001) is calculated. If it was possible to enter 1  1E99 the algorithm would handle this just as well. ;) So the idea is: IF p < 0,5 THEN return QF(p) ELSE return QF(1p) (03212014 05:54 AM)Ángel Martin Wrote: Unfortunately I only used 10 digits to implement the doubleprecision expression (ran out of ROM space), but even then it returns decent results. The FOCAL program I mentioned (initial guess + 1 correction step) is mostly within 1 or 2 ULP, even with just 10 digits working precision. The only exception I noticed are results between 0,7 and 1 which may be off by 5 or 6 ULP. That's because at this point the CDF that's used in the correction step would require 1112 digits for an exact quantile. The FOCAL program using two rational approximations should be within 2 ULP over the whole range. But I did not do any thorough tests. (03212014 05:54 AM)Ángel Martin Wrote: BTW, V41 is not good for benchmarking execution speed  even using default settings it's still a function of the PC's CPU. I'm using an oldreliable XP machine, 9years old so likely slower than yours ;) I wouldn't bet on it. The device I'm writing this on shows a BIOS date in late 2002 when powering up. ;) With standard settings, V41 is about twice as fast as my "real" HP41. Due to the TIME function in V41 the FOCAL program using a rational approximation runs in 2,67 seconds. Dieter 

« Next Oldest  Next Newest »

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