Re: Simplify using custom function

*To*: mathgroup at smc.vnet.net*Subject*: [mg47711] Re: Simplify using custom function*From*: Jon Harrop <jdh30 at cam.ac.uk>*Date*: Fri, 23 Apr 2004 02:30:39 -0400 (EDT)*Organization*: University of Cambridge*References*: <c65fnl$2pn$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Jens wrote: > example: complicated expression: -1+2 x +2 e^x > function: f[x_]=x+e^x > > Mathematica should return: -1+2 f[x] I use Simplify or FullSimplify and tell mathematica your substitution rules as equalities in the assumptions argument to the function: In := Simplify[-1 + 2 x + 2 e^x, f[x] == x + e^x] Out := -1 + 2 f[x] If you need more than one substitution rule then specify them as, for example, "f[x] == x + e^x && g[x] == x - 2 e^x". If you want to make the substitution then apply it as a rule: In := -1 + 2 f[x] /. f[x] -> x + e^xb Out := -1 + 2 (e^x + x) HTH. Cheers, Jon.