-1

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]
Prastt
  • 381
  • 1
  • 12
  • can't you just call it d? and then d->D? – acl Mar 25 '13 at 00:07
  • @acl I'm not sure if that would work in my case. To give more background, I'm calculating Christoffel symbols, see http://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). – Prastt Mar 25 '13 at 00:13
  • 3
    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. – Jens Mar 25 '13 at 00:16
  • @acl, I tried your suggestion but as I expected by calling it d it doesn't eliminate the zero valued symbols because in some cases it needs to compute the derivative. So I think the solution I'm looking for is how to simplify starting from the evaluated expression – Prastt Mar 25 '13 at 00:18
  • @Jens, it is very simple, but check the edit. – Prastt Mar 25 '13 at 00:37
  • 1
    But then the title of the question should be different. – Jens Mar 25 '13 at 00:46
  • @Jens, you don't have to be that pedantic, if you don't want to answer the question then don't. If you think the title should be different you can edit the question and type your proposed title. – Prastt Mar 25 '13 at 00:52
  • He's not being pedantic; your title asks for a completely different thing than what the edit and the first part of the question appear to indicate... – acl Mar 25 '13 at 01:16
  • @acl, OK. First, do you have a suggestion for a better title? Second, I assume both of you don't know the answer otherwise I don't see why the title should matter in order to get the answer. – Prastt Mar 25 '13 at 01:23
  • can't speak for @Jens but I certainly don't know the answer, no. – acl Mar 25 '13 at 01:30
  • 5
    @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. – rm -rf Mar 25 '13 at 01:47
  • @rm-rf, I'm not new here (only in this particular SE) and I know how the site works that's why I modified the original question to make it more descriptive. I just don't like the unhelpful comments of some pedantic users (which exist in every SE). – Prastt Mar 25 '13 at 02:00

2 Answers2

8

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.

Michael E2
  • 235,386
  • 17
  • 334
  • 747
  • 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. – Prastt Mar 25 '13 at 02:06
  • 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. – Michael E2 Mar 25 '13 at 10:35
  • @Barefeg you could try simp[exp_] := Simplify[exp, TransformationFunctions -> (Block[{x}, Defer[D[#, x]] &[Integrate[#, x]]] &)]; – Rojo Mar 25 '13 at 14:36
4

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.

Vitaliy Kaurov
  • 73,078
  • 9
  • 204
  • 355