# 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(g[`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, gg, subsgg; 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 gg[i] := expand(coeff(pol2,x,i)) od; subsgg := g[0]=gg[0]; for i from 1 to (N-1) do subsgg := subsgg , g[i]=gg[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]*(g[0]*(-1)^N)^(arr[N]); for i from 1 to (N-1) do monom := monom * (g[i]*(-1)^(N-i))^(arr[N-i] - arr[N-i+1]) od; monom; end: gpolyutil[onesymm] := proc(expr,N) local remains, gexpr, newg, newgg; if gpolyutil[checkonesym](expr,N) = false then NOTSYM else gpolyutil[onesymminit](N); remains := expand(expr); gexpr :=0; while remains <> 0 do newg := gpolyutil[conv](gpolyutil[gethigh](remains,N),N); gexpr := gexpr + newg; newgg := subs(subsgg , newg); remains := expand( remains - newgg) od; gexpr; 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: gpolyutil[onesymvar] := proc(expr,vlist) local i, newexpr, N, subsgtoa; N := nops(vlist); subsgtoa := []; for i from 0 to N do subsgtoa := [op(subsgtoa),g[i]=(-1)^(i+N)*a[N-i]/a[0]] od; newexpr := expr; for i from 1 to N do newexpr := subs( vlist[i] = w[i] , newexpr) od; newexpr := gpolyutil[onesymm](newexpr,N); newexpr := subs(subsgtoa, newexpr); newexpr := normal(%,expanded); while not type(newexpr, polynom) do newexpr := a[0]*newexpr od; newexpr; end: with(gpolyutil);