Is there a way to define in Mathematica a generic differentiable function $g:\mathbb{R}^2\rightarrow \mathbb{R}$ in such a way that when it computes the derivatives of a composed function involving $g$ it leaves indicated the derivatives of $g$ instead of actually computing them?

I'll explain myself better with an example:

Suppose we have defined this "generic" $g:\mathbb{R}^2\rightarrow \mathbb{R}$ and we have defined $F:\mathbb{R}\rightarrow \mathbb{R}$, $F(x)=7Log[x]$. When given the command $D(F(g(x,y)),x)$ I would like to have the output $7\partial_x(g)/g$. Is it possible?

  • $\begingroup$ Welcome to Mathematica.SE! 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$
    – user9660
    Oct 25, 2016 at 15:11

1 Answer 1


It is not only possible, it is actually quite straightforward. Define f in the usual way:

f[x_] := 7 Log[x]

Then take the derivative of the composition with g[x,y] (being an "undefined" generic function). The answer is as you expect:

D[f[g[x, y]], x]

enter image description here

So there is no need to specially define the function g[x,y].


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