Bug 997459 - Part 2: Coefficients for polevl_cos with fewer terms; potentially less precise, but more performant. r=sunfish
authorEmanuel Hoogeveen <emanuel.hoogeveen@gmail.com>
Mon, 21 Apr 2014 10:44:11 -0400
changeset 197890 25925f2cb271b7b6e2e5de97ff30d75c1abc3ffd
parent 197889 e6bb483835020a084c2326439e08599497902376
child 197891 967d37e175edbe9d3fa2436b6d7f0cc4d258e49f
push id3624
push userasasaki@mozilla.com
push dateMon, 09 Jun 2014 21:49:01 +0000
treeherdermozilla-beta@b1a5da15899a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssunfish
bugs997459
milestone31.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 997459 - Part 2: Coefficients for polevl_cos with fewer terms; potentially less precise, but more performant. r=sunfish CLOSED TREE
js/src/jsmath.cpp
--- a/js/src/jsmath.cpp
+++ b/js/src/jsmath.cpp
@@ -379,30 +379,30 @@ static double polevl_sin(double z, doubl
     ans += -1.66666666666666490881e-01; // -6004799503160655 / exp2(55)
     ans *= zz * z;
     ans += z;
     return ans;
 }
 
 static double polevl_cos(double zz)
 {
-    // Constants taken from fdlibm k_cos.c
-    double ans = -1.13596475577881948265e-11;
+    // Constants generated using Mathematica's GeneralMiniMaxApproximation.
+    // This set uses one less coefficient than usual implementations to
+    // increase performance, raising the maximum approximation error to 2 bits.
+    double ans = 2.06467337476762997948e-9;
     ans *= zz;
-    ans += 2.08757232129817482790e-09;
-    ans *= zz;
-    ans += -2.75573143513906633035e-07;
+    ans += -2.75555495413759160741e-7;
     ans *= zz;
-    ans += 2.48015872894767294178e-05;
+    ans +=  2.48015808595638122085e-5;
     ans *= zz;
-    ans += -1.38888888888741095749e-03;
+    ans += -1.38888888779622760722e-3;
     ans *= zz;
-    ans += 4.16666666666666019037e-02;
+    ans +=  4.16666666665987187046e-2;
     ans *= zz;
-    ans += -0.5;
+    ans += -4.99999999999999888978e-1;
     ans *= zz;
     ans += 1.0;
     return ans;
 }
 
 namespace {
 struct sincos_result { double s, c; };
 }