For multiple integration, I would like to automatically check whether the integrand can be split up to a product of terms, each dependent on as small a subset of the variables as possible.

E.g., given the variables $(x,y,z)$, the integrand: $\sin(x y) e^\sqrt{z} x^3 z/y$ would produce the list of: {$\sin(x y) x^3 / y$, $e^\sqrt{z} z$}.

Sin[x y] E^Sqrt[z] x^3 z/y

It would be nice if it would recognize: $e^{x+y}$ as: {$e^x$, $e^y$}.

For now, I will leave cases requiring sums of the products above, e.g., using the trigonometric identity: $\sin(x + y) = \sin(x) \cos(y) + \sin(y) \cos(x)$.

I was thinking from the mathematical standpoint, of attempting differentiation to see which parts depend on which variables. However, perhaps there already exist Mathematica functions which get me in the right direction.

Thank you.

  • $\begingroup$ Collect? What have you tried so far? $\endgroup$
    – MarcoB
    Commented May 10, 2022 at 20:17
  • $\begingroup$ But Collect is for powers only. How would it handle trigonometric functions, for example? I played around a bit with differentiation, however for that, I would like a tree of the multiplicative terms, in order to start with the largest terms possible, as with my example. $\endgroup$ Commented May 10, 2022 at 20:29
  • $\begingroup$ I thought to replace, at the top level only, Times with List. Then on each element, check to see if it depends on one variable only (differentiating wrt all other variable produces 0). Elements which depend on more than one variable, trying to break them down further to a product. $\endgroup$ Commented May 10, 2022 at 20:39
  • $\begingroup$ A start might be GroupBy[List @@ (Sin[x y] E^Sqrt[z] x^3 z/y), Variables], although it produces quite a few more groups than you wanted. But maybe you can re-group separated terms in its output according to your preferences. You could also try GatherBy instead of GroupBy for a simpler list output. $\endgroup$
    – MarcoB
    Commented May 10, 2022 at 21:13
  • 3
    $\begingroup$ Does the function separate from this answer do what you need? $\endgroup$
    – Carl Woll
    Commented May 10, 2022 at 21:19


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.