from sage.all import ZZ, PolynomialRing
m = 2
n = 3
R = PolynomialRing(ZZ, ["a%s" % i for i in range(m)] + ["b%s" % j for j in range(n)])
gens = R.gens()
a = gens[:m]
b = gens[m:]
S = PolynomialRing(R, "x")
x = S.gen()
f = x**m + sum(a[i] * x**i for i in range(m))
g = x**n + sum(b[j] * x**j for j in range(n))
print(f.resultant(g))The generator computes exact integer coefficients in polynomial rings over $\mathbb Z$ from the resultant, and all arithmetic is exact.
It checks Formula (1) by substituting the elementary symmetric polynomials of independent roots, compares the small rows from Formula (4), Formula (5), and Formula (6) against the stored values, compares every stored row with an independently assembled Sylvester determinant, and compares integer specializations with Sage's exact univariate resultant over $\mathbb Z[x]$.