restart; with(LinearAlgebra): # Define indeterminates QParam := [q1,q2,q3]: PParam := Matrix([[p1],[p2],[p3]]): # Special Fourier parameterization and inverse F := Matrix([ [1,1,1], [1,1/5,-1/5], [1,-3/5,1/5]]): FI := Matrix([ [1/16,5/8,5/16], [5/16,5/8,-15/16], [5/8,-5/4,5/8]]): # List of polynomial parametrizations P0 := [ e0^5+e1^5, 5*e0^4*e1+5*e0*e1^4, 10*e0^3*e1^2+10*e0^2*e1^3]: # Substitutions based on the model P := P0: P := subs(e0 = 1-e1, 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^2-q1*q3]): # 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: