Re: Through[(a+b+b)[x]]

*To*: mathgroup at smc.vnet.net*Subject*: [mg109177] Re: Through[(a+b+b)[x]]*From*: "David Park" <djmpark at comcast.net>*Date*: Fri, 16 Apr 2010 05:49:28 -0400 (EDT)

The Presentations package has the PushOnto command that gives a more controlled way to push arguments onto functions. You can specify the patterns to push the arguments onto. Needs["Presentations`Master`"] (a + 2 b)[x]; % // PushOnto[a, b] a[x] + 2 b[x] (3 a - c Derivative[1][b])[x]; % // PushOnto[a, Derivative[1][b]] 3 a[x]-c b'[x] afunc := #^2 &; bfunc = #^3 &; (afunc - 3 E^bfunc)[x]; % // PushOnto[_Function] -3 E^x^3 + x^2 Other useful functions in the Manipulations section of Presentations are CompleteTheSquare, FactorOut, AddZero, MultiplyByOne, LinearBreakout, MapLevelParts, MapLevelPatterns, EvaluateAt, EvaluateAtPattern. David Park djmpark at comcast.net http://home.comcast.net/~djmpark/ From: Derek Yates [mailto:yatesd at mac.com] Through[(a+b)[x]] yields a[x]+b[x] as expected, but Through[(a+b+b) [x]] yields a[x]+(2b)[x]. Through[(2b)[x]] yields 2[x]b[x]. Now, I can obviously get around this in this specific case, but generically is there a way to solve this so that Through[(a+b+b)[x]] yields a[x] +2b[x]? The case where I envisage this happening is when a sum of functions is supplied (say, for a given value of y, Through[(f[y]+g[y] +h[y]+j[y])[x]] and for some values of y, g = h. Then one will end up with the problem above. Other than some post processing using pattern matching, which feels a bit clunky, I can't think of a way around this.