Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

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.)


  • Prev by Date: Re: First nonzero in list
  • Next by Date: Re: Can This be Possible? A bug in Set (=) ?
  • Previous by thread: Re: replacement x->y except in Exp[x]
  • Next by thread: Re: replacement x->y except in Exp[x]