[Python-ideas] math.nextafter
M.-A. Lemburg
mal at egenix.com
Fri Feb 24 05:29:02 EST 2017
On 24.02.2017 10:13, Nick Coghlan wrote:
> On 6 February 2017 at 20:29, M.-A. Lemburg <mal at egenix.com> wrote:
>
>> On 04.02.2017 12:59, Stephan Houben wrote:
>>> Hi all,
>>>
>>> Visual C++ 2015 supports this one:
>>>
>>> https://msdn.microsoft.com/en-us/library/h0dff77w.aspx
>>>
>>> In any case, this is easy to implement an efficient fallback in C, unlike
>>> the fma() function we discussed some time ago.
>>>
>>> To put this in a bit wider perspective: would it be useful to investigate
>>> how much of the C99 math library could
>>> be supported in Python in general?
>>
>> +1 from me for those features which can be emulated for
>> platforms which don't have the math lib function
>> available and are not too esoteric (though many of those
>> have already been added), e.g. cbt() may be useful.
>>
>> Now, with respect to the one mentioned in the subject,
>> I'm not sure how useful this would be in the stdlib,
>> since it's very much tied to whatever float type Python
>> happens to use on a platform.
>>
>
> Just from an API point of view, a more idiomatically-Pythonic concept seems
> to me to be a "floatrange()" construct, where the default step was defined
> by the internal representation (i.e. it would increment by the smallest
> possible value).
>
> I'm not sure of any use cases outside exploring the behaviour of numerical
> algorithm implementations in the presence of mathematical discontinuities,
> though.
Perhaps closeto() could be extended to address the use case:
"Match anything within N number of smallest float representable
intervals around float value x"
https://www.python.org/dev/peps/pep-0485/
This could then be used to detect cases where it doesn't
make sense to run additional rounds of refinement to
find roots or local minima, since IEEE floats simply don't
provide enough accuracy to dig deeper.
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Experts (#1, Feb 24 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/
More information about the Python-ideas
mailing list