1
0
mirror of https://github.com/MikeMcl/decimal.js.git synced 2026-09-22 20:04:09 +00:00

#217 Compute acos with less cancellation near x=1

This commit is contained in:
Alden
2023-02-12 23:02:53 -05:00
committed by Michael Mclaughlin
parent 7f01abd83d
commit 08e5a381d2
8 changed files with 141 additions and 7 deletions

View File

@@ -741,13 +741,12 @@ P.inverseCosine = P.acos = function () {
Ctor.precision = pr + 6;
Ctor.rounding = 1;
x = x.asin();
halfPi = getPi(Ctor, pr + 4, rm).times(0.5);
x = (new Ctor(1)).minus(x).div(x.plus(1)).sqrt().atan();
Ctor.precision = pr;
Ctor.rounding = rm;
return halfPi.minus(x);
return x.times(2);
};