[racket-dev] plot doesn't plot (inexact->exact: no exact representation for +nan.0)

From: Neil Toronto (neil.toronto at gmail.com)
Date: Wed Dec 7 13:46:26 EST 2011

I just pushed a change that should keep it from raising an error. Can 
you get the latest and try it? If there's no error, will you please send 
me (personally, not the list) a screenshot of the result?

Could you also try this?

#lang racket
(require plot racket/flonum unstable/flonum)
(plot (function sqrt 0 (* 40 +min.0)))
(plot (function (compose flsqrt exact->inexact) 0 (* 40 +min.0)))

Both plots should be identical and look like staircases.

The thing is, the error shouldn't be happening at all. As far as I can 
tell, it happens because at least one surface normal of a polygon that 
makes up the plot has a +nan.0 in it.

That *could* happen if your machine's floating-point processor is pretty 
b0rked - for example, if it returned +nan.0 for square roots of very 
small numbers. (Or possibly Racket on your machine, for some reason, 
computes things like that wrongly.) Have you had floating-point problems 
with anything else?

(It's not too unusual, BTW. I had a laptop where (exp 20) was wrong in 
the least significant 20 bits.)

Neil T

On 12/06/2011 03:13 AM, Marijn wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> So I just wanted to repost this to dev for the record.
>
> The program:
>
> ;== start
> #lang racket
>
> (require plot)
>
> ;(plot3d-diffuse-light? #f)
> ;(plot3d-specular-light? #f)
>
> (plot3d (list (surface3d (λ (x y) (+ (sqr x) (sqr y))) -1 1 -1 1
>                             #:label "z = x^2 + y^2")
>                  (surface3d (λ (x y) (- (+ (sqr x) (sqr y)))) -1 1 -1 1
>                             #:color 4 #:line-color 4
>                             #:label "z = -x^2 - y^2")))
> ;== end
>
> produces:
>
> inexact->exact: no exact representation for +nan.0
>
> but when the commented lines are uncommented it does plot. The plot
> looks plausible, though apparently it should be possible to drag
> inside the plot area to change the view. This is not possible for me;
> the view is stuck from looking along the xy-plane onto the z-axis.
>
> Matthew has been trying to determine the cause via private email.
> Matthew, has any of the data I provided so far pointed you anywhere?
> Otherwise is there something else I can do to help debug?
>
> Marijn
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.18 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAk7d6uIACgkQp/VmCx0OL2yVAQCdEaRC6AuBfrbUtFBXDJF4uBVh
> lJYAoIfI1nkHSURKjhdNeN4qX13I2vnm
> =NTTc
> -----END PGP SIGNATURE-----



Posted on the dev mailing list.