MCPcopy Create free account
hub / github.com/nodejs/node / cos

Function cos

deps/v8/test/mjsunit/sin-cos.js:100–111  ·  view source on GitHub ↗
(x)

Source from the content-addressed store, hash-verified

98}
99
100function cos(x) {
101 var sign = -1;
102 var x2 = x*x;
103 x = x2;
104 var terms = [1];
105 for (var i = 2; i < accuracy; i += 2) {
106 terms.push(sign * x / factorial[i]);
107 x *= x2;
108 sign *= -1;
109 }
110 return precision_sum(terms);
111}
112
113function abs_error(fun, ref, x) {
114 return Math.abs(ref(x) - fun(x));

Callers 8

try_catch.jsFile · 0.85
cos_f64Function · 0.85
f5Function · 0.85

Calls 2

precision_sumFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected