MathGroup Archive 1998

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

Search the Archive

Re: How does a rule get applied?



Yacine Ait-Sahalia gives the following example:

          x^a + x^(1+a)  /. x^(n_) + x^(n_+1) ->0
          x^3 + x^(1+3)  /. x^(n_) + x^(n_+1) ->0
          x^3            /. x^(n_) ->0

Out[388]=
                0
Out[389]=
                 3    4
                x  + x
Out[390]=
                0

And asks why the second output is not 0.

Yacine:

x^3 + x^(1+3)  evaluates to x^3 + x^4 before replacement is tried, so
there is no match.
To get round this we can temporarily hold until replacement is done:

Unevaluated[x^3 + x^(1+3)] /. x^(n_) + x^(n_+1) ->0

0

Allan Hayes
Training and Consulting
Leicester UK
http://www.haystack.demon.co.uk
hay@haystack.demon.co.uk
voice: +44 (0)116 271 4198
fax: +44(0)116 271 8642




  • Prev by Date: Re: Create Auto Save Package
  • Next by Date: Re: Problem defining transformation rules
  • Prev by thread: Re: How does a rule get applied?
  • Next by thread: Re: How does a rule get applied?