MathGroup Archive 1998

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

Search the Archive

Re: How does a rule get applied?


  • To: mathgroup@smc.vnet.net
  • Subject: [mg12459] Re: How does a rule get applied?
  • From: Paul Abbott <paul@physics.uwa.edu.au>
  • Date: Tue, 19 May 1998 13:31:28 -0400
  • Organization: University of Western Australia
  • References: <6jf2mg$3vl@smc.vnet.net>

Yacine Ait-Sahalia wrote:

> Could anyone please explain to me why
> 
>         x^a + x^(1+a)  /. x^(n_) + x^(n_+1) ->0
> 
> returns 0 (as expected), whereas
> 
>         x^3 + x^(1+3)  /. x^(n_) + x^(n_+1) ->0
> 
> returns
> 
>                  3    4
>                 x  + x
> 
> instead of 0?

Because 1+3 evaluates to 4 _before_ the pattern-matching is attempted. 
One general workaround is

In[1]:= x^3 + x^(1+3)  /. x^(n_) + x^(m_) :>0 /; m-n == 1 Out[1]= 0

Cheers,
	Paul 
 
____________________________________________________________________ 
Paul Abbott                                   Phone: +61-8-9380-2734
Department of Physics                           Fax: +61-8-9380-1014
The University of Western Australia            Nedlands WA  6907       
mailto:paul@physics.uwa.edu.au  AUSTRALIA                            
http://www.pd.uwa.edu.au/~paul

            God IS a weakly left-handed dice player
____________________________________________________________________



  • Prev by Date: Re: Solve for positive, real-valued solutions
  • Next by Date: Re: Q: how to start Solve[] with an initial solution guess?
  • Prev by thread: Re: How does a rule get applied?
  • Next by thread: Re: How does a rule get applied?