lua-users home
lua-l archive

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


It was thus said that the Great Coda Highland once stated:
> On Fri, Nov 17, 2017 at 5:58 AM, Hisham <h@hisham.hm> wrote:
> > 
> > If one were to be true to Lua's original spirit as a scripting
> > language to be used by domain specialists in other fields, this would
> > be an excellent choice. But if we're considering an epsilon in for
> > loops, then I'd also expect the same tolerances to be taken into
> > account in equality comparisons of floating-point numbers.
> >
> > The next question, then, would be "what are good default values for
> > math.abstol and math.reltol"?
>
> Absolute tolerance is numerical bupkis. No constant epsilon could ever
> be meaningful across scales -- an epsilon that gives good behavior on
> loops between 0 and 1 isn't going to give you good behavior on loops
> between 1 and 1,000,000, and if you find a reasonable compromise there
> then that epsilon is going to be unsuitable for a loop between 1e20
> and 1e30.

  Just as an example, what follows are some numbers, followed by the delta
between it and the next largest double:

1.000000000000000000000000000000000000000000000000000000
0.000000000000000222044604925031308084726333618164062500

2.000000000000000000000000000000000000000000000000000000
0.000000000000000444089209850062616169452667236328125000

100.000000000000000000000000000000000000000000000000000000
  0.000000000000014210854715202003717422485351562500000000

10000.000000000000000000000000000000000000000000000000000000
    0.000000000001818989403545856475830078125000000000000000

1000000.000000000000000000000000000000000000000000000000000000
      0.000000000116415321826934814453125000000000000000000000

100000000000000000000.0	(1e20)
                16384.0

  So by the time you are hitting 1e20, your increment needs to be between
1e4 and 1e5 to have any effect ...

  -spc