1
0
mirror of https://github.com/MikeMcl/decimal.js.git synced 2024-10-27 20:34:12 +00:00

use a method less prone to cancellation near x=1

This commit is contained in:
Alden 2023-02-13 03:50:30 -05:00
parent e634266aad
commit 2b1298cd69
2 changed files with 5 additions and 7 deletions

View File

@ -745,13 +745,12 @@
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);
};

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);
};