# ReplaceAll and derivatives

I have the following coming from a computation, $$h_1 (u,v,w) = \frac{1}{v}\partial_v g(u,v,w)$$ and in Mathematica I have different quantities in terms of $h_1$ and its derivatives like $\partial_uh_1$, etc. My problem is to implement the substitution (and analogous ones) in the expressions involving derivatives. Concretely I want to make a rule subst = h1 -> 1/v D[g[u, v, w], v] etc. but, as I was expecting when I try to evaluate D[h1[u, v, w], u] /. subst I get $h_1^{\{0,1,0\}}(u,v,w)$.

Any suggestion?

Reformatting code (thanks to MarcoB) Substitution rules are the following,

rules={h1[u, v, w] -> (1/v)*D[g[u, v, w], v], h2[u, v, w] -> (1/w)*D[g[u, v, w], w]}


then I would like to use the following

ω[1] = reWrite[d[h1] + I*d[φ[1]] - D[h1[u, v, w], u]*(d[u] + I*u*d[φ[3]])];
ω[2] = reWrite[d[h2] + I*d[φ[2]] - D[h2[u, v, w], u]*(d[u] + I*u*d[φ[3]])];


and

reWrite[Sum[A[i]*ω[i]*ωb[i], {i, 1, 2}] + A[0]*(ω[1]*ωb[2] + ωb[1]*ω[2])] /. rules

• Hmm, that looks to be the default way of expressing derivatives; e.g. Derivative[1, 0][f][x, y] for the partial derivative of f[x, y] with respect to x. Why would this be not useful for you? – J. M. is away Jul 6 '16 at 17:59
• Perhaps you should show the actual Mathematica form of those expressions, rather than Latex. See here as well: How to copy code from Mathematica so it looks good on this site. – MarcoB Jul 6 '16 at 18:00
• The problem is the pattern matching. Your rules replace the pattern h1[u, v, w], but what actually appears in your expression are derivatives of h1 which look like, for instance, Derivative[0, 1, 0][f][u, v, w]. To make it work, see for instance here and here. – march Jul 6 '16 at 20:32
• For instance, try this replacement Rule instead: h1 -> (1/#2 Derivative[0, 1, 0][g][#1, #2, #3] &). – march Jul 6 '16 at 20:38
• Code here might apply. – Daniel Lichtblau Jul 6 '16 at 20:44