This is the mail archive of the
gsl-discuss@sourceware.org
mailing list for the GSL project.
Re: haversine in specfunc
Richard Mathar writes:
> Since the evaluation of 1-cos(x) close to x=0, 2*pi etc
> suffers from numerical instability in the standard implementations,
> it would be convenient to have a haversine implementation,
> where the haversine is defined according to section 4.3.147 of
> the Abramowitz/Stegun book.
Hello,
Thanks for the suggestions. For this case I think a double angle
formula will do the job: 1-cos(x) = 2 sin^2(x/2)
> I also think that the error estimate for cos(x) for x around zero
> is a factor of 2 too large, by comparison with the standard
> Taylor series that is used.
Generally there is an extra factor of 2 for safety in the error terms.
I'll add a note about that to the design document.
--
Brian Gough