Disproved: Gauss-Legendre primary/secondary nodes satisfy 0 < x_i/z_i - 1 < pi^2/(12(n+1/2)^2) for all i=1..n
A public claim that this conjecture is false. We rebuilt the claimed counterexample from scratch and two separately written checkers confirmed it in exact arithmetic. Both sides of this check came from the same AI model, because the second model was unavailable. Machine-checked; not peer reviewed.
Rerun it yourself: download the certificate and a checker, then
python3 checker_b.py certificate.json
Statement, as tested
Download statement.md# Gauss-Legendre primary/secondary nodes satisfy 0 < x_i/z_i - 1 < pi^2/(12(n+1/2)^2) for all i=1..n
Source: https://arxiv.org/abs/2305.19128
Public claim to check: https://github.com/1337isnot1337/solved-conjectures/tree/main/results/lopez-pouso-segura-quadrature
Source: Ó. López Pouso and J. Segura, 'Uniform relations between the Gauss–Legendre nodes and weights', arXiv:2305.19128v3 (TeX source read directly); published in J. Inequal. Appl. (2025) article 40, https://link.springer.com/article/10.1186/s13660-025-03283-w (publisher page blocked automated access; the repository cites the published numbering 'Conjectures 3 and 7', which matches the order of the conjecture environments in arXiv v3, labels mainc1 and lili4). Definitions. Let x_1<...<x_n be the nodes (zeros of the Legendre polynomial P_n) and w_1,...,w_n the weights of n-point Gauss–Legendre quadrature on [-1,1] (sum of w_i = 2), and kappa=n+1/2. Secondary intermediate nodes: zbar_0=-1, zbar_i=zbar_{i-1}+w_i=-1+sum_{j<=i} w_j (i=1..n), so zbar_n=1. Secondary nodes: z_i=(zbar_{i-1}+zbar_i)/2, i=1..n. First-order partial moments: alpha_0=0, alpha_i=alpha_{i-1}-2 x_i w_i, i.e. alpha_i=2*sum_{k=i+1}^n x_k w_k. Conjecture 3 (mainc1): The primary and secondary nodes of Gauss–Legendre quadrature of degree n are such that 0 < x_i/z_i - 1 < pi^2/(12 kappa^2), i=1,...,n, with pi^2/12 the best possible asymptotic constant. Conjecture 7 (lili4): For all the secondary intermediate nodes and partial moments, 0 < alpha_i/(1-zbar_i^2) - 1 < pi^2/(12 kappa^2), where the constant pi^2/12 is the best possible. (For odd n the middle node has x_i=z_i=0, so the ratio in Conjecture 3 is meant for nonzero nodes; for Conjecture 7 the index ranges over interior i=1..n-1.)
Counterexample offered by the repository: the two-point Gauss–Legendre rule n=2, with nodes x=±1/sqrt(3), weights w_1=w_2=1, kappa=5/2. Then zbar_1=0, z_2=1/2, alpha_1=2/sqrt(3), so x_2/z_2-1 = alpha_1/(1-zbar_1^2)-1 = 2/sqrt(3)-1 ≈ 0.1547 > 1/7 > pi^2/75 ≈ 0.1316 = pi^2/(12 kappa^2), violating the strict upper bound in both Conjecture 3 and Conjecture 7 (the lower bounds and the asymptotic constant are not contradicted). This is in results/lopez-pouso-segura-quadrature/PROOF.md (Section 2, 'Exact common counterexample'), summarized in results/lopez-pouso-segura-quadrature/README.md, and Lean-checked per the repository in lean/Conjectures/LopezPousoSegura.lean. The repository additionally claims (non-finite, asymptotic argument in PROOF.md) that Conjecture 3 fails at the smallest positive node for every sufficiently large even n, via x_{m+1}/z_{m+1} = 1 + pi^2/(12 kappa^2) + pi^4/(120 kappa^4) + O(kappa^-6) for n=2m.
Certificate
Download certificate.json{
"statement": "Lopez Pouso-Segura Conjectures 3 (mainc1) and 7 (lili4): strict upper bound pi^2/(12 kappa^2) fails",
"n": 2,
"d": 3,
"nodes": [[["0", "1"], ["-1", "3"]], [["0", "1"], ["1", "3"]]],
"weights": [[["1", "1"], ["0", "1"]], [["1", "1"], ["0", "1"]]],
"conjecture3_index": 2,
"conjecture7_index": 1
}
Certificate format
Download CERTIFICATE.md# Certificate format `certificate.json` describes one Gauss-Legendre rule at which the upper bounds of Conjecture 3 and Conjecture 7 of Lopez Pouso and Segura (arXiv:2305.19128v3) fail. Fields: - `n`: the number of quadrature points (here 2). kappa = n + 1/2. - `d`: a squarefree positive integer. Every number below lies in the field Q(sqrt(d)). - A **number** is a pair `[a, b]` meaning `a + b*sqrt(d)`, where `a` and `b` are each a rational written as a pair of decimal-integer strings `[numerator, denominator]`. Example with d = 3: `[["0","1"],["1","3"]]` is `0 + (1/3)*sqrt(3) = 1/sqrt(3)`. - `nodes`: the n nodes x_1 < ... < x_n, each a number as above. - `weights`: the n weights w_1, ..., w_n, in the same order, each a number as above. - `conjecture3_index`: a 1-based index i (1 <= i <= n) at which `x_i/z_i - 1 < pi^2/(12 kappa^2)` is claimed to fail (with z_i > 0). - `conjecture7_index`: a 1-based interior index i (1 <= i <= n-1) at which `alpha_i/(1 - zbar_i^2) - 1 < pi^2/(12 kappa^2)` is claimed to fail. - `statement`: free text, ignored by the verifier. Here: n = 2, nodes -1/sqrt(3), 1/sqrt(3), weights 1, 1. Then zbar_1 = 0, z_2 = 1/2, alpha_1 = 2/sqrt(3), and both left-hand sides equal 2/sqrt(3) - 1 = 0.1547..., while pi^2/(12 kappa^2) = pi^2/75 = 0.1316... What `verify.py` does (exact arithmetic only, no floats): 1. Builds the Legendre polynomial P_n from Bonnet's recurrence with rational coefficients, and checks that the given nodes are strictly increasing and are all zeros of P_n (n distinct zeros of a degree-n polynomial are all of its zeros). 2. Checks that the weights make the rule exact: sum_i w_i x_i^k = integral of x^k over [-1,1] for every k = 0..2n-1. This identifies them as the Gauss-Legendre weights. 3. Computes zbar_i, z_i, alpha_i from the definitions in statement.md (and cross-checks the two equivalent definitions of alpha_i, and zbar_n = 1). 4. Computes a rigorous rational upper bound U > pi from Machin's formula pi = 16 arctan(1/5) - 4 arctan(1/239) using truncated alternating series, hence a rational B = U^2/(12 kappa^2) > pi^2/(12 kappa^2). 5. Checks exactly in Q(sqrt(d)) (signs of a + b*sqrt(d) decided by integer comparisons) that x_i/z_i - 1 > B and alpha_i/(1 - zbar_i^2) - 1 > B at the given indices. Both must hold for VERIFIED.
Checker A, written alongside the certificate
Download checker_a.py#!/usr/bin/env python3
"""usage: python3 verify.py certificate.json (exact arithmetic only)"""
import json, sys
from fractions import Fraction as F
def fail(msg):
print("FAIL:", msg)
sys.exit(1)
def squarefree(d):
p = 2
while p * p <= d:
if d % (p * p) == 0:
return False
p += 1
return True
class Q:
"""a + b*sqrt(D), a, b rational, D squarefree integer > 1."""
D = None
def __init__(self, a, b=0):
self.a, self.b = F(a), F(b)
@staticmethod
def c(x):
return x if isinstance(x, Q) else Q(x)
def __add__(s, o):
o = Q.c(o); return Q(s.a + o.a, s.b + o.b)
__radd__ = __add__
def __neg__(s):
return Q(-s.a, -s.b)
def __sub__(s, o):
return s + (-Q.c(o))
def __rsub__(s, o):
return Q.c(o) + (-s)
def __mul__(s, o):
o = Q.c(o)
return Q(s.a * o.a + s.b * o.b * Q.D, s.a * o.b + s.b * o.a)
__rmul__ = __mul__
def inv(s):
nrm = s.a * s.a - s.b * s.b * Q.D # nonzero unless s == 0 (D squarefree > 1)
if nrm == 0:
fail("division by zero")
return Q(s.a / nrm, -s.b / nrm)
def __truediv__(s, o):
return s * Q.c(o).inv()
def is_zero(s):
return s.a == 0 and s.b == 0
def sign(s):
"""exact sign of a + b*sqrt(D)"""
a, b = s.a, s.b
sa = (a > 0) - (a < 0)
sb = (b > 0) - (b < 0)
if sb == 0:
return sa
if sa == 0:
return sb
if sa == sb:
return sa
# opposite signs: compare a^2 with b^2 D (never equal, sqrt(D) irrational)
t = a * a - b * b * Q.D
if t == 0:
fail("impossible equality")
return sa if t > 0 else sb
def legendre(n):
"""coefficient list (low degree first) of P_n via (k+1)P_{k+1} = (2k+1)xP_k - kP_{k-1}"""
p0, p1 = [F(1)], [F(0), F(1)]
if n == 0:
return p0
for k in range(1, n):
nxt = [F(0)] * (k + 2)
for j, cf in enumerate(p1):
nxt[j + 1] += F(2 * k + 1, k + 1) * cf
for j, cf in enumerate(p0):
nxt[j] -= F(k, k + 1) * cf
p0, p1 = p1, nxt
return p1
def atan_bounds(q, terms):
"""rational (lower, upper) for arctan(1/q), integer q>1: alternating series with decreasing terms"""
s = F(0)
part = []
for k in range(terms + 1):
s += F((-1) ** k, (2 * k + 1) * q ** (2 * k + 1))
part.append(s)
# even number of terms summed -> last term negative -> lower bound; odd -> upper
last, prev = part[-1], part[-2]
return (min(last, prev), max(last, prev))
def main():
if len(sys.argv) != 2:
fail("usage: verify.py certificate.json")
with open(sys.argv[1]) as fh:
C = json.load(fh)
n, d = C["n"], C["d"]
if not (isinstance(n, int) and not isinstance(n, bool) and 1 <= n <= 60):
fail("bad n")
if not (isinstance(d, int) and not isinstance(d, bool) and d > 1 and squarefree(d)):
fail("d must be a squarefree integer > 1")
Q.D = d
def rd(v):
(an, ad), (bn, bd) = v
if int(ad) == 0 or int(bd) == 0:
fail("zero denominator")
return Q(F(int(an), int(ad)), F(int(bn), int(bd)))
x = [rd(v) for v in C["nodes"]]
w = [rd(v) for v in C["weights"]]
if len(x) != n or len(w) != n:
fail("need n nodes and n weights")
# 1. nodes: strictly increasing zeros of P_n (=> they are all n zeros of P_n)
for i in range(n - 1):
if (x[i + 1] - x[i]).sign() <= 0:
fail("nodes not strictly increasing")
P = legendre(n)
for xi in x:
v = Q(0)
for cf in reversed(P):
v = v * xi + cf
if not v.is_zero():
fail("a node is not a zero of P_n")
# 2. weights: exactness on x^k, k = 0..2n-1
for k in range(2 * n):
s = Q(0)
for xi, wi in zip(x, w):
t = Q(1)
for _ in range(k):
t = t * xi
s = s + wi * t
exact = F(2, k + 1) if k % 2 == 0 else F(0)
if not (s - exact).is_zero():
fail("quadrature not exact for degree %d" % k)
# 3. derived quantities, straight from the definitions
kappa = F(2 * n + 1, 2)
zbar = [Q(-1)]
for i in range(n):
zbar.append(zbar[-1] + w[i])
if not (zbar[n] - 1).is_zero():
fail("zbar_n != 1")
z = [None] + [(zbar[i - 1] + zbar[i]) / 2 for i in range(1, n + 1)] # 1-based
alpha = [Q(0)]
for i in range(1, n + 1):
alpha.append(alpha[-1] - 2 * x[i - 1] * w[i - 1])
for i in range(n + 1): # cross-check: alpha_i = 2 sum_{k>i} x_k w_k
s = Q(0)
for k in range(i + 1, n + 1):
s = s + x[k - 1] * w[k - 1]
if not (alpha[i] - 2 * s).is_zero():
fail("alpha definitions disagree")
# 4. rigorous rational upper bound for pi (Machin)
lo5, up5 = atan_bounds(5, 12)
lo239, up239 = atan_bounds(239, 4)
pi_up = 16 * up5 - 4 * lo239
pi_lo = 16 * lo5 - 4 * up239
if not (F(3) < pi_lo < pi_up < F(22, 7)):
fail("pi bounds broken")
B = pi_up * pi_up / (12 * kappa * kappa) # B > pi^2/(12 kappa^2)
# 5a. Conjecture 3 at index i
i = C["conjecture3_index"]
if not (isinstance(i, int) and not isinstance(i, bool) and 1 <= i <= n):
fail("bad conjecture3_index")
if z[i].sign() <= 0:
fail("z_i must be positive")
r3 = x[i - 1] / z[i] - 1
if (r3 - B).sign() <= 0:
fail("Conjecture 3 upper bound not violated")
# 5b. Conjecture 7 at interior index j
j = C["conjecture7_index"]
if not (isinstance(j, int) and not isinstance(j, bool) and 1 <= j <= n - 1):
fail("bad conjecture7_index")
den = 1 - zbar[j] * zbar[j]
if den.sign() <= 0:
fail("1 - zbar_j^2 must be positive")
r7 = alpha[j] / den - 1
if (r7 - B).sign() <= 0:
fail("Conjecture 7 upper bound not violated")
print("n = %d, kappa = %s, d = %d" % (n, kappa, d))
print("x_%d/z_%d - 1 = (%s) + (%s)*sqrt(%d)" % (i, i, r3.a, r3.b, d))
print("alpha_%d/(1-zbar_%d^2) - 1 = (%s) + (%s)*sqrt(%d)" % (j, j, r7.a, r7.b, d))
print("both exceed a rational upper bound of pi^2/(12 kappa^2) (bound < %s)" % F(B.numerator * 10**6 // B.denominator + 1, 10**6))
print("VERIFIED")
sys.exit(0)
if __name__ == "__main__":
try:
main()
except SystemExit:
raise
except Exception as e:
print("FAIL:", repr(e))
sys.exit(1)
Checker B, written independently from the certificate alone
Download checker_b.py#!/usr/bin/env python3
"""Independent checker for the claimed counterexample to Conjectures 3 (mainc1) and
7 (lili4) of Lopez Pouso & Segura, arXiv:2305.19128v3.
Usage: python3 checker.py certificate.json
Exact arithmetic only (Python ints / Fractions, elements of Q(sqrt d)); no floats.
Prints VERIFIED as the last line and exits 0 only if the certificate describes the
genuine n-point Gauss-Legendre rule and, at the stated indices,
x_i/z_i - 1 > pi^2/(12 kappa^2) (Conjecture 3 upper bound fails)
alpha_i/(1 - zbar_i^2) - 1 > pi^2/(12 kappa^2) (Conjecture 7 upper bound fails)
Anything else: exit 1 with a reason.
"""
import json
import re
import sys
from fractions import Fraction
MAX_N = 60
MAX_DIGITS = 2000
INT_RE = re.compile(r"-?(0|[1-9][0-9]*)\Z")
class Fail(Exception):
pass
def need(cond, msg):
if not cond:
raise Fail(msg)
# ---------------------------------------------------------------- Q(sqrt d)
class Q:
"""a + b*sqrt(D), a, b rational, D a fixed squarefree integer >= 2."""
D = None
__slots__ = ("a", "b")
def __init__(self, a, b=0):
self.a = Fraction(a)
self.b = Fraction(b)
@staticmethod
def lift(o):
if isinstance(o, Q):
return o
if isinstance(o, (int, Fraction)) and not isinstance(o, bool):
return Q(o, 0)
raise TypeError("bad operand %r" % (o,))
def __add__(self, o):
o = Q.lift(o)
return Q(self.a + o.a, self.b + o.b)
__radd__ = __add__
def __neg__(self):
return Q(-self.a, -self.b)
def __sub__(self, o):
return self + (-Q.lift(o))
def __rsub__(self, o):
return Q.lift(o) + (-self)
def __mul__(self, o):
o = Q.lift(o)
return Q(self.a * o.a + Q.D * self.b * o.b, self.a * o.b + self.b * o.a)
__rmul__ = __mul__
def inv(self):
norm = self.a * self.a - Q.D * self.b * self.b
# D squarefree >= 2 => norm == 0 iff a == b == 0
if norm == 0:
raise Fail("division by zero in Q(sqrt(d))")
return Q(self.a / norm, -self.b / norm)
def __truediv__(self, o):
return self * Q.lift(o).inv()
def __pow__(self, k):
r = Q(1)
for _ in range(k):
r = r * self
return r
def is_zero(self):
return self.a == 0 and self.b == 0
def sign(self):
"""Exact sign of a + b*sqrt(D), decided by rational comparisons."""
a, b = self.a, self.b
sa = (a > 0) - (a < 0)
sb = (b > 0) - (b < 0)
if sb == 0:
return sa
if sa == 0:
return sb
if sa == sb:
return sa
# opposite signs: |a| vs |b| sqrt(D) <=> a^2 vs b^2 D (never equal, D squarefree)
lhs, rhs = a * a, b * b * Q.D
need(lhs != rhs, "internal: a^2 == d b^2 with d squarefree")
return sa if lhs > rhs else sb
def __eq__(self, o):
o = Q.lift(o)
return self.a == o.a and self.b == o.b
def __hash__(self):
return hash((self.a, self.b))
def __repr__(self):
return "(%s + %s*sqrt(%d))" % (self.a, self.b, Q.D)
def gt(x, y):
return (Q.lift(x) - Q.lift(y)).sign() > 0
# ---------------------------------------------------------------- parsing
def no_float(s):
raise Fail("floating-point literal %r in certificate" % (s,))
def no_const(s):
raise Fail("non-finite constant %r in certificate" % (s,))
def no_dups(pairs):
d = {}
for k, v in pairs:
need(k not in d, "duplicate key %r in certificate" % (k,))
d[k] = v
return d
def is_int(v):
return isinstance(v, int) and not isinstance(v, bool)
def parse_int_str(s, what):
need(isinstance(s, str), "%s: expected decimal-integer string, got %r" % (what, s))
need(len(s) <= MAX_DIGITS, "%s: integer string too long" % what)
need(INT_RE.match(s) is not None, "%s: not a decimal integer string: %r" % (what, s))
return int(s)
def parse_rat(v, what):
need(isinstance(v, list) and len(v) == 2, "%s: rational must be [num, den]" % what)
num = parse_int_str(v[0], what + " numerator")
den = parse_int_str(v[1], what + " denominator")
need(den > 0, "%s: denominator must be positive" % what)
return Fraction(num, den)
def parse_num(v, what):
need(isinstance(v, list) and len(v) == 2, "%s: number must be a pair [a, b]" % what)
return Q(parse_rat(v[0], what + ".a"), parse_rat(v[1], what + ".b"))
def squarefree(d):
p = 2
while p * p <= d:
if d % (p * p) == 0:
return False
p += 1
return True
# ---------------------------------------------------------------- mathematics
def legendre(n):
"""Coefficient list (low degree first) of P_n via Bonnet:
(k+1) P_{k+1} = (2k+1) x P_k - k P_{k-1}."""
p0 = [Fraction(1)]
if n == 0:
return p0
p1 = [Fraction(0), Fraction(1)]
for k in range(1, n):
nxt = [Fraction(0)] * (k + 2)
for j, c in enumerate(p1):
nxt[j + 1] += (2 * k + 1) * c
for j, c in enumerate(p0):
nxt[j] -= k * c
nxt = [c / (k + 1) for c in nxt]
p0, p1 = p1, nxt
return p1
def peval(coeffs, x):
r = Q(0)
for c in reversed(coeffs):
r = r * x + c
return r
def pi_bounds(terms=12):
"""Rational L < pi < U from Machin: pi = 16 atan(1/5) - 4 atan(1/239).
atan(1/q) = sum_{k>=0} (-1)^k / ((2k+1) q^(2k+1)) is alternating with strictly
decreasing terms, so a partial sum ending on a + term is a strict upper bound and
one ending on a - term is a strict lower bound."""
def atan_inv(q, m): # sum of first m terms
s = Fraction(0)
for k in range(m):
t = Fraction(1, (2 * k + 1) * q ** (2 * k + 1))
s += t if k % 2 == 0 else -t
return s
need(terms % 2 == 0, "internal")
a5_lo, a5_hi = atan_inv(5, terms), atan_inv(5, terms + 1)
a239_lo, a239_hi = atan_inv(239, terms), atan_inv(239, terms + 1)
need(a5_lo < a5_hi and a239_lo < a239_hi, "internal: arctan enclosure inverted")
L = 16 * a5_lo - 4 * a239_hi
U = 16 * a5_hi - 4 * a239_lo
# independent sanity anchors: 3.14159265 < pi < 3.14159266 (and Archimedes 223/71, 22/7)
need(Fraction(223, 71) < L < U < Fraction(22, 7), "pi enclosure fails Archimedes sanity check")
need(Fraction(314159265, 10 ** 8) < L and U < Fraction(314159266, 10 ** 8),
"pi enclosure not tight / wrong")
return L, U
def check(path):
with open(path, "r", encoding="utf-8") as f:
raw = f.read()
need(len(raw) <= 5_000_000, "certificate too large")
try:
cert = json.loads(raw, parse_float=no_float, parse_constant=no_const,
object_pairs_hook=no_dups)
except Fail:
raise
except Exception as e:
raise Fail("certificate is not valid JSON: %s" % e)
need(isinstance(cert, dict), "certificate must be a JSON object")
required = {"n", "d", "nodes", "weights", "conjecture3_index", "conjecture7_index"}
allowed = required | {"statement"}
need(required <= set(cert), "missing fields: %s" % sorted(required - set(cert)))
need(set(cert) <= allowed, "unknown fields: %s" % sorted(set(cert) - allowed))
n, d = cert["n"], cert["d"]
need(is_int(n) and 1 <= n <= MAX_N, "n must be an integer in 1..%d" % MAX_N)
need(is_int(d) and 2 <= d <= 10 ** 12, "d must be an integer >= 2 (and <= 10^12)")
need(squarefree(d), "d = %d is not squarefree" % d)
Q.D = d
need(isinstance(cert["nodes"], list) and len(cert["nodes"]) == n, "nodes must be a list of n numbers")
need(isinstance(cert["weights"], list) and len(cert["weights"]) == n, "weights must be a list of n numbers")
x = [parse_num(v, "nodes[%d]" % (i + 1)) for i, v in enumerate(cert["nodes"])]
w = [parse_num(v, "weights[%d]" % (i + 1)) for i, v in enumerate(cert["weights"])]
i3, i7 = cert["conjecture3_index"], cert["conjecture7_index"]
need(is_int(i3) and 1 <= i3 <= n, "conjecture3_index must be an integer in 1..n")
need(is_int(i7) and 1 <= i7 <= n - 1, "conjecture7_index must be an interior index in 1..n-1")
# --- 1. the nodes are exactly the zeros of P_n, in increasing order
P = legendre(n)
need(len(P) == n + 1 and P[n] != 0, "internal: P_n has wrong degree")
need(peval(P, Q(1)) == Q(1), "internal: P_n(1) != 1")
for i in range(n - 1):
need(gt(x[i + 1], x[i]), "nodes not strictly increasing at position %d" % (i + 1))
for i in range(n):
need(peval(P, x[i]).is_zero(), "nodes[%d] is not a zero of P_%d" % (i + 1, n))
# n distinct zeros of a degree-n polynomial: these are all the zeros of P_n.
print("nodes: %d distinct zeros of P_%d, strictly increasing -> the Gauss-Legendre nodes" % (n, n))
# --- 2. the weights are the Gauss-Legendre weights
# (a) exactness on x^k, k = 0..2n-1 (k = 0..n-1 already determines w uniquely: Vandermonde)
for k in range(2 * n):
s = Q(0)
for i in range(n):
s = s + w[i] * (x[i] ** k)
target = Fraction(2, k + 1) if k % 2 == 0 else Fraction(0)
need(s == Q(target), "rule not exact on x^%d" % k)
# (b) independent cross-check: w_i = 2 / ((1 - x_i^2) P_n'(x_i)^2)
dP = [j * P[j] for j in range(1, n + 1)]
for i in range(n):
dv = peval(dP, x[i])
need(not dv.is_zero(), "internal: repeated root")
need(w[i] == Q(2) / ((Q(1) - x[i] * x[i]) * dv * dv),
"weights[%d] disagrees with 2/((1-x^2)P_n'(x)^2)" % (i + 1))
need(w[i].sign() > 0, "weights[%d] not positive" % (i + 1))
need(sum(w, Q(0)) == Q(2), "weights do not sum to 2")
print("weights: exact for degree <= %d and match the closed formula -> the Gauss-Legendre weights" % (2 * n - 1))
# --- 3. quantities from statement.md
kappa = Fraction(2 * n + 1, 2)
zbar = [Q(-1)]
for i in range(1, n + 1):
zbar.append(zbar[i - 1] + w[i - 1]) # zbar_i = zbar_{i-1} + w_i
need(zbar[n] == Q(1), "zbar_n != 1")
for i in range(1, n + 1): # closed form -1 + sum_{j<=i} w_j
need(zbar[i] == Q(-1) + sum(w[:i], Q(0)), "zbar recurrence/closed form mismatch")
z = [None] + [(zbar[i - 1] + zbar[i]) / 2 for i in range(1, n + 1)]
alpha = [Q(0)]
for i in range(1, n + 1):
alpha.append(alpha[i - 1] - 2 * x[i - 1] * w[i - 1]) # alpha_i = alpha_{i-1} - 2 x_i w_i
for i in range(0, n + 1): # alpha_i = 2 sum_{k=i+1}^n x_k w_k
s = Q(0)
for k in range(i + 1, n + 1):
s = s + x[k - 1] * w[k - 1]
need(alpha[i] == 2 * s, "alpha_%d: the two definitions disagree" % i)
# --- 4. rigorous rational upper bound for pi^2/(12 kappa^2)
L, U = pi_bounds()
B = U * U / (12 * kappa * kappa) # B > pi^2/(12 kappa^2) since 0 < pi < U
print("kappa = %s; using rational B > pi^2/(12 kappa^2)" % kappa)
# --- 5. the two violations
need(z[i3].sign() > 0, "z_%d is not positive (Conjecture 3 ratio must be taken at a positive node)" % i3)
need(x[i3 - 1].sign() > 0, "x_%d is not positive" % i3)
lhs3 = x[i3 - 1] / z[i3] - 1
need(gt(lhs3, B), "Conjecture 3 upper bound is NOT violated at i=%d: x_i/z_i - 1 = %r" % (i3, lhs3))
print("Conjecture 3: x_%d/z_%d - 1 = %r > B > pi^2/(12 kappa^2)" % (i3, i3, lhs3))
den7 = Q(1) - zbar[i7] * zbar[i7]
need(den7.sign() > 0, "1 - zbar_%d^2 is not positive" % i7)
lhs7 = alpha[i7] / den7 - 1
need(gt(lhs7, B), "Conjecture 7 upper bound is NOT violated at i=%d: alpha_i/(1-zbar_i^2) - 1 = %r" % (i7, lhs7))
print("Conjecture 7: alpha_%d/(1 - zbar_%d^2) - 1 = %r > B > pi^2/(12 kappa^2)" % (i7, i7, lhs7))
print("Both strict upper bounds fail for the %d-point Gauss-Legendre rule: "
"Conjectures 3 and 7 are false as stated (for all n)." % n)
def main(argv):
if len(argv) != 2:
print("usage: python3 checker.py certificate.json")
return 1
try:
check(argv[1])
except Fail as e:
print("REJECTED: %s" % e)
return 1
except Exception as e: # any unexpected error is a rejection
print("REJECTED: unexpected error: %s: %s" % (type(e).__name__, e))
return 1
print("VERIFIED")
return 0
if __name__ == "__main__":
sys.exit(main(sys.argv))