[Numpy-discussion] what goes wrong with cos(), sin()
David L Goldsmith
David.L.Goldsmith@noaa....
Thu Feb 22 12:29:47 CST 2007
I agree w/ Chuck - I'd consider what Tim describes is happening a "bug".
DG
Charles R Harris wrote:
>
>
> On 2/21/07, *Timothy Hochberg* <tim.hochberg@ieee.org
> <mailto:tim.hochberg@ieee.org>> wrote:
>
>
>
> On 2/21/07, *Charles R Harris* < charlesr.harris@gmail.com
> <mailto:charlesr.harris@gmail.com>> wrote:
>
>
>
> On 2/21/07, *Robert Kern* < robert.kern@gmail.com
> <mailto:robert.kern@gmail.com>> wrote:
>
> Christopher Barker wrote:
> > Robert Kern wrote:
> >> Christopher Barker wrote:
> >>> I wonder if there are any C math libs that do a better
> job than you'd
> >>> expect from standard FP? (short of unlimited precision
> ones)
> >> With respect to π and the zeros of sin() and cos()? Not
> really.
>
>
> <snip>
>
> Well, you can always use long double if it is implemented
> on your platform. You
> will have to construct a value for π yourself, though. I'm
> afraid that we don't
> really make that easy.
>
> --
>
>
> pi = 3. 1415926535 8979323846 2643383279 5028841971 6939937510
> 5820974944 5923078164 0628620899 8628034825 3421170679
> 8214808651 *...
>
> *
> I dont know what that looks like when converted to long
> double. Lessee,
>
> In [1]: import numpy
>
> In [2]: pi =
> numpy.float128(3.1415926535897932384626433832795028841971)
>
>
> I think this is where you go wrong. Your string of digits is first
> a python float and *then* is converted to a long double. In the
> intermediate stage it gets truncated and you don't get the
> precision back.
>
>
> True. But there is missing functionality here.
>
> In [4]: pi = numpy.float128('3.1415926535897932384626433832795028841971')
> ---------------------------------------------------------------------------
>
> exceptions.TypeError Traceback (most
> recent call last)
>
> /home/charris/workspace/microsat/daemon/<ipython console>
>
> TypeError: a float is required
>
> It's somewhat pointless to have a data type that you can't properly
> initialize. I think the string value should work, it works for python
> types.
>
> Chuck
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
--
ERD/ORR/NOS/NOAA <http://response.restoration.noaa.gov/emergencyresponse/>
More information about the Numpy-discussion
mailing list