# Replace a derivative within partial derivatives

Suppose:

f = a + b g[x, y]
h = D[f, {x, 2}, {y, 1}]
(*Out:= b g^(2,1)[x,y]*)

1. In the function $h=b\frac{\partial^3g}{\partial x^2\partial y}$ I want to replace $\frac{\partial g}{\partial y}$ by $c\frac{\partial u}{\partial t}$ to obtain $h=bc\frac{\partial^3u}{\partial x^2\partial t}$.

2. In the function $h=b\frac{\partial^3g}{\partial x^2\partial y}$ I want to replace $\frac{\partial^2 g}{\partial x^2}$ by $c\frac{\partial u}{\partial t}$ to obtain $h=bc\frac{\partial^2u}{\partial y\partial t}$.

After looking at the Fullform of partial derivatives this seems like a hopeless task. I have also read this post but it hasn't helped. Any suggestions and help is much appreciated.

Clear@Derivative
Derivative[n_, 1][g][x, y] := c D[u[x, t], {x, n}, t]
h
Clear@Derivative
Derivative[2, n_][g][x, y] := c D[u[y, t], t, {y, n}]
h


You can use InternalInheritedBlock to avoid clearing Derivative again and again:

Clear@Derivative

InternalInheritedBlock[{Derivative},
Derivative[n_, 1][g][x, y] := c D[u[x, t], {x, n}, t]; h]

InternalInheritedBlock[{Derivative},
Derivative[2, n_][g][x, y] := c D[u[y, t], t, {y, n}]; h]

• +1 Nice. What does Clear@Derivative exactly do here? – Deep Oct 1 '17 at 9:38
• @Deep Otherwise the rule we created via Derivative[2, n_][g][x, y] := c D[u[y, t], t, {y, n}] etc. will remain. Try removing Clear@Derivative and execute SubValues@Derivative` and you'll know what I mean. – xzczd Oct 1 '17 at 9:44