[Numpy-discussion] Slightly off-topic - accuracy of C exp function?

David Cournapeau cournape at gmail.com
Wed Apr 23 05:01:26 EDT 2014


On Wed, Apr 23, 2014 at 9:43 AM, Nathaniel Smith <njs at pobox.com> wrote:

> On Wed, Apr 23, 2014 at 6:22 AM, Matthew Brett <matthew.brett at gmail.com>
> wrote:
> > Hi,
> >
> > I'm exploring Mingw-w64 for numpy building, and I've found it gives a
> > slightly different answer for 'exp' than - say - gcc on OSX.
> >
> > The difference is of the order of the eps value for the output number
> > (2 * eps for a result of ~2.0).
> >
> > Is accuracy somewhere specified for C functions like exp?  Or is
> > accuracy left as an implementation detail for the C library author?
>
> C99 says (sec 5.2.4.2.2) that "The accuracy of the floating point
> operations ... and of the library functions in <math.h> and
> <complex.h> that return floating point results is implemenetation
> defined. The implementation may state that the accuracy is unknown."
> (This last sentence is basically saying that with regard to some
> higher up clauses that required all conforming implementations to
> document this stuff, saying "eh, who knows" counts as documenting it.
> Hooray for standards!)
>
> Presumably the accuracy in this case is a function of the C library
> anyway, not the compiler? Numpy has its own implementations for a
> bunch of the math functions, and it's been unclear in the past whether
> numpy or the libc implementations were better in any particular case.
>

In the case of MS runtime, at least 9 (as shipped in VS 2008), our
implementation is likely to be better (most of the code was taken from the
sun math library when the license allowed it).

David

>
> -n
>
> --
> Nathaniel J. Smith
> Postdoctoral researcher - Informatics - University of Edinburgh
> http://vorpus.org
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20140423/6796861f/attachment.html>


More information about the NumPy-Discussion mailing list