[Numpy-discussion] Re: numpy.sin

Sasha ndarray at mac.com
Thu May 25 14:29:07 EDT 2006


This example looks like an artifact of decimal to binary conversion.

Consider this:

>>> epsilon = 1./2**16
>>> epsilon
1.52587890625e-05
>>> sin(100*pi+epsilon)
1.5258789063872671e-05
>>> sin((100*pi+epsilon)%(2*pi))
1.5258789076118735e-05

and in bc:

scale=50
epsilon = 1./2.^16
s(100*pi + epsilon)
.00001525878906190788105354014301687863346141310239


On 5/25/06, Alan G Isaac <aisaac at american.edu> wrote:
> On Thu, 25 May 2006, Robert Kern apparently wrote:
> > What continuity? This is floating-point arithmetic.
>
> Sure, but a continuity argument suggests (in the absence of
> specific floating point reasons to doubt it) that a better
> approximation at one point will mean better approximations
> nearby.  E.g.,
>
> >>> epsilon = 0.00001
> >>> sin(100*pi+epsilon)
> 9.999999976550551e-006
> >>> sin((100*pi+epsilon)%(2*pi))
> 9.9999999887966145e-006
>
> Compare to the bc result of
> 9.9999999998333333e-006
>
>
> bc 1.05
> Copyright 1991, 1992, 1993, 1994, 1997, 1998 Free Software Foundation, Inc.
> This is free software with ABSOLUTELY NO WARRANTY.
> For details type `warranty'.
> scale = 50
> epsilon = 0.00001
> s(100*pi + epsilon)
> .00000999999999983333333333416666666666468253968254
>
> Cheers,
> Alan
>
>
>
>
> -------------------------------------------------------
> All the advantages of Linux Managed Hosting--Without the Cost and Risk!
> Fully trained technicians. The highest number of Red Hat certifications in
> the hosting industry. Fanatical Support. Click to learn more
> http://sel.as-us.falkag.net/sel?cmdlnk&kid7521&bid$8729&dat1642
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion
>




More information about the NumPy-Discussion mailing list