[racket] Error propagation in `flexpt` [was: [racket-bug] all/14862: extflonum returns a different solution to flonum and mixed-integer calculations]

From: George Neuner (gneuner2 at comcast.net)
Date: Mon Dec 1 21:29:56 EST 2014

On 12/1/2014 6:17 PM, Neil Toronto wrote:
> On 12/01/2014 11:46 AM, Mark Lee wrote:
>>
>> Fascinating stuff, I figured it was an exponentiation issue but wasn't
>> sure because my extfloat implementation provided a different answer from
>> wolframalpha. Does racket switch precision for operations like * by 
>> default?
>>
>> Regards,
>> Mark
>>
>
> I'm not sure how to answer the question. When `*` gets a flonum and an 
> exact rational, it usually downcasts the exact rational to a flonum 
> and then carries out the operation. (The exception is multiplication 
> by exact 0, which returns 0. It's weird but makes sense; blame Scheme.)
>
> It could be that your system's 80-bit `pow` isn't correctly rounded.
> :
> Or it could be that Wolfram Alpha is doing exact real computation.
>
> Neil

It's possible that Wolfram is rounding differently, but it's also 
possible that Wolfram is using SSE and that Mark's extflonum code 
actually is at higher precision that his Wolfram code.

Wolfram does exact arbitrary precision when asked, but the documentation 
states that the default is to use "machine numbers" which, AFAIHS, are 
not further qualified.   Since the introduction of SSE2 (Pentium4), 
unless deliberately told to use the 80-bit FPC, x86 compilers have 
preferred the 64-bit SIMD FPU for general use [ it's data path is faster 
and it uses registers rather than a stack ].  There's no question that 
Wolfram _used_ to use the FPC for floating point, but I have never seen 
any definitive statement that current versions still do.  Most important 
code specifies the desired precision and so does not use the default.

I could be wrong, but it's something else to check.

George


Posted on the users mailing list.