[Numpy-discussion] improving arange()? introducing fma()?

Nils Becker nilsc.becker at gmail.com
Sun Feb 25 06:34:48 EST 2018


Hey,


> Anyone that understands FP better than I do:
>
> In the above code, you are multiplying the step by an integer -- is there
> any precision loss when you do that??
>
>
Elementary operations (add, sub, mul, div) are demanded to be correctly
rounded (cr) by IEEE, i.e. accurate within +/- 0.5 ulp. Consequently, a cr
multiplication followed by a cr addition will be accurate within +/-1 ulp.
This is also true if the first multiplicand is an integer.
Using FMA will reduce this to +/- 0.5 ulp. This increase in accuracy of the
grid calculation should not be relevant - but it also does not hurt.

Still I would suggest adding the FMA operation to numpy, e.g. np.fma(a, b,
c). There are several places in numpy that could benefit from the increased
accuracy, e.g. evaluation of polynomials using Horner's method. In cases
like this due to iteration and consequent error propagation the accuracy
benefit of using FMA can be far larger. There may also be a performance
benefit on platforms that implement FMA in hardware (although I am not sure
about that).

Cheers
Nils
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20180225/4f938d4a/attachment.html>


More information about the NumPy-Discussion mailing list