substitutions within a function



When the Maxima evaluator encounters f(x), it first checks whether f
has a function-value.  If so, it uses that function-value.  If not, it
evaluates f as a symbol, and tries to use *that* value as a function.

So:

         f: x+1$
         f(t)

tries to apply (x+1) to the argument t; but (x+1) is not a function.

The purpose of this evaluation is to support things like

       foo(f,x):= f(x-1)$
       foo(sqrt,y^2) => sqrt(y^2-1)

Personally, I'd prefer to make that syntactically different, e.g.
(f)(x-1) (which also works), but....

            -s
On 1/10/07, Daniel Lakeland <dlakelan at street-artists.org> wrote:
> I know there's something I don't understand about maxima
> evaluation... I have an expression "fma_steady" and I want to create a
> function which has 2 parameters which returns the result of
> substituting those parameters into the expression fma_steady.
>
> Residfma(h,v) := block([expr:subst(v,vx(x), subst(h,h(x),lhs(fma_steady)))],
>   ev(expr,diff));
>
> Here's what happens when I call it with an example set of arguments:
>
> (%i54) Residfma(1+a*x,1+b*x);
>
> h evaluates to a*x+1
> Improper name or value in functional position.
> #0: Residfma(h=a*x+1,v=b*x+1)
>  -- an error.  Quitting.  To debug this try debugmode(true);
>
> what's going on?
>
>
> --
> Daniel Lakeland
> dlakelan at street-artists.org
> http://www.street-artists.org/~dlakelan
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>