composition of functions



-----maxima-bounces at math.utexas.edu wrote: -----


>msubst(list,expr):=
>  block([lv: listofvars(expr), ft: expr],  if length(lv)#length(list)
>then print("Error: number of variables in",list,"must equal number of
>variables in, expr") else
>  for i:1    thru length(lv) do ft: subst(lv[i]=list[i],ft),
>   return(ft))$

By the way, listofvars doesn't return a sorted list:

(%i8) listofvars(a[a] + a);
(%o8) [a,a[a]]

(%i9) listofvars(a[a] + cos(a));
(%o9) [a[a],a]

So, I think the first argument to msubst should be a list of
substitutions (for example [x=u+v,y=u-v]), or msubst should take
another argument that is the list of variables. Either way, msubst
becomes little more than a call to subst.

Another thing: msubst should locally assign listconstvars to false.

Barton