       Re: Replacement rule limitations

• To: mathgroup at smc.vnet.net
• Subject: [mg110576] Re: Replacement rule limitations
• From: Peter Pein <petsie at dordos.net>
• Date: Sat, 26 Jun 2010 03:11:07 -0400 (EDT)
• References: <i023o1\$r6u\$1@smc.vnet.net>

```Am Fri, 25 Jun 2010 11:25:53 +0000 (UTC)
schrieb "S. B. Gray" <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
>

Hi,

rules are one way constructs. Once you eliminated x, y and z by
your multiplier-method, exp is free of these variables. You'll have to
do a backsubstitution first:

exp/.{dd->x^2+y^2+z^2,x->a^2, y->3b, z->Sqrt[d + e]}

should give what you want.

Peter

P.S.: Did I hear a flat hand slapping against someone's forehead? ;-)

```

• Prev by Date: Re: Why?
• Next by Date: Re: Image processing Questions
• Previous by thread: Replacement rule limitations
• Next by thread: Re: Replacement rule limitations