MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / zeta3

Function zeta3

benchmarks/big-decimal/ops-bench.mjs:86–98  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

84// ζ(3) = 5/2 · Σ_{n≥1} (-1)^(n-1) / (n³ · C(2n,n)); term ~ /64 per step →
85// ~0.55·prec terms for prec digits. Recomputed in full each call (no memo).
86function zeta3() {
87 const half = new B('0.5');
88 let sum = new B(0);
89 let binom = 1n; // C(2n,n)
90 const terms = Math.ceil(prec * 0.6) + 4;
91 for (let n = 1; n <= terms; n++) {
92 binom = (binom * BigInt(2 * n) * BigInt(2 * n - 1)) / (BigInt(n) * BigInt(n));
93 const denom = new B(BigInt(n * n * n) * binom);
94 const t = B.ONE.div(denom);
95 sum = (n & 1) === 1 ? sum.add(t) : sum.sub(t);
96 }
97 return sum.mul(half).mul(new B(5)); // 5/2 · Σ
98}
99
100// ---- op table -------------------------------------------------------------
101// Each is a closure taking the call counter `i` (already masked) and doing ONE

Callers 1

ops-bench.mjsFile · 0.85

Calls 5

divMethod · 0.65
addMethod · 0.65
subMethod · 0.65
mulMethod · 0.65
ceilMethod · 0.45

Tested by

no test coverage detected