# write function in singles of variables in terms of elementary # symmetric polynomials... # # originally by with minor alterations by # gpolyutil[g3onesymmp] := proc(poly::polynom) local i; subs(seq(f[`i`]=(-1)^(1+`i`)*p[2-`i`],`i`=0..2), gpolyutil[onesymm](subs(seq(x[`i`]=w[`i`],`i`=1..3),poly),3)); end: gpolyutil[checkonesym] := proc(expr,N) local i, check, exprr; check := true; exprr := expand(expr); i:=2; while check = true and i < (N+1) do if subs({w[1]=w[i],w[i]=w[1]},exprr) <> exprr then check:=false fi; i := i+1 od; check end: gpolyutil[onesymminit] := proc(N) local i,x, # dummy variables pol1, # pol1 will be (x-w[1])*...*(x-w[n]) pol2; # pol2 will be pol1 expanded, with coefficients of x collected. global ww, ff, subsff; pol1 := 1; for i from 1 to N do pol1 := pol1 * (x-w[i]) od; pol2 := collect(pol1,x); for i from 0 to N-1 do ff[i] := expand(coeff(pol2,x,i)) od; subsff := f[0]=ff[0]; for i from 1 to (N-1) do subsff := subsff , f[i]=ff[i] od; ww := [w[1]]; for i from 2 to N do ww := [ op(ww), w[i] ] od; end: gpolyutil[gethigh] := proc(expr, N) local i, exprr , highlex , lead , t; exprr := collect( expr , ww); # this collects coeffs of w[1],..,w[N] lead[1] := lcoeff ( exprr , w[1] ,'t'); if t=1 then highlex :=0 elif nops(t)=1 then highlex :=[1] else highlex := [op(2,t)] fi; for i from 2 to N do lead[i-1] := collect ( lead[i-1] , w[i] ); lead[i] := lcoeff( lead[i-1] , w[i] , 't'); if t=1 then highlex := [op(highlex),0] elif nops(t) = 1 then highlex := [op(highlex),1] else highlex :=[op(highlex),op(2,t)] fi od; highlex := [op(highlex), lead[N] ]; end: gpolyutil[conv] := proc(arr,N) local i, monom; monom := arr[N+1]*(f[0]*(-1)^N)^(arr[N]); for i from 1 to (N-1) do monom := monom * (f[i]*(-1)^(N-i))^(arr[N-i] - arr[N-i+1]) od; monom; end: gpolyutil[onesymm] := proc(expr,N) local remains, fexpr, newf, newff; if gpolyutil[checkonesym](expr,N) = false then NOTSYM else gpolyutil[onesymminit](N); remains := expand(expr); fexpr :=0; while remains <> 0 do newf := gpolyutil[conv](gpolyutil[gethigh](remains,N),N); fexpr := fexpr + newf; newff := subs(subsff , newf); remains := expand( remains - newff) od; fexpr; fi end: gpolyutil[onesym] := proc(expr,vlist) local i, newexpr, N; N := nops(vlist); newexpr := expr; for i from 1 to N do newexpr := subs( vlist[i] = w[i] , newexpr) od; gpolyutil[onesymm](newexpr,N) end: