Re: replacement x->y except in Exp[x]
- To: mathgroup at smc.vnet.net
- Subject: [mg110864] Re: replacement x->y except in Exp[x]
- From: AES <siegman at stanford.edu>
- Date: Thu, 8 Jul 2010 20:34:53 -0400 (EDT)
- References: <i14aij$g0p$1@smc.vnet.net>
In article <i14aij$g0p$1 at smc.vnet.net>, Bob Hanlon <hanlonr at cox.net>
wrote:
> expr = a*x + b*x^2 - c*Exp[x];
>
> expr /. {Exp[x] -> z, x -> y} /. z -> Exp[x]
>
> a*y + b*y^2 - c*E^x
>
>
> Bob Hanlon
>
> ---- Sebastian <sebhofer at gmail.com> wrote:
>
> =============
> Is it possible to exclude certain patterns from replacements?
> For example I want to replace y for x everywhere except in Exp[x].
>
> TIA Sebastian
Is it ever a good idea to use ReplaceAll to do word-processing-type
"global find and replace" changes like this?
Lengthy threads on this NG have pointed out the havoc that this can
wreak if the symbol I is among those replaced, particularly if one
attempts to do I -> -I.
Or is I the _only_ symbol in the entire Mathematica vocabulary that
encounters this difficulty?
(I really would like to know the answer to this question, even if this
is entirely out of curiosity, not any real need. I've asked it
previously, and never gotten an answer.)
- Follow-Ups:
- Re: replacement x->y except in Exp[x]
- From: Andrzej Kozlowski <akozlowski@gmail.com>
- Re: replacement x->y except in Exp[x]