[racket] Floating-point

From: Neil Toronto (neil.toronto at gmail.com)
Date: Mon Oct 14 13:39:35 EDT 2013

On 10/14/2013 12:15 AM, Konrad Hinsen wrote:
> Neil Toronto writes:
>
>   > > So how about Racket? Can a programmer rely on a given program producing
>   > > the exact same result on all platforms, and with any Racket version?
>   >
>   > In almost everything, PLT and Racket prioritize correctness over speed.
>
> That sounds interesting. Why doesn't the Racket marketing department
> do more advertising for this? It's pretty hard to find a language that
> is both usable in real life and aims for correctness in float
> operations.

What marketing department? :D

I'm planning to demo some of this stuff at Strange Loop next year.

>   > If you want to test Racket's compliance on your system, run this:
>   >
>   >    #lang racket
>   >    (require math/utils)
>   >    (test-floating-point 10000)
>   >
>   > If it returns '(), your system is either compliant or close to it.
>
> The bad news is that MacOS X is not very compliant. I get a list that's
> far from empty:
>
> '(((flexpt -1.4916681462400412e-154 -1.0) 1.0)
>    ((flexpt 1.4916681462400412e-154 -1.0) 1.0)
>    ((flexpt -1.3407807929942596e+154 -1.0) 1.0)
>    ((flexpt 1.3407807929942596e+154 -1.0) 1.0)
>    ((flsin -10.0) 1.0)
>    ((flsin 10.0) 1.0)
>    ...
>    ((flatan 10.0) 1.0)
>    ((fl2log 8.537625565374698e+146 -4.512338244767214e+130) 17179869183.907547)
>    ((fl2log1p 2.0398056943905264e+255 5.292226095768373e+238)
>     549755813887.9563))
>
> It's always an error of 1.0 ulps, except for logarithms where the
> error is much more important.

Those are double-double (~105-bit) log functions. If you didn't see 
anything that looked like ((fllog x) e) where e > 1.0, your system's 
floating-point log is probably okay.

Do you get `fl2log' and `fl2log1p' errors like that with the JIT turned 
off? Are you running on HEAD? Matthew recently fixed a JIT error that 
was making `beta-inc' randomly fail; this could be another manifestation.

If it's not the JIT, can you zip and send to me (off-list) the output 
for (test-floating-point 50000)? I'd like to try to spot some trends.

Neil ⊥


Posted on the users mailing list.