Fix 180 favor issue, reworked favor and reputation mathjax

This commit is contained in:
Olivier Gagnon
2021-09-03 17:12:55 -04:00
parent 5dd6145d53
commit cc9a07c09f
4 changed files with 18 additions and 6 deletions
+8 -1
View File
@@ -2,8 +2,15 @@
// These formulas were derived on wolfram alpha.
// Wolfram Alpha: sum from 0 to n of 500*1.02^n
// 500 * ((pow(51, f+1)) / pow(50,f) - 50)
// Then we use https://herbie.uwplse.org/demo/ to simplify it and prevent
// Infinity issues.
export function favorToRep(f: number): number {
return 500 * ((Math.pow(51, f+1)) / Math.pow(50,f) - 50);
function fma(a: number, b: number, c: number): number {
return a * b + c;
}
const ex = fma(f, (Math.log(51.0) - Math.log(50.0)), Math.log(51.0));
return fma(500.0, Math.exp(ex), -25000.0);
}
// Wolfram Alpha: 500 (50^(-n) 51^(n + 1) - 50) solve for n