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:
parent
e634266aad
commit
2b1298cd69
@ -745,13 +745,12 @@
|
|||||||
Ctor.precision = pr + 6;
|
Ctor.precision = pr + 6;
|
||||||
Ctor.rounding = 1;
|
Ctor.rounding = 1;
|
||||||
|
|
||||||
x = x.asin();
|
x = (new Ctor(1)).minus(x).div(x.plus(1)).sqrt().atan();
|
||||||
halfPi = getPi(Ctor, pr + 4, rm).times(0.5);
|
|
||||||
|
|
||||||
Ctor.precision = pr;
|
Ctor.precision = pr;
|
||||||
Ctor.rounding = rm;
|
Ctor.rounding = rm;
|
||||||
|
|
||||||
return halfPi.minus(x);
|
return x.times(2);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -741,13 +741,12 @@ P.inverseCosine = P.acos = function () {
|
|||||||
Ctor.precision = pr + 6;
|
Ctor.precision = pr + 6;
|
||||||
Ctor.rounding = 1;
|
Ctor.rounding = 1;
|
||||||
|
|
||||||
x = x.asin();
|
x = (new Ctor(1)).minus(x).div(x.plus(1)).sqrt().atan();
|
||||||
halfPi = getPi(Ctor, pr + 4, rm).times(0.5);
|
|
||||||
|
|
||||||
Ctor.precision = pr;
|
Ctor.precision = pr;
|
||||||
Ctor.rounding = rm;
|
Ctor.rounding = rm;
|
||||||
|
|
||||||
return halfPi.minus(x);
|
return x.times(2);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user