P = PolynomialRing(QQ, 'x', 6) xs = x0,x1,x2,x3,x4,x5 = P.gens() def act_single(g, p): return p.subs({xs[i-1]: xs[j-1] for i, j in g.dict().items()}) def act_all(G, p): return [act_single(g, p) for g in G] G = PermutationGroup([[(2,4,6,5,3)], [(1,2),(3,5),(4,6)]]) p = x0^2 + x0*x1 print(G[:10]) print(act_all(G, p)[:10])