I am trying to convert Mathematica output into equations I can plug into C. I am presently trying to convert expressions of the form
Derivative[1,0,0][f][t,x,y]
where f is function with an arbitrary name (e.g. it may be called f, g, func, etc), into expressions of the form
f_Dt
where f is the symbol for the original function, e.g. I want the general rule to map Derivative[1,0,0][g][t,x,y] to g_Dt as well. Is there a way of doing this? For example, applying
expression/.{Derivative[1,0,0][f_][t,x,y]->f_Dt}
(where "expression" is arbitrary) doesn't work.
To expand the scope of this question, more generally I would like to transform
Derivative[1,0,0][f][t,x,y]
to not just f_Dt, but also expressions like
f$D
or
fD
(i.e. expressions that don't just include the underscore after f).
Derivative[1,0,0][f][t,x,y]thenDerivative[1,0,0][f_][T,R,Y]clearly won't match that. Maybe you wantedDerivative[1,0,0][f_][a_, b_, c_]? By the way, why are you trying to transform it into something that looks likef_Dy? If you look at theFullForm[f_Dy]you getPattern[f, Blank[Dy]]which is a pattern matching object and thus something that can't be used as a function name or anything like that. – b3m2a1 Dec 11 '19 at 18:34expressionwhere this fails? I'm almost certain your pattern just isn't quite flexible enough for what you want. Like you expect one form of the pattern but it turns out you have a different one. – b3m2a1 Dec 11 '19 at 18:48Derivative[1, 0, 0][foo][t, x, y] /. {Derivative[1, 0, 0][f_][t, x, y] :> f_Dt}yieldsfoo_Dtalong with a warning message that in this case can be ignored. – Mr.Wizard Dec 11 '19 at 20:25Patternon the right side of a Rule; it's a common mistake like using=in place of==withinSolve. However if that is actually what one wants it can be safely ignored; see (210799) for example. – Mr.Wizard Dec 19 '19 at 15:10"f_Dt"instead of plainf_Dtwhich is interpreted by Mathematica as a pattern namedfwith headDt. – QuantumDot Dec 19 '19 at 19:50