RE : composition of functions



Just a game:

nary("?");
"?"(%%f, %%g) := ratsimp(ratsubst(rhs(%%g), first(args(lhs(%%f))), rhs(%%f)));

h(y) := ''((f(x) := a* x ^ 2 + b * x + c) ? (g(y) := m * y ^ 3 + p));

f1 : g1(x) := 1 + sin(x);
f2 : g2(x) := 1 - sin(x);
ff(x) := ''(f1 ? f2);

Laurent.


> -----Message d'origine-----
> De?: maxima-bounces at math.utexas.edu [mailto:maxima-bounces at math.utexas.edu] De la part de
> Barton Willis
> Envoy??: vendredi 12 septembre 2008 16:06
> ??: Sheldon Newhouse
> Cc?: maxima-help
> Objet?: Re: [Maxima] 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
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima