Bug fix: Problems with unapply
The function unapply , which constructs a procedure from an expression, has three major shortcomings, listed below. To correct them, I have written the alternative procedure vnapply .
> f:=unapply(vector([1,x,x^2]), x):
> f(t);
Here it is with vnapply :
>
readlib(vnapply):
f:= vnapply(vector([1,x,x^2]), x);
> f(t);
> unapply(diff(g(x),x), x);
Unfortunately, unapply fails to do this in slightly more complicated circumstances.
> unapply(2*diff(g(x),x), x);
Here it is with vnapply :
> vnapply(2*diff(g(x),x), x);
> f:= unapply((x+1)^2,x);
> whattype(f);
In most cases this behaviour is harmless: applying f to any argument v will result in , as it should.
> f(q+1);
However, one place it will not work is in the evalhf environment:
> evalhf(f(3));
Error, unable to evaluate function `f` in evalhf
Here it is using vnapply :
> g:= vnapply((x+1)^2,x);
> evalhf(g(3));
See also: array , D , diff , evalhf , table , unapply , vnapply
Maple Advisor Database, R. Israel 1998