restart; with(LinearAlgebra): # Define indeterminates QParam := [q1,q2,q3,q4]: PParam := Matrix([[p1],[p2],[p3],[p4],[p5]]): # Special Fourier parameterization and inverse F := Matrix([[1,1,1,1,1], [1,-1/3,-1/3,1,1], [1,3/7,-1/7,-5/7,-1/7], [1,-3/5,1/5,1/5,-3/5]]): FI := Matrix([ [1/16,3/16,7/16,5/16], [3/16,-3/16,9/16,-9/16], [9/16,-9/16,-9/16,9/16], [1/16,3/16,-5/16,1/16], [1/8,3/8,-1/8,-3/8] ]): # List of polynomial parametrizations P0 := [ c0^3*f0^5+c0^3*f1^5+2*c0^2*c1*f0^4*f1+c0^2*c1*f0^3*f1^2+c0^2*c1*f0^2*f1^3+2*c0^2*c1*f0*f1^4+2*c0*c1^2*f0^4*f1+c0*c1^2*f0^3*f1^2+c0*c1^2*f0^2*f1^3+2*c0*c1^2*f0*f1^4+c1^3*f0^5+c1^3*f1^5, 3*c0^3*f0^4*f1+3*c0^3*f0*f1^4+9*c0^2*c1*f0^3*f1^2+9*c0^2*c1*f0^2*f1^3+9*c0*c1^2*f0^3*f1^2+9*c0*c1^2*f0^2*f1^3+3*c1^3*f0^4*f1+3*c1^3*f0*f1^4, 9*c0^3*f0^3*f1^2+9*c0^3*f0^2*f1^3+9*c0^2*c1*f0^4*f1+18*c0^2*c1*f0^3*f1^2+18*c0^2*c1*f0^2*f1^3+9*c0^2*c1*f0*f1^4+9*c0*c1^2*f0^4*f1+18*c0*c1^2*f0^3*f1^2+18*c0*c1^2*f0^2*f1^3+9*c0*c1^2*f0*f1^4+9*c1^3*f0^3*f1^2+9*c1^3*f0^2*f1^3, c0^3*f0^3*f1^2+c0^3*f0^2*f1^3+c0^2*c1*f0^5+2*c0^2*c1*f0^4*f1+2*c0^2*c1*f0*f1^4+c0^2*c1*f1^5+c0*c1^2*f0^5+2*c0*c1^2*f0^4*f1+2*c0*c1^2*f0*f1^4+c0*c1^2*f1^5+c1^3*f0^3*f1^2+c1^3*f0^2*f1^3, 2*c0^3*f0^4*f1+2*c0^3*f0*f1^4+2*c0^2*c1*f0^5+2*c0^2*c1*f0^4*f1+2*c0^2*c1*f0^3*f1^2+2*c0^2*c1*f0^2*f1^3+2*c0^2*c1*f0*f1^4+2*c0^2*c1*f1^5+2*c0*c1^2*f0^5+2*c0*c1^2*f0^4*f1+2*c0*c1^2*f0^3*f1^2+2*c0*c1^2*f0^2*f1^3+2*c0*c1^2*f0*f1^4+2*c0*c1^2*f1^5+2*c1^3*f0^4*f1+2*c1^3*f0*f1^4]: # Substitutions based on the model P := P0: P := subs(c0 = 1-c1, P): P := subs(f0 = 1-f1, P): # Check that the polynomial parametrization lies in the probability simplex suma := 0: for i from 1 to nops(P) do suma := suma + P[i]: od: normal(expand(suma)); # Ideal of Invariants in Fourier coordinates Invariants := Matrix([ q2*q3-q1*q4]): # Ideal of Invariants in probability coordinates Fourier := MatrixMatrixMultiply(F,PParam): PInvariants := Invariants: for i from 1 to nops(QParam) do PInvariants := subs(QParam[i] = Fourier[i, 1], PInvariants): od: # Evaluation of Invariants at the polynomial/rational parametrization num := op(PInvariants[1,1..-1])[1]: for j from 1 to num do coordpoly := PInvariants[1, j]: for i from 1 to op(PParam[1..-1,1])[1] do coordpoly := subs(PParam[i, 1] = P0[i], coordpoly): od: coordpoly :=expand(coordpoly): lprint(j,coordpoly); od: