MCPcopy Create free account
hub / github.com/arguiot/TheoremJS / arctan

Method arctan

__test__/theorem.js:1233–1249  ·  view source on GitHub ↗
(x)

Source from the content-addressed store, hash-verified

1231 const digits = 15
1232 const Decimal = BigNumber.clone({ DECIMAL_PLACES: digits })
1233 function arctan(x) {
1234 var y = x;
1235 var yPrev = NaN;
1236 var x2 = x.times(x);
1237 var num = x;
1238 var sign = -1;
1239
1240 for (var k = 3; !y.eq(yPrev); k += 2) {
1241 num = num.times(x2);
1242
1243 yPrev = y;
1244 y = (sign > 0) ? y.plus(num.div(k)) : y.minus(num.div(k));
1245 sign = -sign;
1246 }
1247
1248 return y;
1249 }
1250
1251 // Machin: Pi / 4 = 4 * arctan(1 / 5) - arctan(1 / 239)
1252 // http://milan.milanovic.org/math/english/pi/machin.html

Callers

nothing calls this directly

Calls 5

timesMethod · 0.80
eqMethod · 0.80
plusMethod · 0.80
divMethod · 0.80
minusMethod · 0.80

Tested by

no test coverage detected