[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gcl-devel] Re: [Maxima] eps in trigi.lisp
From: |
Camm Maguire |
Subject: |
[Gcl-devel] Re: [Maxima] eps in trigi.lisp |
Date: |
15 Oct 2002 23:53:31 -0400 |
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] Re: [Maxima] eps in trigi.lisp,
Camm Maguire <=