#
# toddp(f) converts a symmetric function f in the omega algebra into a
#  polynomial function of p1,p3,p5,...
# toddp(f,'b'), where 'b' is one of the names q, P[] or Q[], will
#  assume that f is expressed in base b.
#
`QF/toddp`:=proc() local z,i,hack,d,poly,b;
  if nargs>1 then b:=args[2] else b:=NULL fi;
  if b<>'q' then  poly:=QF['toq'](args) else poly:=args[1] fi;
  d:=SF['varset'](poly,'q');
  hack:=convert([seq(cat('p',i)*(1-(-1)^i)*z^i/i,i=1..d)],`+`);
  hack:=taylor(exp(hack),z,d+1);
  poly:=subs({seq(cat('q',i)=coeff(hack,z,i),i=1..d)},poly);
  collect(poly,[seq(cat('p',i),i=1..d)],'distributed',normal);
end:
#
save `QF/toddp`, cat(HomeLib,`/QF/toddp.m`);
read cat(HomeLib,`/help/QF/toddp`);
quit;

