-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Labels
Description
3:24 AM] slabdrill: i improved my hyperbolic trig functions. it turns out they really only have a range of however much your precision can fit. so not necessarily needed i guess.
[6:15 AM] slabdrill: I think you should just make factorial a static instead of being a function of decimal
[6:22 AM] slabdrill:
static factorial(value) {
let n = value+1;
return Decimal.pow((n/Math.E)*Math.sqrt(n*Math.sinh(1/n)+1/(810*Math.pow(n, 6))), n).mul(Math.sqrt(2*Math.PI/n));
}
static fact(value) {return Decimal.factorial(value)}
static permutation(value,other) {
return Decimal.fact(value).div(Decimal.fact(value-other))
}
static combination(value,other) {
return Decimal.permutation(value,other).div(Decimal.fact(other))
}
static doubleFactorial(value) {
value = Math.round(value) //making sure only ints can get in
if (value % 2 == 1) return Decimal.fact(value).div(Decimal.doubleFactorial(value-1))
return Decimal.fact(value/2).mul(Decimal.pow(2,value/2))
//also this doesnt support negatives
}
ilog(base) { //https://en.wikipedia.org/wiki/Iterated_logarithm
if (this.lte(1)) return 0;
let t = this.log(base)
for (var r=1;t>=1;r++) t = Math.log(t)/Math.log(base);
return r;
}
[7:21 AM] slabdrill: is exp() faster the way it is or would this.pow(Math.E) be faster
random suggestion: make the base comparison functions work with tolerance without needing to specify _tolerance. This can be done by checking if args.length is 2 (i think?)
[3:09 AM] slabdrill: random break_infinity suggestion:
root(x) {
if (x%2 !== 1 || this.m >= 0) return this.pow(1/x)
return this.negate().pow(1/x)
}
basically, allows doing negatives for odd roots