restart; with(LinearAlgebra): # Define indeterminates QParam := [q1,q2,q3,q4,q5]: PParam := Matrix([[p1],[p2],[p3],[p4],[p5],[p6]]): # Special Fourier parameterization and inverse F := Matrix([[1,1,1,1,1,1], [1,-1,1,1,-1,1], [1,1/3,-1/3,1/9,-1/9,-1/3], [1,-1,1,-1/3,1/3,-1/3], [1,0,-1,-1,0,1]]): FI := Matrix([ [1/16,1/16,9/16,3/16,1/8], [1/8,-1/8,3/8,-3/8,0], [1/16,1/16,-3/16,3/16,-1/8], [3/16,3/16,3/16,-3/16,-3/8], [3/8,-3/8,-3/8,3/8,0], [3/16,3/16,-9/16,-3/16,3/8] ]): # List of polynomial parametrizations P0 := [ d0^4*f0^5+d0^4*f1^5+3*d0^3*d1*f0^4*f1+d0^3*d1*f0^3*f1^2+d0^3*d1*f0^2*f1^3+3*d0^3*d1*f0*f1^4+6*d0^2*d1^2*f0^3*f1^2+6*d0^2*d1^2*f0^2*f1^3+3*d0*d1^3*f0^4*f1+d0*d1^3*f0^3*f1^2+d0*d1^3*f0^2*f1^3+3*d0*d1^3*f0*f1^4+d1^4*f0^5+d1^4*f1^5, 2*d0^4*f0^4*f1+2*d0^4*f0*f1^4+2*d0^3*d1*f0^4*f1+6*d0^3*d1*f0^3*f1^2+6*d0^3*d1*f0^2*f1^3+2*d0^3*d1*f0*f1^4+12*d0^2*d1^2*f0^3*f1^2+12*d0^2*d1^2*f0^2*f1^3+2*d0*d1^3*f0^4*f1+6*d0*d1^3*f0^3*f1^2+6*d0*d1^3*f0^2*f1^3+2*d0*d1^3*f0*f1^4+2*d1^4*f0^4*f1+2*d1^4*f0*f1^4, d0^4*f0^3*f1^2+d0^4*f0^2*f1^3+d0^3*d1*f0^5+3*d0^3*d1*f0^3*f1^2+3*d0^3*d1*f0^2*f1^3+d0^3*d1*f1^5+6*d0^2*d1^2*f0^4*f1+6*d0^2*d1^2*f0*f1^4+d0*d1^3*f0^5+3*d0*d1^3*f0^3*f1^2+3*d0*d1^3*f0^2*f1^3+d0*d1^3*f1^5+d1^4*f0^3*f1^2+d1^4*f0^2*f1^3, 3*d0^4*f0^4*f1+3*d0^4*f0*f1^4+3*d0^3*d1*f0^5+9*d0^3*d1*f0^3*f1^2+9*d0^3*d1*f0^2*f1^3+3*d0^3*d1*f1^5+12*d0^2*d1^2*f0^4*f1+6*d0^2*d1^2*f0^3*f1^2+6*d0^2*d1^2*f0^2*f1^3+12*d0^2*d1^2*f0*f1^4+3*d0*d1^3*f0^5+9*d0*d1^3*f0^3*f1^2+9*d0*d1^3*f0^2*f1^3+3*d0*d1^3*f1^5+3*d1^4*f0^4*f1+3*d1^4*f0*f1^4, 6*d0^4*f0^3*f1^2+6*d0^4*f0^2*f1^3+6*d0^3*d1*f0^4*f1+18*d0^3*d1*f0^3*f1^2+18*d0^3*d1*f0^2*f1^3+6*d0^3*d1*f0*f1^4+12*d0^2*d1^2*f0^4*f1+24*d0^2*d1^2*f0^3*f1^2+24*d0^2*d1^2*f0^2*f1^3+12*d0^2*d1^2*f0*f1^4+6*d0*d1^3*f0^4*f1+18*d0*d1^3*f0^3*f1^2+18*d0*d1^3*f0^2*f1^3+6*d0*d1^3*f0*f1^4+6*d1^4*f0^3*f1^2+6*d1^4*f0^2*f1^3, 3*d0^4*f0^3*f1^2+3*d0^4*f0^2*f1^3+9*d0^3*d1*f0^4*f1+3*d0^3*d1*f0^3*f1^2+3*d0^3*d1*f0^2*f1^3+9*d0^3*d1*f0*f1^4+6*d0^2*d1^2*f0^5+12*d0^2*d1^2*f0^3*f1^2+12*d0^2*d1^2*f0^2*f1^3+6*d0^2*d1^2*f1^5+9*d0*d1^3*f0^4*f1+3*d0*d1^3*f0^3*f1^2+3*d0*d1^3*f0^2*f1^3+9*d0*d1^3*f0*f1^4+3*d1^4*f0^3*f1^2+3*d1^4*f0^2*f1^3]: # Substitutions based on the model P := P0: P := subs(d0 = 1-d1, 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([ q3*q4-q2*q5, q3^2-q1*q5, 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: