import numberdb.sage as numberdb
from sage.matrix.constructor import matrix
from sage.modules.free_module_element import vector
from sage.rings.rational_field import QQ
def adams_moulton_coefficients(s):
nodes = list(range(s + 1))
rows = [[QQ(j) ** m for j in nodes] for m in range(s + 1)]
rhs = [(QQ(s) ** (m + 1) - QQ(s - 1) ** (m + 1)) / QQ(m + 1)
for m in range(s + 1)]
return dict(zip(nodes, matrix(QQ, rows).solve_right(vector(QQ, rhs))))
adams_moulton_coefficients(3)The generator builds the moment equations over $\mathbb{Q}$ for the nodes $0,1,\ldots,s$ and solves them exactly.
Each completed method is checked against the defining moments, the integral formula for the Lagrange basis polynomials, the displayed Adams–Moulton formulas through $s=4$ in [1], OEIS A260781 and A235936, and the Gregory-coefficient identity stated in the Formulas section.