[Numpy-discussion] Precision/value change moving from C to Python

Daπid davidmenhur at gmail.com
Tue Nov 12 09:07:49 EST 2013


On 12 November 2013 12:01, Bart Baker <bartbkr at gmail.com> wrote:

> The issue is that there are some minor (10^-16) differences in the
> values when I do the calculation in C vs Python.
>

That is the order of the machine epsilon for double, that looks like
roundoff errors to me.

 I found similar results cythonising some code, everything was the same
until I changed some numpy functions for libc functions (exp, sin, cos...).
After some operations in float32, the results were apart for 1 in 10^-5
(the epsilon is 10^-6). I blame them on specific implementation differences
between numpy's and my system's libc specific functions.

To check equality, use np.allclose, it lets you define the relative and
absolute error.


/David.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20131112/2a39b313/attachment.html>


More information about the NumPy-Discussion mailing list