// Check the (corrected) Nekrasov-Okounkov formula as stated by Han: // sum_lambda x^|lambda| prod_{h in H(lambda)} (1 - z/h^2) = prod_{k>=1} (1 - x^k)^(z-1) // for z = 25 (Ramanujan tau: coefficient of x^(n-1) is tau(n)) and z = 2, 4 (Euler, Jacobi), n <= N, exactly in rationals. const N = 14; function partitions(n, max = n) { if (n === 0) return [[]]; const r = []; for (let k = Math.min(n, max); k >= 1; k--) for (const p of partitions(n - k, k)) r.push([k, ...p]); return r; } function hooks(l) { const c = []; for (let j = 0; j < (l[0] || 0); j++) c.push(l.filter(x => x > j).length); const H = []; l.forEach((row, i) => { for (let j = 0; j < row; j++) H.push(row - j - 1 + c[j] - i - 1 + 1); }); return H; } const gcd = (a, b) => b ? gcd(b, a % b) : (a < 0n ? -a : a); function lhs(n, z) { let num = 0n, den = 1n; // sum of prod (h^2 - z)/h^2 for (const l of partitions(n)) { let p = 1n, q = 1n; for (const h of hooks(l)) { p *= BigInt(h * h - z); q *= BigInt(h * h); } num = num * q + p * den; den *= q; const g = gcd(num, den) || 1n; num /= g; den /= g; } return den === 1n ? num : num + "/" + den; } function rhs(z) { // coefficients of prod (1-x^k)^(z-1) up to x^N, integer exponent z-1 >= 0 let c = Array(N + 1).fill(0n); c[0] = 1n; for (let k = 1; k <= N; k++) for (let t = 0; t < z - 1; t++) { const d = c.slice(); for (let i = k; i <= N; i++) d[i] -= c[i - k]; c = d; } return c; } for (const z of [2, 4, 25]) { const R = rhs(z); let ok = true; for (let n = 0; n <= N; n++) if (String(lhs(n, z)) !== String(R[n])) { ok = false; console.log("mismatch z=" + z + " n=" + n, lhs(n, z), R[n]); } console.log(`z=${z}: formula with PRODUCT over hooks matches for n<=${N}: ${ok}; coefficients ${R.slice(0, 6).join(",")}`); } // The version printed in the MO question uses a SUM over hooks; test it at z=25, n=1..4 for (let n = 1; n <= 4; n++) { let s = 0; for (const l of partitions(n)) for (const h of hooks(l)) s += 1 - 25 / (h * h); console.log(`sum-over-hooks version, n=${n}: ${s.toFixed(4)} vs tau(${n + 1}) = ${rhs(25)[n]}`); }