"""Exact finite checks for the odd-index Lambert determinant. Python 3.9+.""" from fractions import Fraction from functools import cache from math import comb, factorial, gcd, prod WEIGHTS = ((1, 0), (0, 1), (-1, 1), (-9, 1), (3, -2)) def weight(k, u, v): return u + v * (2 * k + 1) ** 2 def check_series(limit=160): count = 0 for u, v in WEIGHTS: h, c = u + v, 4 * v direct = [0] * (limit + 1) geometric = direct.copy() for d in range(1, limit + 1, 2): for power in range(d, limit + 1, d): direct[power] += u + v * d**2 for n in range(1, limit + 1): for power in range(n, limit + 1, 2 * n): geometric[power] += h for j, power in enumerate(range(3 * n, limit + 1, 2 * n)): geometric[power] += 2 * c * comb(j + 2, 2) assert direct == geometric count += limit for a in range(1, 7): kernel = [0] * (limit + 1) shifted = kernel.copy() for k in range(limit + a + 1): d = 2 * k + 1 for power in range(d + 2 * a * k, limit + 1, d): kernel[power] += weight(k, u, v) for n in range(a + 1, limit + a + 1): for k, power in enumerate(range(n - a, limit + 1, 2 * n)): shifted[power] += weight(k, u, v) assert kernel == shifted count += limit return count def determinant(matrix): rows = [row.copy() for row in matrix] value = Fraction(1) for j in range(len(rows)): pivot = next((i for i in range(j, len(rows)) if rows[i][j]), None) if pivot is None: return Fraction(0) if pivot != j: rows[j], rows[pivot] = rows[pivot], rows[j] value = -value pivot_value = rows[j][j] value *= pivot_value for i in range(j + 1, len(rows)): factor = rows[i][j] / pivot_value for k in range(j + 1, len(rows)): rows[i][k] -= factor * rows[j][k] return value def multiply_by_linear(poly, root): result = [0] * (len(poly) + 1) for i, coeff in enumerate(poly): result[i] -= root * coeff result[i + 1] += coeff return result def monic_quotient(degree, divisor): # Ordinary polynomial long division of s^degree, in ascending powers. remainder = [0] * degree + [1] size = len(divisor) - 1 quotient = [0] * max(0, degree - size + 1) for i in reversed(range(len(quotient))): quotient[i] = remainder[i + size] for j, coeff in enumerate(divisor): remainder[i + j] -= quotient[i] * coeff return quotient def moment_entries(b, size, u, v): nodes = [b ** (2 * a) for a in range(1, size + 1)] divisor = [1] partial_sums = [] total = Fraction(0) for a, node in enumerate(nodes, 1): z = b**a total += Fraction((u + v) * z, node - 1) total += Fraction(8 * v * z**3, (node - 1) ** 3) partial_sums.append(total) divisor = multiply_by_linear(divisor, node) inverse_derivatives = [ Fraction(1, b**a * prod(node - other for other in nodes if node != other)) for a, node in enumerate(nodes, 1) ] moments = [Fraction(weight(j, u, v), b ** (2 * j + 1) - 1) for j in range(size - 1)] scale = (-1) ** size * b ** (size * (size + 1)) entries = [] for m in range(2 * size - 1): quotient = monic_quotient(m, divisor) constant = sum(coef * moments[j] for j, coef in enumerate(quotient)) linear = Fraction(0) for node, inv, partial in zip(nodes, inverse_derivatives, partial_sums): residual = node**m * inv constant += residual * partial linear -= residual entries.append((scale * constant, scale * linear)) return entries def det_at(entries, size, x): values = [constant + x * linear for constant, linear in entries] return determinant([values[i:i + size] for i in range(size)]) def interpolate(values): # Newton's formula from the samples at 0,1,...,K. differences = list(values) coefficients = [Fraction(0)] * len(values) falling_product = [1] for j in range(len(values)): multiplier = differences[0] / factorial(j) for k, coef in enumerate(falling_product): coefficients[k] += multiplier * coef differences = [right - left for left, right in zip(differences, differences[1:])] falling_product = multiply_by_linear(falling_product, j) return coefficients @cache def cyclotomic_value(b, d): factors = prod(cyclotomic_value(b, j) for j in range(1, d) if d % j == 0) result, remainder = divmod(b**d - 1, factors) assert remainder == 0 return result def pole_bound(size, d): # At d=1 test the sharper one-cluster bound as well as its claimed # inequality with the pure-cube denominator in the published theorem. if d == 1: costs = [size + 2 - 2 * j for j in range(size)] sharp = sum(max(1, cost) for cost in costs) coarse = sum(max(0, cost) for cost in costs) assert sharp == coarse + (size - 2) // 2 <= coarse + size - 2 return sharp e = d // gcd(d, 2) rho = max(0, size - 1 - (d - 1) // 2) if d % 2 else 0 if e > size: return rho coarse = 0 sharp_odd = 0 for r in range(1, e + 1): m = len(range(r, size + 1, e)) for j in range(m): cost = m + 2 - 2 * j if j == m - 1 and r < e: cost = 0 coarse += max(0, cost) sharp_odd += max(1, cost) if d % 2: return min(coarse + rho, sharp_odd) return min(coarse, 3 * size) def check_determinants(): cases = [(b, size, u, v) for b in (2, 3, 6) for size in range(2, 9) for u, v in WEIGHTS] cases += [(b, size, -9, 1) for b in (2, 3, 6) for size in (9, 10)] coefficients_tested = 0 for b, size, u, v in cases: entries = moment_entries(b, size, u, v) coefficients = interpolate([det_at(entries, size, x) for x in range(size + 1)]) for x in (Fraction(-2), Fraction(3, 7)): assert sum(coef * x**j for j, coef in enumerate(coefficients)) == det_at(entries, size, x) # All denominator nodes are distinct; the X-coefficient matrix is # a Vandermonde product with known nonzero diagonal weights. nodes = [b ** (2 * a) for a in range(1, size + 1)] scale = (-1) ** size * b ** (size * (size + 1)) vandermonde = prod(y - x for i, x in enumerate(nodes) for y in nodes[i + 1:]) diagonal = [Fraction(-scale, b**a * prod(x - y for y in nodes if x != y)) for a, x in enumerate(nodes, 1)] assert coefficients[-1] == vandermonde**2 * prod(diagonal) != 0 content = size**2 * (size + 1) - comb(size + 2, 3) clearing = prod(cyclotomic_value(b, d) ** pole_bound(size, d) for d in range(1, 2 * size + 1)) assert gcd(clearing, b) == 1 for coef in coefficients: assert (coef * Fraction(clearing, b**content)).denominator == 1, (b, size, u, v) coefficients_tested += len(coefficients) return len(cases), coefficients_tested FIELD = 241 @cache def local_jet(zeta, k, order=5): # Expand x/(1-x), x=zeta^(2k+1)(1+pi)^(2k+1), by series division. exponent = 2 * k + 1 constant = pow(zeta, exponent, FIELD) inverse = pow(1 - constant, -1, FIELD) x = [constant * comb(exponent, j) % FIELD for j in range(order + 1)] coeffs = [] for j in range(order + 1): convolution = sum(x[i] * coeffs[j - i] for i in range(1, j + 1)) coeffs.append((x[j] + convolution) * inverse % FIELD) return coeffs def check_even_roots(): generator = next( g for g in range(2, FIELD) if all(pow(g, (FIELD - 1) // p, FIELD) != 1 for p in (2, 3, 5)) ) count = 0 for d in (2, 4, 6, 8, 10, 12, 16, 20, 24): e = d // 2 for i in range(1, d): if gcd(i, d) != 1: continue zeta = pow(generator, (FIELD - 1) // d * i, FIELD) for k in range(e): for u, v in WEIGHTS: for r in range(6): row = [weight(k + e * j, u, v) * local_jet(zeta, k + e * j)[r] % FIELD for j in range(r + 6)] for _ in range(r + 3): row = [(right - left) % FIELD for left, right in zip(row, row[1:])] assert row == [0, 0, 0] count += len(row) return count if __name__ == "__main__": print("Checked formal series coefficients through degree 160:", check_series()) determinants, coefficients = check_determinants() print("Exact rational determinant polynomials:", determinants) print("Coefficients simultaneously satisfying both divisibility bounds:", coefficients) print("The order-one exponent uses the sharper odd-cluster bound.") print("Determinants checked at two extra rational arguments and by their leading coefficients.") print("Bases 2, 3, 6; K=2,...,8 for five weights, K=9,10 also for (u,v)=(-9,1).") print("Vanishing finite differences at even roots in F_241:", check_even_roots()) print("Orders 2,4,6,8,10,12,16,20,24; all primitive roots; Taylor degrees 0,...,5.")