On Thu, 25 May 2006, Alexander Belopolsky apparently wrote:
This is not really a numpy issue, but general floating point problem. Consider this:
x=linspace(0,10*pi,11) all(array(map(math.sin, x))==sin(x))
True
I think this misses the point. I was not suggesting numpy results differ from the C math library results.
x1=sin(linspace(0,10*pi,21)) x2=sin(linspace(0,10*pi,21)%(2*pi)) all(x1==x2)
False
x1
array([ 0.00000000e+00, 1.00000000e+00, 1.22460635e-16, -1.00000000e+00, -2.44921271e-16, 1.00000000e+00, 3.67381906e-16, -1.00000000e+00, -4.89842542e-16, 1.00000000e+00, 6.12303177e-16, -1.00000000e+00, -7.34763812e-16, 1.00000000e+00, 8.57224448e-16, -1.00000000e+00, -9.79685083e-16, 1.00000000e+00, 1.10214572e-15, -1.00000000e+00, -1.22460635e-15])
x2
array([ 0.00000000e+00, 1.00000000e+00, 1.22460635e-16, -1.00000000e+00, 0.00000000e+00, 1.00000000e+00, 1.22460635e-16, -1.00000000e+00, 0.00000000e+00, 1.00000000e+00, 1.22460635e-16, -1.00000000e+00, 0.00000000e+00, 1.00000000e+00, 1.22460635e-16, -1.00000000e+00, 0.00000000e+00, 1.00000000e+00, 1.22460635e-16, -1.00000000e+00, 0.00000000e+00])
I'd rather have x2: I'm just asking if there is anything exploitable here. Robert suggests not.
Cheers, Alan Isaac