[Numpy-discussion] what goes wrong with cos(), sin()

Zachary Pincus zpincus@stanford....
Wed Feb 21 12:43:57 CST 2007


It's true -- blindly using allclose isn't a lot better than blindly  
using equality testing. (Though given the choice between blindly  
using one and blindly using the other, I'd still probably vote for  
allclose... it won't get you quantum mechanics, but it'll do fine for  
a lot of other things.)

On the other hand, *properly* using allclose (e.g. setting the  
absolute and expected relative error tolerances) is better than  
properly using equality testing because in many cases there is no  
proper use for equality testing.

Zach

On Feb 21, 2007, at 10:29 AM, Anne Archibald wrote:

> On 21/02/07, Zachary Pincus <zpincus@stanford.edu> wrote:
>
>> A corrolary: in general do not two floating-point values for equality
>> -- use something like numpy.allclose. (Exception -- equality is
>> expected if the exact sequence of operations to generate two numbers
>> were identical.)
>
> I really can't agree that blindly using allclose() is a good idea. For
> example, allclose(plancks_constant,0) and the difference leads to
> quantum mechanics... you really have to know how much difference you
> expect and how big your numbers are going to be.
>
> Anne
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion



More information about the Numpy-discussion mailing list