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

Anne Archibald peridot.faceted at gmail.com
Wed Feb 21 17:09:39 EST 2007


On 21/02/07, Robert Kern <robert.kern at gmail.com> wrote:

> 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.

If the trig functions are implemented at all, you can probably use
atan2(-1,0) and get a decent approximation; alternatively, if you want
to use sin(pi)=0 as a definition you could use scipy's bisection
routine (which is datatype-independent, IIRC) to find pi. Or you could
probably use a rational approximation to pi, then convert numerator
and denominator to long doubles, or better yet compare the rational
number with your long double approximation of pi.

But no, not particularly easy.

Anne


More information about the NumPy-Discussion mailing list