Skip to content

Conversation

IanBriggs
Copy link

I think there is a typo in sincos.h that dramatically increases error for the sin and cos functions by parenthesizing an expression the wrong way. You can see a more detailed exploration in https://github.com/IanBriggs/vdt_cos_error, but in short, in sincos.h, line 123 is:

c = 1.0 - zz * .5 + zz * zz * get_cos_px(zz);

This adds 1.0 and -zz * .5 together first, but it's more accurate to go from smallest to largest magnitude, like this:

c = 1.0 + zz * (-.5 + zz * get_cos_px(zz));

This cuts the worst case error approximately in half for fast_cos on the domain $[0, \frac{\pi}{2}]$.

Here's a plot of error values versus MPFR over this interval:
Original_vs_Reordered_Absolute_Error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant