Replacement rule limitations

*To*: mathgroup at smc.vnet.net*Subject*: [mg110550] Replacement rule limitations*From*: "S. B. Gray" <stevebg at ROADRUNNER.COM>*Date*: Fri, 25 Jun 2010 07:26:47 -0400 (EDT)*Reply-to*: stevebg at ROADRUNNER.COM

Several responders have told me that replacement rules are the way to simplify complex expressions and to reduce redundant computations (?). So let's try an arbitrary expression as a very simple example of something that could be much more complicated: exp = 1/Sqrt[ x^2+y^2+z^2] - (x^2+y^2+z^2) + (x^2+y^2+z^2)^( 1/3) /. x^2+y^2+z^2->dd This gives 1/Sqrt[dd] + dd^(1/3)-x^2-y^2-z^2 which is not that useful. But if I introduce a superfluous multiplier "s": exp = 1/Sqrt[x^2+y^2+z^2] - s(x^2+y^2+z^2) + (x^2+y^2+z^2)^( 1/3) /. {x^2+y^2+z^2->dd, s->1} I get 1/Sqrt[dd] + dd^(1/3) - dd which is better. Asking for exp^2 gives, as desired, (1/Sqrt[dd] + dd^(1/3) - dd)^2 . But trying to proceed as if this were regular algebra where cascaded substitutions are routine, I try: exp/.{x->a^2, y->3b, z->Sqrt[d + e]} , I get the useless result 1/Sqrt[dd] + dd^(1/3) - dd . Unless I am missing something important (it wouldn't be the first time!), replacement rules are not a good substitute for real intermediate variables. This does not even address a feature I'd like to see in Mathematica in which it would figure out what subexpressions appear repeatedly and make up its own simplifying intermediate variables. This could be incorporated into FullSimplify. Comments will be greatly appreciated. Steve Gray