At 5:47 PM -0700 4/7/04, Steve Peters wrote:
> > Incidentally, the reason one needs only x \in (0,PI/2) is that the
>> trigonometric
>> functions' shapes are just tesselations of the shapes of their curves
>> in said restricted interval (0,PI/2).
>
> From the perspective of numerical stability, it turns out that the most
>satisfactory treatment of cos() reduces x into [0, PI/4), and chooses
>between algebraic formulae for cos() or sin() as needed. This avoids
>some nasty cancellation near PI/2 for the cosine. Sine is best handled
>in the same way. [I like YAMS -- Yet another mirror symmetry.]
And just to throw another trick into the ring.
You can use the sin(theta) = f (sin(theta/2)) relation to actually reduce the argument to be near zero where the series converges MUCH faster. So you do a bunch of divide by 2 to make the argument small, evaluate it and repeatedly get the sine of the double value.
How much you divide by 2 depends on accuracy and speed of course. But this can of course be optimized better than a straight evaluation.
-Scott
_______________________________________________
scitech mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/scitech
Do not post admin requests to the list. They will be ignored.