program.py

back to table · edit · history · where entries came from · files · download

921 bytes, as of the version from 2026-10-28 22:59 (current). Recorded here, not run.

# Run with SageMath's Python. The letter m denotes the parameter mu.
import numberdb.sage as numberdb
from sage.rings.integer_ring import ZZ
from sage.rings.rational_field import QQ
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing

R = PolynomialRing(QQ, names=('x', 'm'))
Z = PolynomialRing(ZZ, names=('x', 'm'))
x, m = R.gens()

def umemura(n):
    if n < 0 or n != int(n):
        raise ValueError('n must be a nonnegative integer')
    previous = current = R.one()
    for k in range(int(n)):
        d = current.derivative(x)
        numerator = (x+m)*current**2 - x*(current*d.derivative(x)-d**2) - current*d
        following, remainder = numerator.quo_rem(previous)
        assert remainder == 0
        previous, current = current, following
    return Z(current)

polynomials = {n: umemura(n) for n in range(6)}
umemura(6)  # Compute the next polynomial with the same normalization.