restart; with(LinearAlgebra): # Define indeterminates QParam := [q1,q2,q3,q4,q5,q6,q7,q8]: PParam := Matrix([[p1],[p2],[p3],[p4],[p5],[p6],[p7],[p8]]): # Special Fourier parameterization and inverse F := Matrix([ [1,1,1,1,1,1,1,1], [1,-1,-1,1,1,-1,-1,1], [1,-1,1,-1,-1,1,-1,1], [1,1,-1,-1,-1,-1,1,1], [1,-1,1,-1,1,-1,1,-1], [1,1,-1,-1,1,1,-1,-1], [1,1,1,1,-1,-1,-1,-1], [1,-1,-1,1,-1,1,1,-1]]): FI := Matrix([ [1/8,1/8,1/8,1/8,1/8,1/8,1/8,1/8], [1/8,-1/8,-1/8,1/8,-1/8,1/8,1/8,-1/8], [1/8,-1/8,1/8,-1/8,1/8,-1/8,1/8,-1/8], [1/8,1/8,-1/8,-1/8,-1/8,-1/8,1/8,1/8], [1/8,1/8,-1/8,-1/8,1/8,1/8,-1/8,-1/8], [1/8,-1/8,1/8,-1/8,-1/8,1/8,-1/8,1/8], [1/8,-1/8,-1/8,1/8,1/8,-1/8,-1/8,1/8], [1/8,1/8,1/8,1/8,-1/8,-1/8,-1/8,-1/8]]): # List of polynomial parametrizations P0 := [ a0*b0*c0*d0+a1*b1*c1*d1, a0*b1*c0*d0+a1*b0*c1*d1, a0*b0*c0*d1+a1*b1*c1*d0, a0*b1*c0*d1+a1*b0*c1*d0, a0*b0*c1*d0+a1*b1*c0*d1, a0*b1*c1*d0+a1*b0*c0*d1, a0*b0*c1*d1+a1*b1*c0*d0, a0*b1*c1*d1+a1*b0*c0*d0]: # Substitutions based on the model P := P0: P := subs(a0 = 1-a1, P): P := subs(b0 = 1-b1, P): P := subs(c0 = 1-c1, P): P := subs(d0 = 1-d1, 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([ q4*q5-q3*q6, q4*q5-q2*q7, q4*q5-q1*q8]): # 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: