Re: Replace in operators
- To: mathgroup at smc.vnet.net
- Subject: [mg102894] Re: Replace in operators
- From: Albert Retey <awnl at gmx-topmail.de>
- Date: Wed, 2 Sep 2009 03:58:42 -0400 (EDT)
- References: <h7ijns$i5a$1@smc.vnet.net>
did wrote: > I can't figure out how to force Mathematica to replace > f[x] by g[x] in expressions involving operators. > For example: > > f[x] + D[f[x],x] /. f[x] -> g[x] > > f is not replaced in the derivative. I found > somewhere in the manual that the replacement > does not work on operators, but then it does > not indicate how to do it. > > In my real problem, f[x]->g[x] is a (long) > list of complicated transformations resulting > from the resolution of many equations. > Thus, changing f[x]->g[x] by f->g is not > an option. > > f[x] + D[f[x],x] is actually a complicated > expression involving many operators. > > There are no ways I can do the > substitution by hand, bit by bit. > > Any suggestions ? As you can see from this: D[f[x], x] // FullForm Derivative[1][f][x] there is just no f[x] that could be matched. One thing you could try is to replace the occurrences of Derivative with something where an explicit form f[x] can be replaced and replace back the derivatives after your replacements, e.g.: f[x] + D[f[x], x] /. Derivative[n__][f_][args__] -> dd[{n}, f[args]] /. f[x] -> g[x] /. dd[{n__}, f_[args__]] :> Derivative[n][f][args] this should be working with more complicated cases than just single derivatives of functions of one argument, but it's not tested and you should check that it covers the cases you need... hth, albert