<div dir="ltr">Do you mean something like:<div><br></div><div>    isclose(f(x), 0.0, rel_tol, abs_tol)</div><div><br></div><div>If so, what should `rel_tol` and `abs_tol` be?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 6, 2017 at 2:16 PM, M.-A. Lemburg <span dir="ltr"><<a href="mailto:mal@egenix.com" target="_blank">mal@egenix.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 06.02.2017 13:22, Juraj Sukop wrote:<br>
> On Mon, Feb 6, 2017 at 11:29 AM, M.-A. Lemburg <<a href="mailto:mal@egenix.com">mal@egenix.com</a>> wrote:<br>
><br>
>><br>
>> Juraj: Could you provide some use cases, where such a function<br>
>> would help in Python applications ? (I can see use cases<br>
>> written in C, but due to the low level, find it hard to<br>
>> believe that people would use this at the Python level)<br>
>><br>
><br>
> In my case, `nextafter` would be used to check if a number is close to<br>
> polynomial zero, e.g.:<br>
><br>
>     def f(x):<br>
>         return 2.0*x**3 - 3.0*x**2 + 5.0*x - 7.0<br>
><br>
>     # x = 1.4455284586795218<br>
>     x = 1.445528458679522<br>
>     # x = 1.4455284586795223<br>
>     # x = 1.4455284586795225<br>
><br>
>     left = nextafter(x, -float('inf'))<br>
>     right = nextafter(x, float('inf'))<br>
><br>
>     print((f(left) < 0.0) != (f(x) < 0.0) or (f(x) < 0.0) != (f(right) <<br>
> 0.0))<br>
<br>
</div></div>Isn't this something you can do with math.isclose() ?<br>
<br>
This would even give you a predefined error range,<br>
not a dynamic one.<br>
<div class="HOEnZb"><div class="h5"><br>
--<br>
Marc-Andre Lemburg<br>
eGenix.com<br>
<br>
Professional Python Services directly from the Experts (#1, Feb 06 2017)<br>
>>> Python Projects, Coaching and Consulting ...  <a href="http://www.egenix.com/" rel="noreferrer" target="_blank">http://www.egenix.com/</a><br>
>>> Python Database Interfaces ...           <a href="http://products.egenix.com/" rel="noreferrer" target="_blank">http://products.egenix.com/</a><br>
>>> Plone/Zope Database Interfaces ...           <a href="http://zope.egenix.com/" rel="noreferrer" target="_blank">http://zope.egenix.com/</a><br>
______________________________<wbr>______________________________<wbr>____________<br>
<br>
::: We implement business ideas - efficiently in both time and costs :::<br>
<br>
   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48<br>
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg<br>
           Registered at Amtsgericht Duesseldorf: HRB 46611<br>
               <a href="http://www.egenix.com/company/contact/" rel="noreferrer" target="_blank">http://www.egenix.com/company/<wbr>contact/</a><br>
                      <a href="http://www.malemburg.com/" rel="noreferrer" target="_blank">http://www.malemburg.com/</a><br>
<br>
</div></div></blockquote></div><br></div>