[Cuis-dev] testing Float results

Mark Volkmann r.mark.volkmann at gmail.com
Tue Jun 4 11:02:20 PDT 2024


For now I only need this functionality in unit tests. I found an assertion
for that. Here is what works for case where the variable `c` refers to a
`VCircle` object from a class I defined:

 self assert: c area isCloseTo: 28.2743339.

On Tue, Jun 4, 2024 at 10:26 AM H. Fernandes via Cuis-dev <
cuis-dev at lists.cuis.st> wrote:

> Would be nice to have within DrGeo, especially when computing locus
>
> Dr. Geo -- http://gnu.org/s/dr-geo
>
> ----- ken.dickey--- via Cuis-dev <cuis-dev at lists.cuis.st> a écrit :
> > On 2024-06-03 16:36, Mark Volkmann via Cuis-dev wrote:
> >
> > > Is there a function that tests whether two Float values are "close"
> > > (within some delta)?
> >
> > Really, it depends on what you expect to use numbers for.
> >
> > Numerical methods using Floats are frequently unstable and "the wrong
> > answer fast".
> >
> > https://people.cs.pitt.edu/~cho/cs1541/current/handouts/goldberg.pdf
> >
> > Various strategies have been devised to make numerical calculations more
> > robust.
> >
> > One simple idea, used in several systems such as Mathematica, is to keep
> > the highest and lowest possible values a function computes and carry the
> > calculation of values throughout a calculation. You then expect the
> > "exact" value to be within this interval.
> >
> > https://en.wikipedia.org/wiki/Interval_arithmetic
> >
> > If the interval is small, you may have a high confidence in a close
> > result. If the "answer" is a humongous interval, you better do the
> > error analysis.
> >
> > An interesting variant of this is Ball Arithmetic, where the answer is
> > not an interval but lives within a (potentially multidimensional)
> > hypersphere.
> >
> > https://www.texmacs.org/joris/ball/ball.html
> >
> > NB: I am not mathematician enough to evaluate Ball Arithmetic.
> >
> > I have used Interval Arithmetic for some cases. Interestingly, there
> > was an Apple function grapher which used Interval Arithmetic to
> > automatically calculate function values to the required precision. This
> > meant that you could look at f(x) = x * sin(x) near zero, and keep
> > "inzooming" to smaller and smaller ranges and still see an accurate
> > graph of this "squiggle function".
> >
> > There are some very interesting discussions about real numbers -- and
> > holes between them -- in Lakoff & Nunez's _Where Mathematics Comes From_
> >
> > HTH,
> > -KenD
> > --
> > Cuis-dev mailing list
> > Cuis-dev at lists.cuis.st
> > https://lists.cuis.st/mailman/listinfo/cuis-dev
>
> --
> Cuis-dev mailing list
> Cuis-dev at lists.cuis.st
> https://lists.cuis.st/mailman/listinfo/cuis-dev
>


-- 
R. Mark Volkmann
Object Computing, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20240604/cb4bccdd/attachment-0001.htm>


More information about the Cuis-dev mailing list