Sorry, this is a bug. I don't think I'll be able to look into a fix this
weekend, though....
(%i2) subst(lambda([x],x),f,f(x));
(%o2) x
(%i3) subst(lambda([x],x),f[1],f[1](x));
(%o3) lambda([x],x)(x)
Another bug:
(%i5) lambda([x],x)[y];
lambda: cannot apply lambda as an array function. <<< this is
correct
-- an error. To debug this try: debugmode(true);
(%i6) subst(lambda([x],x),f,f[x]);
(%o6) x <<< this should give the same error as the above
-s
On Fri, Apr 22, 2011 at 12:26, Derek Thomas <derekcthomas at gmail.com> wrote:
> I'm trying to use lambda functions to replace instances of pderivop
> from the pdiff package and I've encountered some inconsistent
> behavior.
> Here's my workflow,
>
> in > load(pdiff);
>
> in > f(x);
> out> f(x)
>
> If I use subst on an operator everything works fine.
> in > subst(g,f,%);
> out> g(x)
>
> if I use a lambda function to substitute for an operator it works fine too.
> in > subst(lambda([y], y*h(y)), g,%);
> out> x * (h(x)
>
> Now with pderivop.
> I can use subst to replace an instance of pderivop with another operator.
> in > diff(h(x),x);
> out> pderivop(h,1)(x)
> in > subst(f, pderivop(h,1),%);
> out> f(x)
>
> If I try to replace an instance of pderivop with a lambda function,
> the lambda function doesn't get applied correctly.
> in > diff(g(x),x);
> out> pderivop(g,1)(x)
> in > subst(lambda([y],y*k(y)), pderivop(h,1),%);
> out> lambda([y], y*k(y))(x)
>
> I can get around this by using an intermediate function.
>
> in > diff(g(x),x);
> out> pderivop(g,1)(x)
> in > subst(tempFunction, pderivop(h,1),%);
> out> tempFunction(x)
> in > subst(lambda([y],y*k(y)), tempFunction,%);
> out> x*k(x)
>
> If anyone can tell me what I'm doing wrong, or help me understand
> what's going on here, that would be great. Thanks,
>
> Derek
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>