I am taking the derivative of a function with respect to another function, e.g.


This outputs g'(f(x,y)), as expected. How can I specify a rule for this derivative?

I've tried the following:

Derivative[g[f[x_,y_]][f[x_, k_]]] := f[y, k]

but apparently this isn't the output of D[].

Any ideas?

  • $\begingroup$ Try: Derivative[g[f[x_, y_]][f[x_, k_]]] := g'[f[y, k]] $\endgroup$ Jan 29, 2023 at 13:20
  • $\begingroup$ This doesn't appear to do anything.... $\endgroup$
    – Akoben
    Jan 29, 2023 at 14:04

1 Answer 1


Assuming that you have a random expression

expr = D[g[f[x, y]], f[x, y]] + 2 x + 2 f[x, y] + g[f[x, y]] + 
   Log[D[g[f[x, y]], f[x, y]]];

that looks like this



you can write a replacement rule like so:

rule = Derivative[1][g][f[x, y]] -> 
    HHH[x, y]; 

and then

expr /. rule



To understand the above, I suggest that you take a look at the FullForm of the expression for which you wanted to set a rule originally, i.e D[g[f[x, y]], f[x, y]] // FullForm


Your Answer

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

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