Question: How can I make first derivative as a function with respect to a variable?

Hi,

     I now have a problem.

     I want to calculate first derivative of a function and make it a function with respect to a variable.

     For example,

     f:=x->x^2

     derivative:=x->diff(f,x)

 

     I expect derivative is a function, (i.e.  derivative(x)=2x) , So if I put 'derivative(2)',I should get 4 as results. However I get "Error, (in H_Mag_Derivative_2) invalid input: diff received 2, which is not valid for its 2nd argument".

     Could someone give me a hand? Very much appreciated.

Please Wait...