[Date Index] [Thread Index] [Author Index]
Re: Simplify using custom function
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.