On Fri, Feb 24, 2017 at 1:40 AM, Juraj Sukop <juraj.su...@gmail.com> wrote:
> > > On Fri, Feb 24, 2017 at 5:01 AM, Chris Barker <chris.bar...@noaa.gov> > wrote: > >> cause if your computation was that perfect, why not just check for zero? >> >> > A polynomial root may simply be not representable in double precision > floating-point format. > Indeed. > Per the example I posted above, the best one can hope for in such > situation is to find (x, nextafter(x, float('inf'))) interval which has > opposite function value signs. > I'm not much of a numerical analyst, but I think the number of applications in which the computation is accurate to the limit of float precision is vanishingly small -- so you need something larger than the smallest representable non-zero value anyway. Also many time when one is looking for a "zero", you are really looking for the difference between two values to be zero -- in which case isclose() is the right tool for the job. Thus this kind of thing is useful primarily for "exploring the behaviour of numerical algorithm implementations" as Nick said. Which doesn't mean it wouldn't' be useful to have in Python. Someone said: " it's very much tied to whatever float type Python happens to use on a platform." Which is the whole point -- if one could assume that Python is using IEEE 754 64 bit floats, then you could write these functions yourself but it's built-in then the implementation can make sure it's correct for the platform/etc that you are currently running on. By the way, it looks like math doesn't have machine epsilon either: https://en.wikipedia.org/wiki/Machine_epsilon which would be handy as well. -CHB -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception chris.bar...@noaa.gov
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/