############################################################################# ## ## ## sympol.g Meinolf Geck ## ## ## ## Material zur Algebra-Vorlesung Uni Stuttgart, Wintersemester 2020/21 ## ## ## ## This files contains a GAP function for implementing the Main Theorem ## ## on symmetric polynomials in n variables, for any positive integer n. ## ## ## ## Example with 4 variables: ## ## ## ## gap> x:=PolynomialRing(Rationals,4); ## ## gap> f:=(x.1^3+x.2^3+x.3^3+x.4^3)^2; ## ## gap> HauptsatzSymPol(x,f); ## ## ## ## returns the polynomial g in four variables such that f=g(s1,s2,s3,s4) ## ## where s1, s2, s3, s4 are the elementary symmetric polynomials. ## ## ## ## If the input polynomial is not symmetric, then an error message will ## ## be returned. To provide examples, the function 'DeltaPol' returns the ## ## (symmetric) polynomial given by the product of all (X_i-X_j)^2 where ## ## i x:=PolynomialRing(Rationals,3); ## ## gap> HauptsatzSymPol(x,DeltaPol(x)); ## ## #I Steps for polynomial g: ..... ## ## #I Test OK ! ## ## -4*x_1^3*x_3+x_1^2*x_2^2+18*x_1*x_2*x_3-4*x_2^3-27*x_3^2 ## ## ## ############################################################################# # This function computes the Delta polynomial. DeltaPol:=function(x) local d,i,j,n,inds; inds:=IndeterminatesOfPolynomialRing(x); n:=Length(inds); d:=inds[1]^0; for i in [1..n] do for j in [i+1..n] do d:=d*(inds[i]-inds[j])^2; od; od; return d; end; # This function computes the d-th elementary symmetric polynomial. ElementarySymmetric:=function(x,d) local inds,f,c; inds:=IndeterminatesOfPolynomialRing(x); f:=0*inds[1]; for c in Combinations(inds,d) do f:=f+Product(c); od; return f; end; # This is the main function, where 'x' is a polynomial ring and f in x. # The variables in this polynomial ring are called 'x.1', 'x.2', etc. # (If, instead of 'x', a different symbol for the polynomial ring is # used, then the names for the variables change accordingly.) HauptsatzSymPol:=function(x,f) local ff,inds,n,lt,lt1,mon,i,e,g,g1,vg,h,sp; inds:=IndeterminatesOfPolynomialRing(x); n:=Length(inds); sp:=List([1..n],i->ElementarySymmetric(x,i)); ff:=ShallowCopy(f); g:=0*f; Print("#I Steps for polynomial g: \c"); while ff<>0*ff do lt:=LeadingTermOfPolynomial(ff,MonomialGrlexOrdering()); lt1:=ExtRepPolynomialRatFun(lt); mon:=lt1[1]; e:=0*[1..n+1]; for i in [1..Length(mon)/2] do e[mon[2*i-1]]:=mon[2*i]; od; if ForAny([1..n-1],i->e[i]f then Print(" --------> SOMETHING IS WRONG ! <--------\n"); return false; else Print("#I Test OK !\n"); return g; fi; end; # Remark: Internal representation of polynomials by tuples: # x:=PolynomialRing(Rationals,2); # f:=-3*x.1^3*x.2+17*x.1*x.2^2+1-5*x.2^100; # ExtRepPolynomialRatFun(f); # There is a problem with 'Value' for constant multivariate polynomials(??)