Re: New version of John Hayes' tester
- From: Krishna Myneni <krishnamyneni@xxxxxxxxxxxxx>
- Date: Thu, 16 Aug 2007 05:30:39 -0500
Krishna Myneni wrote:
Anton Ertl wrote:
Concerning the fine-tuning, I meant the REL-NEAR and ABS-NEAR stuff;
with FSENSITIVITY you can do either relative (negative FSENSITIVITY)
or absolute (positive FSENSITIVITY) approximate comparison, but not
both at once. Do you use that?
When a nearness comparison is made, ftester does both absolute nearness
("FABS=") and relative nearness ("FREL=") comparsions in the word "FNEARLY=".
There are two different parameters to specify the absolute and relative
tolerances (sensitivities).
Offhand it seems that one test or the other would be sufficient; however, one
may want to do both tests if the results are being compared against reference
values on a system with unknown fp precision.
Perhaps David has another justification for doing both tests.
In ftester, David comments on the justification for doing both absolute and
relative nearness tests in the word "FNEARLY=". If the two numbers being
compared are very small, their difference may be affected by truncation so that
a valid nearness test is not possible.
The following example may be instructive. Using a negative third argument for
F~, we perform the following relative nearness tests:
1e 1.01e -0.005e F~ . => -1 ( ok )
1e-15 1.01e-15 -0.005e F~ . => -1 ( ok )
1e-318 1.01e-318 -0.005e F~ . => -1 ( ok )
1e-319 1.01e-319 -0.005e F~ . => 0 ( incorrect )
The result for the last case is incorrect due to finite size representation
errors. Using an absolute nearness test, with a matching tolerance, also fails.
1e-319 1.01e-319 0.01005e-319 F~ . => 0 ( ok )
From the above example, it is not clear whether or not doing both types ofnearness tests gains us any more robustness in the test.
A side rant on "F~"
-------------------
The word F~ really is three different words, which are explicitly spelled out in
ftester:
FEXACTLY= ( not the same as F= which gives true when comparing 0e and -0e)
FABS=
FREL=
It may be justified to combine the first two functions into one word, but
combining the latter function into F~ is poor design. The relative
nearness test should have been specified as a separate word in the Forth
language standard. Using the sign of the tolerance to distinguish between
absolute and relative nearness tests is confusing and prone to misuse. For
comparing physical quantities, the tolerance parameter does not even have the
same units for absolute and relative comparisons (in the latter case, the
tolerance is dimensionless).
Krishna
.
- Follow-Ups:
- Re: New version of John Hayes' tester
- From: Anton Ertl
- Re: New version of John Hayes' tester
- From: Marcel Hendrix
- Re: New version of John Hayes' tester
- From: David N. Williams
- Re: New version of John Hayes' tester
- References:
- New version of John Hayes' tester
- From: Anton Ertl
- Re: New version of John Hayes' tester
- From: Krishna Myneni
- Re: New version of John Hayes' tester
- From: Anton Ertl
- Re: New version of John Hayes' tester
- From: Krishna Myneni
- Re: New version of John Hayes' tester
- From: Anton Ertl
- Re: New version of John Hayes' tester
- From: Krishna Myneni
- New version of John Hayes' tester
- Prev by Date: Re: RfD: Number Prefixes
- Next by Date: Re: gforth webserver, why isn't forth used all over ecommerce?
- Previous by thread: Re: New version of John Hayes' tester
- Next by thread: Re: New version of John Hayes' tester
- Index(es):
Relevant Pages
|