Problem with diff



Dear Holger,

Re:

> (%i1) f(x) := x^2 - 3*x;
> (%i4) f1(x) := diff(f(x),x);
> (%i8) f1(2);
>

f1(2) means "evalute the body of the function with x=2", that is,
diff(f(2),2), which is of course meaningless.  If you want to define a
function f1 which is the derivative of the function f, you need to write

        f1(x) := ''(diff(f(x),x))$

where '' are two single-quotes (not one double-quote).  The two-single-quote
construction evaluates its body *at the time of definition*.  Of course,
this means that if you redefine f, f1 will not change.

As a general rule, Maxima is set up better to deal with *formulae* than with
named functions.  Thus the more convenient way to deal with your problem
would be:

    f: x^2-3*x$                 f has a value which is a formula
    f1: diff(f,x)$               f1's value is also a formula, 2*x
    subst(x=2,f1) => 4
or
    ev(f1,x=2) => 4           (beware, ev can be tricky)

I trust this is useful.

          -s