import numberdb.sage as numberdb
from sage.rings.integer_ring import ZZ
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
R = PolynomialRing(ZZ, "x")
x = R.gen()
def shapiro_pair(n):
P = R.one()
Q = R.one()
for k in range(n):
P, Q = P + x**(2**k)*Q, P - x**(2**k)*Q
return P, Q
shapiro_pair(8)[0] # the next polynomial after this tableThe generator computes $P_n$ and $Q_n$ by the exact recurrence in $\mathbb Z[x]$.