[libc-commits] [libc] [libc][math] Improve the performance of sin/cos for small inputs |x| < 2^-4. (PR #201748)

via libc-commits libc-commits at lists.llvm.org
Mon Jun 8 12:01:09 PDT 2026


================
@@ -55,9 +96,39 @@ LIBC_INLINE double cos(double x) {
         return fputil::round_result_slightly_down(1.0);
       }
       // No range reduction needed.
-      k = 0;
-      y.lo = 0.0;
-      y.hi = x;
+
+      // Use degree-8 polynomial approximation:
+      //   sin(x) ~ 1 + a1 * x^2 + a2 * x^4 + a3 * x^6 + a4 * x^8
----------------
lntue wrote:

Done.

https://github.com/llvm/llvm-project/pull/201748


More information about the libc-commits mailing list