I have sets of functions of material parameters where the first input argument denotes the material. Here's a simple version:
tf1["a", x_] = x^3; tf1["b", x_] = x^4; Now, I'd like to make a function which needs the derivative of tf1 with respect to x. My goal is the following:
myderivative["a",x]=3 x^2
myderivative["b",x]=4 x^3
The way to implement this should be something like
myderivative[i_, x_] = Derivative[2][tf1[i, #] &][x] myderivativeb[i_, x_] = Derivative[0, 2][tf1][i, x] I even tried
tf2[i_] = tf1[i, #] & myderivative2[i_, x_] = Derivative[2][tf2[i]][x] But all of the variants return
(tf1^(0,2))[i,x] I tried using SetDelayed (:=) in all of the above variants but this doesn't return anything else. Also, approaches with D or [Esc] pd [Esc] failed.
So how do I take the derivative of this overloaded function? It should also work with distinct numbers, e.g. I expect
myderivative["a",2]=12
der[i_, x_] := D[tf1[i, x], x]worked for me? $\endgroup$tf1has a first variable, you should define it as:tf1[myname_?String, x_]and define the specific functions formyname = "a"and"b". $\endgroup$der["a",3], for example. There's an error "General::ivar" $\endgroup$