Glibc Proposes CORE-MATH Implementations for Trigonometric Functions with Enhanced Rounding Accuracy
Adhemerval Zanella has submitted a glibc patch series aimed at replacing IBM's double-precision `sin`, `cos`, and `sincos` routines with CORE-MATH implementations. The primary goal is to achieve correct rounding in all rounding modes, addressing inaccuracies found in the current IBM code. The existing IBM routines often misround by one unit in the last place, particularly outside of round-to-nearest mode. Zanella's analysis of over four billion inputs revealed that about half of the results in directed rounding modes were off by one unit, and three-quarters of paired `sincos` results had at least one incorrect value. Even in round-to-nearest mode, the IBM functions misround hundreds of thousands of hard-to-round cases identified by CORE-MATH. The proposed CORE-MATH `sincos` function is built upon the new `sin` and `cos` code, ensuring bitwise identical results. This change is significant because compilers frequently optimize `sin` and `cos` of the same argument into a single `sincos` call, necessitating ag...