[Haskell-cafe] Sinus in Haskell

Carl Witty cwitty at newtonlabs.com
Fri Nov 9 19:57:05 EST 2007


On Sat, 2007-11-10 at 01:29 +0100, Daniel Fischer wrote:
> > The above essay was written after much experimentation using the MPFR
> > library for correctly-rounded arbitrary-precision floating point, as
> > exposed in the Sage computer algebra system.
> >
> > Carl Witty
> 
> Thanks a lot.
> 
> Since you seem to know a lot about these things, out of curiosity, do you know 
> how these functions are actually implemented? Do they use Taylor series or 
> other techniques?

I don't really know that much about it; I just understand that the
floating-point numbers are really rational numbers of a particular form,
and I know how to use MPFR (via Sage) to play with these rational
numbers.  The idea to try higher-precision approximations of pi as
approx_pi came from the link Dan Piponi posted, to
http://blogs.sun.com/jag/entry/transcendental_meditation .

Given that our numbers match the "bad" number from that blog post, I
assume that sin is actually implemented as the fsin machine
instruction. :)  It seems likely that this instruction (and library
implementations on architectures where sin is not built into the
processor) use Taylor series, but I don't know for sure.

Carl Witty




More information about the Haskell-Cafe mailing list