GNU Scientific Library - Bugs: bug #45746, Incorrect results of trigonometric...
You are not allowed to post comments on this tracker with your current authentication level.
bug #45746: Incorrect results of trigonometric functions gsl_sf_sin and gsl_sf_cos
Submitter: | Enyi Tang <eytang> | ||
Submitted: | Thu 13 Aug 2015 06:04:09 AM UTC | ||
Category: | Accuracy problem | Severity: | 3 - Normal |
Operating System: | Status: | None | |
Assigned to: | None | Open/Closed: | Open |
Release: | GSL-1.16 |
Tue 11 Oct 2016 04:35:38 PM UTC, comment #1: |
Peter Barfuss <bofh453> |
Thu 13 Aug 2015 06:04:09 AM UTC, original submission:
When I further investigate the reason of bug #45726, and the bug #45730. I find the problem is from trigonometric function gsl_sf_sin and gsl_sf_cos. It is cause by the cancellation in specfunc/trig.c, such as line 183 and line 199 in the following:
|
Enyi Tang <eytang> |
Depends on the following items: None found
Items that depend on this one: None found
Follows 1 latest change.
Date | Changed by | Updated Field | Previous Value | => | Replaced by |
---|---|---|---|---|---|
2015-08-13 | eytang | Attached File | - | Added gsltrigtest.c, #34633 |
Powered by Savane 3.13-4448.
Corresponding source code
So gsl_sf_angle_restrict_symm_err_e is basically equivalent to e_rem_pio2. As you can see in that file, this technique only works until about x ~ 2^18 * M_PI (~823549.6645, so smaller than you think). Past that, you need to implement Payne-Hanek reduction (which is the entirety of k_rem_pio2), which is somewhat of a royal payne.
http://stackoverflow.com/questions/30463616/payne-hanek-algorithm-implementation-in-c is a pretty comprehensive reference. I might throw something together myself later if I have time.
There's really no other alternative other than that or the current implementation, which is "return very invalid results for large values of fabs(x)", sadly.