[racket] Am I Missing Something? [HtDP 31.3.1]

From: Richard Cleis (rcleis at mac.com)
Date: Tue Jan 4 16:22:59 EST 2011

I wonder if it has something to do with the rounding switches in fenv.h.  For example, the last elements are:

 -6.137094160310568e-05
 -6.13709416031052e-05

The precision is different, and if the higher precision representation is rounded to the lower one, the 15th digit differs by 5.

rac

On Jan 4, 2011, at 2:04 PM, David Van Horn wrote:

> On 1/4/11 3:55 PM, Richard Cleis wrote:
>> Can you post the first few dozen elements of g-series?
> 
> Ubuntu (Luke's behavior):
> 
> Welcome to Racket v5.0.2.
> > (define (g-series n)
>    (if (zero? n)
>        empty
>        (cons (expt -0.99 n) (g-series (sub1 n)))))
> > (take (g-series #i1000) 36)
> (4.317124741065751e-05
> -4.360732061682577e-05
> 4.404779860285432e-05
> -4.449272586146901e-05
> 4.4942147334817175e-05
> -4.539610841900725e-05
> 4.5854654968694194e-05
> -4.631783330171131e-05
> 4.6785690203748796e-05
> -4.7258272933079593e-05
> 4.773562922533292e-05
> -4.8217807298316076e-05
> 4.8704855856884935e-05
> -4.9196824097863566e-05
> 4.969376171501371e-05
> -5.019571890405425e-05
> 5.0702746367731566e-05
> -5.1214895320940976e-05
> 5.173221749589997e-05
> -5.2254765147373715e-05
> 5.278259105795324e-05
> -5.331574854338711e-05
> 5.3854291457966793e-05
> -5.439827419996645e-05
> 5.494775171713783e-05
> -5.550277951226043e-05
> 5.606341364874792e-05
> -5.662971075631102e-05
> 5.7201728036677816e-05
> -5.777952326937152e-05
> 5.836315481754699e-05
> -5.895268163388586e-05
> 5.954816326655136e-05
> -6.014965986520341e-05
> 6.075723218707414e-05
> -6.13709416031052e-05)
> 
> My mac (expected behavior):
> 
> [Q: Is this a PPC?  A: Nope.]
> 
> Welcome to Racket v5.0.2.
> > (define (g-series n)
>    (if (zero? n)
>        empty
>        (cons (expt #e-0.99 n) (g-series (sub1 n)))))
> > (take (g-series #i1000) 36)
> '(4.317124741065786e-05
>  -4.360732061682612e-05
>  4.404779860285467e-05
>  -4.449272586146937e-05
>  4.494214733481754e-05
>  -4.539610841900762e-05
>  4.585465496869457e-05
>  -4.631783330171168e-05
>  4.6785690203749175e-05
>  -4.725827293307997e-05
>  4.773562922533331e-05
>  -4.821780729831647e-05
>  4.870485585688533e-05
>  -4.9196824097863966e-05
>  4.969376171501411e-05
>  -5.019571890405466e-05
>  5.070274636773198e-05
>  -5.121489532094139e-05
>  5.173221749590039e-05
>  -5.2254765147374135e-05
>  5.2782591057953676e-05
>  -5.3315748543387546e-05
>  5.385429145796722e-05
>  -5.4398274199966894e-05
>  5.494775171713828e-05
>  -5.5502779512260884e-05
>  5.606341364874837e-05
>  -5.662971075631149e-05
>  5.720172803667826e-05
>  -5.777952326937199e-05
>  5.8363154817547464e-05
>  -5.8952681633886325e-05
>  5.954816326655184e-05
>  -6.014965986520388e-05
>  6.0757232187074635e-05
>  -6.137094160310568e-05)
> 
> David



Posted on the users mailing list.