3
$\begingroup$

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.

$\endgroup$

1 Answer 1

4
$\begingroup$
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 Internal`InheritedBlock to avoid clearing Derivative again and again:

Clear@Derivative

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

Internal`InheritedBlock[{Derivative},
 Derivative[2, n_][g][x, y] := c D[u[y, t], t, {y, n}]; h]
$\endgroup$
2
  • $\begingroup$ +1 Nice. What does Clear@Derivative exactly do here? $\endgroup$
    – Deep
    Oct 1, 2017 at 9:38
  • $\begingroup$ @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. $\endgroup$
    – xzczd
    Oct 1, 2017 at 9:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.