gcl-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gcl-devel] Re: [Maxima] eps in trigi.lisp


From: Camm Maguire
Subject: Re: [Gcl-devel] Re: [Maxima] eps in trigi.lisp
Date: 16 Oct 2002 21:40:15 -0400

I've taken a crack at this and now have the following:

#ifdef IEEEFLOAT
 { 
   double div,td;
   float ts;
   for (float_epsilon=1.0,div=0.5;(float)div!=1.0;div=1.0-(0.5*(1.0-div)))
     for 
(ts=float_epsilon;FMEM(ts),!SF_EQL((float)(1.0+ts),(float)1.0);float_epsilon=ts,ts*=div);

   for 
(float_negative_epsilon=1.0,div=0.5;(float)div!=1.0;div=1.0-(0.5*(1.0-div)))
     for 
(ts=float_negative_epsilon;FMEM(ts),!SF_EQL((float)(1.0-ts),(float)1.0);float_negative_epsilon=ts,ts*=div);

   for (double_epsilon=1.0,div=0.5;(double)div!=1.0;div=1.0-(0.5*(1.0-div)))
     for 
(td=double_epsilon;FMEM(td),!LF_EQL((double)(1.0+td),(double)1.0);double_epsilon=td,td*=div);

   for 
(double_negative_epsilon=1.0,div=0.5;(double)div!=1.0;div=1.0-(0.5*(1.0-div)))
     for 
(td=double_negative_epsilon;FMEM(td),!LF_EQL((double)(1.0-td),(double)1.0);double_negative_epsilon=td,td*=div);

 }
#else


>short-float-epsilon

5.960465S-8

>short-float-negative-epsilon

2.980233S-8

>double-float-negative-epsilon

5.5538256285569977E-17

>double-float-epsilon

1.1107651257113995E-16

>(* 1.05 double-float-epsilon)

1.1663033819969697E-16

>(by)


Is this acceptable?

Take care,


Camm Maguire <address@hidden> writes:

> Greetings!  OK the epsilon code still appears a bit non-standard.  The
> other constants (least-positive, ...) should have been fixed some time
> ago.   I'll try to take a look at this, but I thought I'd post what
> gcl does now in case anyone has suggestions for a better approach:
> 
> =============================================================================
> /* We want the smallest number not satisfying something,
>    and so we go quickly down, and then back up.  We have
>    to use a function call for test, since in line code may keep
>    too much precision, while the usual lisp eql,is not
>    in line.
>    We use SMALL as a multiple to come back up by.
>    We use FMEM(double_negative_epsilon)
>    to force the quantity into memory by taking its address
>    and then passing it to a function.
> */
> 
> #define SMALL 1.05    
>       for (float_epsilon = 1.0;
>            FMEM(float_epsilon),!SF_EQL((float)(1.0 + 
> float_epsilon),(float)1.0);
>            float_epsilon /= 2.0)
>               ;
>       while(SF_EQL((float)(1.0 + float_epsilon),(float)1.0))
>         { FMEM(float_epsilon); float_epsilon=float_epsilon*SMALL;}
>       for (float_negative_epsilon = 1.0;
>           FMEM(float_negative_epsilon), !SF_EQL((float)(1.0 - 
> float_negative_epsilon) ,(float)1.0);
>            float_negative_epsilon /= 2.0)
>               ;
>       while(SF_EQL((float)(1.0 - float_negative_epsilon) ,(float)1.0))
>         float_negative_epsilon=float_negative_epsilon*SMALL;
>       for (double_epsilon = 1.0;
>            FMEM(double_epsilon), !(LF_EQL(1.0 + double_epsilon, 1.0));
>            double_epsilon /= 2.0)
>               ;
>       while((LF_EQL(1.0 + double_epsilon, 1.0)))
>         double_epsilon=double_epsilon*SMALL;
>         ;
>       for (double_negative_epsilon = 1.0;
>          FMEM(double_negative_epsilon),
>              !LF_EQL(1.0 - double_negative_epsilon , 1.0);
>            double_negative_epsilon /= 2.0)
>               ;
>       while(LF_EQL(1.0 - double_negative_epsilon , 1.0))
>         double_negative_epsilon=double_negative_epsilon*SMALL;
>         ;
>       
> =============================================================================
> 
> "Stavros Macrakis" <address@hidden> writes:
> 
> > > long-float-epsilon  value: 1.1102230246251568d-16
> > 
> > Peculiarly, in Maxima 5.5, gcl 2-3.6, Windows 2000, long-float-epsilon
> > is set to 1.1657341758564144E-16, approximately 5% too large; similarly
> > for long-float-negative-epsilon.  Probably doesn't matter to many
> > people, but....
> > 
> > By the way, Camm and James, what is the correct way to submit bug
> > reports for gcl?
> 
> As James said so well, either address@hidden or
> http://savannah.gnu.org/projects/gcl.  
> 
> Take care,
> 
> 
> > 
> >       -s
> > 
> > 
> > (setq *print-base* (+ 8 8))
> > 
> > (integer-decode-float long-float-epsilon)
> > 10CCCCCCCCCCCD
> > -69
> > 1
> > 
> > (setq lfe 1.1102230246251568d-16)
> > (+ 1 lfe -1) => 2.22E-16
> > (integer-decode-float lfe)
> > 10000000000001
> > -69
> > 1
> > 
> > (integer-decode-float long-float-negative-epsilon)
> > 10CCCCCCCCCCCD
> > -6A
> > 1
> > 
> > (+ 1 (* (- long-float-negative-epsilon) .96))
> > 0.99999999999999989
> > 
> >   So LFNE is not the smallest.
> > 
> > 
> > 
> 
> -- 
> Camm Maguire                                          address@hidden
> ==========================================================================
> "The earth is but one country, and mankind its citizens."  --  Baha'u'llah
> 
> 
> _______________________________________________
> Gcl-devel mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/gcl-devel
> 
> 

-- 
Camm Maguire                                            address@hidden
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah




reply via email to

[Prev in Thread] Current Thread [Next in Thread]