import assert from 'node:assert/strict'; function multiplyLinear(polynomial, constant) { const product = Array(polynomial.length + 1).fill(0n); for (let i = 0; i < polynomial.length; i++) { product[i] += constant * polynomial[i]; product[i + 1] += polynomial[i]; } return product; } function scaledEhrhart(d, n) { const polynomial = Array(d + 1).fill(0n); for (let height = 0; height < d; height++) { const multiplicity = height === 0 ? 1n : height === d - 1 ? n - 1n : n; let falling = [multiplicity]; for (let k = 1 - height; k <= d - height; k++) { falling = multiplyLinear(falling, BigInt(k)); } falling.forEach((value, i) => { polynomial[i] += value; }); } return polynomial; } for (let d = 2; d <= 48; d++) { for (let n = 2n; n <= 200n; n++) { const coefficients = scaledEhrhart(d, n); let descending = false; coefficients.forEach((value, i) => { assert(value > 0n); if (i && coefficients[i - 1] > value) descending = true; if (i && descending) assert(coefficients[i - 1] >= value, `d=${d}, N=${n}`); }); } } console.log('9353 parameter pairs: positive and unimodal with exact coefficients.');