A little explanation from what I think I understood...
First, you have to make a distinction between functions and expressions :
expression:=x^2+x+1 is an expression
f(x):=x^2+x+1 is a function
The difference beetween these guys is that you can't evaluate expression(2). If you do want, you'll have to call
subst(expression,x=2)
Now you can convert this expression into a function, but be aware that when you define a function with f(x):=expression, the right member is not evaluated : you define f: x --> expression
If you want the expression to be replaced with its value, you want to call unapply : f:=unapply(expression,x). Then you can call f(2)
The same mechanism is in use when you use the diff command : the result of the diff command is an expression
when you type f1:=diff(f(x)), the diff command gives you an expression and you get into trouble. f1:=unapply(diff(f(x)),x) evaluates the diff command and stores the result into the f1 function that is what you want here.
Alternatively, you could use function_diff that gives you in return a function and not an expression :
f1:=function_diff(f)
Edited: 26 Oct 2013, 3:46 a.m.