[Python-ideas] math.nextafter
Juraj Sukop
juraj.sukop at gmail.com
Mon Feb 6 08:42:09 EST 2017
Do you mean something like:
isclose(f(x), 0.0, rel_tol, abs_tol)
If so, what should `rel_tol` and `abs_tol` be?
On Mon, Feb 6, 2017 at 2:16 PM, M.-A. Lemburg <mal at egenix.com> wrote:
> On 06.02.2017 13:22, Juraj Sukop wrote:
> > On Mon, Feb 6, 2017 at 11:29 AM, M.-A. Lemburg <mal at egenix.com> wrote:
> >
> >>
> >> Juraj: Could you provide some use cases, where such a function
> >> would help in Python applications ? (I can see use cases
> >> written in C, but due to the low level, find it hard to
> >> believe that people would use this at the Python level)
> >>
> >
> > In my case, `nextafter` would be used to check if a number is close to
> > polynomial zero, e.g.:
> >
> > def f(x):
> > return 2.0*x**3 - 3.0*x**2 + 5.0*x - 7.0
> >
> > # x = 1.4455284586795218
> > x = 1.445528458679522
> > # x = 1.4455284586795223
> > # x = 1.4455284586795225
> >
> > left = nextafter(x, -float('inf'))
> > right = nextafter(x, float('inf'))
> >
> > print((f(left) < 0.0) != (f(x) < 0.0) or (f(x) < 0.0) != (f(right) <
> > 0.0))
>
> Isn't this something you can do with math.isclose() ?
>
> This would even give you a predefined error range,
> not a dynamic one.
>
> --
> Marc-Andre Lemburg
> eGenix.com
>
> Professional Python Services directly from the Experts (#1, Feb 06 2017)
> >>> Python Projects, Coaching and Consulting ... http://www.egenix.com/
> >>> Python Database Interfaces ... http://products.egenix.com/
> >>> Plone/Zope Database Interfaces ... http://zope.egenix.com/
> ________________________________________________________________________
>
> ::: We implement business ideas - efficiently in both time and costs :::
>
> eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
> D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
> Registered at Amtsgericht Duesseldorf: HRB 46611
> http://www.egenix.com/company/contact/
> http://www.malemburg.com/
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170206/499f4264/attachment-0001.html>
More information about the Python-ideas
mailing list