I try to evaluate:

$$ \frac{\partial}{\partial x} \log{u(x, y, z)}$$

Mathematica gives:

$$ \frac{1}{x+y+z}$$

I want to simplify the expression with my function:

$$ \frac{1}{u(x, y, z)}$$

How to do that?


u[x_, y_, z_] = x + y + z
Simplify[D[Log[u[x, y, z]], x]]

2 Answers 2

D[Log[u[x, y, z]], x] /. u[x_, y_, z_] :> Defer[u[x, y, z]]

1/u[x, y, z]

  • $\begingroup$ A more general substitution: /. u[x_,y_,z_] -> Defer[u[x,y,z]] $\endgroup$
    – R zu
    Nov 22, 2018 at 18:04
  • $\begingroup$ @Rzu, good point. $\endgroup$
    – kglr
    Nov 22, 2018 at 18:05

An alternative is to define UpValues instead of DownValues of u:

Derivative[1, 0, 0][u] ^:= 1&
Derivative[0, 1, 0][u] ^:= 1&
Derivative[0, 0, 1][u] ^:= 1&

D[Log[u[x, y, z]], x]

1/u[x, y, z]

  • $\begingroup$ What are UpValues and DownValues? The definition in the doc seems recursive: UpValue "gives a list of transformation rules corresponding to all upvalues defined for the symbol f. " $\endgroup$
    – R zu
    Nov 22, 2018 at 19:29
  • $\begingroup$ @Rzu Maybe you can check out the documentation for UpSetDelayed and TagSetDelayed. $\endgroup$
    – Carl Woll
    Nov 22, 2018 at 19:39

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.