-1
$\begingroup$

Is there a way to reverse the application of derivative rules in order to simplify expressions including derivatives?

e.g. in Mathematica code: Want to go from

(g[x, y]*Derivative[1, 0][f][x, y])/h[x, y] + (f[x, y]*Derivative[1, 0][g][x, y])/h[x, y] - 
(f[x, y]*g[x, y]*Derivative[1, 0][h][x, y])/h[x, y]^2

to

D[f[x, y]*g[x, y]/h[x, y], x]
$\endgroup$
12
  • $\begingroup$ can't you just call it d? and then d->D? $\endgroup$
    – acl
    Commented Mar 25, 2013 at 0:07
  • $\begingroup$ @acl I'm not sure if that would work in my case. To give more background, I'm calculating Christoffel symbols, see mathworld.wolfram.com/ChristoffelSymboloftheSecondKind.html eq. 3. The procedure outputs the symols that are not zero which is what I want, but it evaluates all the derivatives (huge mess). $\endgroup$
    – Prastt
    Commented Mar 25, 2013 at 0:13
  • 3
    $\begingroup$ You should spend some time writing a small example in valid Mathematica code so that we can see what your starting point is. Otherwise we'd have to waste time guessing wether some or all of the f, g, h are defined or not, whether x is the independent variable, etc. $\endgroup$
    – Jens
    Commented Mar 25, 2013 at 0:16
  • 1
    $\begingroup$ But then the title of the question should be different. $\endgroup$
    – Jens
    Commented Mar 25, 2013 at 0:46
  • 5
    $\begingroup$ @Barefeg Re: your recent comments above, let me clarify a few things for you, since you're new here. 1) This is not a personal support site. We try our best to keep questions meaningful and useful to a wide audience and that means, having an appropriate title that succinctly describes the problem (which will then allow others to easily search for it). If titles didn't matter, we might as well call this "How to make Lasagna". 2) This is a community run site and people here are volunteering their time to help others. Snapping at the very people who are trying to help you is not a good idea. $\endgroup$
    – rm -rf
    Commented Mar 25, 2013 at 1:47

2 Answers 2

8
$\begingroup$

Actually, Integrate will work. The trouble is preventing the evaluation of the derivative.

expr = With[{anti = 
   Integrate[(g[x, y]*Derivative[1, 0][f][x, y])/
      h[x, y] + (f[x, y]*Derivative[1, 0][g][x, y])/
      h[x, y] - (f[x, y]*g[x, y]*Derivative[1, 0][h][x, y])/h[x, y]^2,
     x]}, HoldForm[D[anti, x]]]

Use ReleaseHold[expr] if you want to evaluate the derivative.

$\endgroup$
3
  • $\begingroup$ Great, this works almost perfectly. Is there any way to make this more general? For example if the expression contains full derivatives instead of being a full derivative? In other words, a way to look for full derivatives and simplify them while leaving the other parts unchanged. If this is not clear I can give an example. $\endgroup$
    – Prastt
    Commented Mar 25, 2013 at 2:06
  • $\begingroup$ You would probably have to teach Mathematica how to simplify. I'm not sure about the best way. Perhaps these will be helpful: a question about sums or a question about vector calculus. Adding another example to your question might help others give a more complete answer. $\endgroup$
    – Michael E2
    Commented Mar 25, 2013 at 10:35
  • $\begingroup$ @Barefeg you could try simp[exp_] := Simplify[exp, TransformationFunctions -> (Block[{x}, Defer[D[#, x]] &[Integrate[#, x]]] &)]; $\endgroup$
    – Rojo
    Commented Mar 25, 2013 at 14:36
4
$\begingroup$

If you are starting with you original expression (basically a general derivative unfloded):

exp = (g[x, y]*Derivative[1, 0][f][x, y])/h[x, y] + 
      (f[x, y]*Derivative[1, 0][g][x, y])/h[x, y] - 
      (f[x, y]*g[x, y]*Derivative[1, 0][h][x, y])/h[x, y]^2;

You know that the only variable with respect to which differentiation is taken is x. Then you could just try to integrate and it will give what you need:

Integrate[exp, x]

(f[x, y] g[x, y])/h[x, y]

meaning expression under derivative.

$\endgroup$

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.