Problem with diff



On Qui, 2009-06-18 at 18:23 +0200, Holger Schulz wrote:
> I want to make the derivate of a function a function itself. Naively
> i  
> tried
> 
> f(x):=-2*x^3+3*x^2+12*x-13;
> 
> and
> 
> f1(x):=diff(f(x),x);
> 
> which did not work:
> 
> (%i16) f1(1);
> diff: second argument must be a variable; found 1
> #0: f1(x=1)
>   -- an error.  To debug this try debugmode(true);

That's a FAQ. If fails because := does not force the derivative to be
evaluated; an attempt at its evaluation is only made when you write
f1(1). Use "define" instead of :=

f(x):=-2*x^3+3*x^2+12*x-13;
define(f1(x),diff(f(x),x));
f1(1);

Regards,
Jaime