how can we take the derivative of something then use it in an expression like
g := t->diff(f(t),t);
this fails because maple does not first take the derivative then apply t, but applies the value of t then tries to differentiate with respect to that value symbolically.
To solve this I usually have to precompute the differential, then copy and paste it. The problem with this method is that any time the original function changes, everything needs to be redone, which can be time consuming.
Is there a better way?
Using the
Doperator you can assign the "derivative" of the operatorftog, without having first assigned anything tof.You can subsequently assign and reassign different operators to
f, after whichgcan be called. Callinggin the example below will not causefto be called with any symbolic argument.Another way to do it is as follows. Note that with this methodology every call to
gwill cause Maple to calldiffon the symbolic localT. If -- after assigning tof-- you callgmany times then that will be more expensive (even if just for the overhead of checking a memoized result and making the extra function call todiff). Also, yourfmay be something which is not even set up to return appropriately for a non-numeric argument, so the call tof(T)might be problematic.The
Doperator is pretty useful. You could check out its help page.