g(x):=diff(f(x), x);g(1);



[Jorge Barros de Abreu , Sun, 17 Apr 2005 15:31:21 -0300]:
> Hi for All.
>
> What the correct form to make it:
>
> f(x):=x^2;
> g(x):=diff(f(x), x);
> g(1);

Another variation:

,----
| (%i1) f(x):=x^2$
|
| (%i2) g(x):= block([xx], subst(x, xx, diff(f(xx),xx)));
|
| (%o2)               g(x) := BLOCK([xx], SUBST(x, xx, DIFF(f(xx), xx)))
| (%i3) g(2);
|
| (%o3)                                        4
`----

This differentiates anew whenever g is called, so that a change of
definition in f affects g:

,----
| (%i5) f(x) := x^3;
|
|                                                  3
| (%o5)                                   f(x) := x
| (%i6) g(2);
|
| (%o6)                                       12
`----

Albert.