composition of functions



On Thursday 11 September 2008 22:10:43 Alexey Beshenov wrote:
> Strictly speaking, you deal with expressions, not functions.
> And it looks like a work for "at":
>
> ? (%i1) comp(g,f,x) := at(g,x=f)$
> ? (%i2) comp(sqrt(1-x^2),sqrt(x),x);
> ? (%o2) sqrt(1-x)
> ? (%i3) comp(asin(x),sin(x),x);
> ? (%o3) x

For functions:

  (%i1) comp(g,f,x) := g(apply(f,[x]))$
  (%i2) comp(lambda([x],sqrt(1-x^2)),'sqrt,x);
  (%o2) sqrt(1-x)
  (%i3) comp('asin,'sin,x);
  (%o3) x

-- 
Prickle-Prickle, Bureaucracy 35, 3174 YOLD
Alexey Beshenov http://beshenov.ru/