Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

next slabdrill stuff #27

Open
Patashu opened this issue Dec 30, 2017 · 0 comments
Open

next slabdrill stuff #27

Patashu opened this issue Dec 30, 2017 · 0 comments

Comments

@Patashu
Copy link
Owner

Patashu commented Dec 30, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant