Codefactor changes, comment improvement

This commit is contained in:
Dan Simon 2023-02-09 13:50:59 -05:00 committed by dan-simon
parent 12958ccd9d
commit bd02e7e394

View File

@ -514,13 +514,14 @@ window.logFactorial = (function() {
};
}());
window.exp1m = function (x) {
window.exp1m = function(x) {
if (x.abs().gte(0.001)) {
return x.exp().minus(1);
} else {
// Probably just figuring out these are the only terms needed is faster than calculating all the terms.
return x.plus(x.pow(2).div(2)).plus(x.pow(3).div(6)).plus(x.pow(4).div(24)).plus(x.pow(5).div(120));
}
// This sum contains all the terms that are relevant for |x| < 0.001. We could do some sort of loop
// (add terms as long as they matter) but that probably has a greater fixed overhead, and we don't
// call this enough for efficiency to be very worrying anyway.
return x.plus(x.pow(2).div(2)).plus(x.pow(3).div(6)).plus(x.pow(4).div(24)).plus(x.pow(5).div(120));
};
/** 32 bit XORSHIFT generator */