Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • 1
    $\begingroup$ Collect[expr, G[__], h1] /. G :> Composition[h2, G] $\endgroup$ Commented May 11, 2020 at 19:25
  • $\begingroup$ Thanks! that's an elegant way of writing it. However, if I'm not mistaken it still means mathematica has to pattern match the G's "twice", which I was hoping to avoid. Maybe it's just not possible though.. $\endgroup$ Commented May 12, 2020 at 13:36
  • 1
    $\begingroup$ Would it make sense to use Collect[...] in that third argument? $\endgroup$ Commented May 12, 2020 at 14:38
  • $\begingroup$ I think (the first) Collect allows me to specify an action on the "coefficients", but no way to obviously act on the "variables", so then I think adding a further Collect cannot directly help. $\endgroup$ Commented May 13, 2020 at 15:06