2009/4/27 William D Clinger <[email protected]>: > David Rush wrote: >> > (cos (acos 0)) >> 6.123233995736766e-17 >> >> on Larceny. Now it appears that this is an inescapable feature of the >> C runtime; > > Indeed, it illustrates the inescapable misfeature known as > roundoff error.
Yup. I actually got here by using an exact rational approximation to pi, derived via the Machin formula and accurate to significantly more places than those returned by acos, which produces the same result. I just didn't really think that 266 digits of ratnum was going to make the post any clearer. >> however, given that FLT_MIN on the x86 platform is 1E-37, >> mapping this result to #i0 is somewhat problematic. > > FLT_MIN isn't relevant here Well, the man page on my Debian Etch says that FLT_MIN == DBL_MIN == LDBL_MIN == 1E-37, which seems silly but there you go. In any case, the cos approximation is rather less accurate than any of those minima. >> 2) extract some kind of underlying precision information about the >> Larceny's flonums (and maybe individual operations) > > (system-features) will give you that information. Currently, > however, all supported varieties of Larceny use IEEE double > precision on all supported architectures. That's a nice feature. It would be nice to have it include a flonum-epsilon entry or something similar so that programs could avoid building a mechanism to convert the symbolic information into computable data. > Perhaps you will feel better about this once you realize that > C programs experience the same kinds of roundoff error. Naah, I figured that part out already. What I'm really looking for is a way to minimize the roundoff error in trig functions (so I can actually find the zeros). It's looking like reducing all trig evaluations to the +x+y quadrant and using symmetry to return to the actual value might be the best answer. _Numerical Recipes_ also recommends using a mutant recurrence relation for iterating sines and cosines over equally spaced angular samples, and I'm thinking of trying that. david rush -- GPG Public key at http://cyber-rush.org/drr/gpg-public-key.txt _______________________________________________ Larceny-users mailing list [email protected] https://lists.ccs.neu.edu/bin/listinfo/larceny-users
