3
$\begingroup$

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?

Thanks.

u[x_, y_, z_] = x + y + z
Simplify[D[Log[u[x, y, z]], x]]
$\endgroup$
7
$\begingroup$
D[Log[u[x, y, z]], x] /. u[x_, y_, z_] :> Defer[u[x, y, z]]

1/u[x, y, z]

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

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]

$\endgroup$
  • $\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 '18 at 19:29
  • $\begingroup$ @Rzu Maybe you can check out the documentation for UpSetDelayed and TagSetDelayed. $\endgroup$ – Carl Woll Nov 22 '18 at 19:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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