Re: How does a rule get applied?
- To: mathgroup@smc.vnet.net
- Subject: [mg12468] Re: [mg12417] How does a rule get applied?
- From: "Jrgen Tischer" <jtischer@pitagoras.univalle.edu.co>
- Date: Tue, 19 May 1998 13:31:35 -0400
Hello Yacine, if you execute x^3 + x^(1+3) /. x^(n_) + x^(n_+1) ->0//Trace you will see that 1+3 is evaluated before the rule is applied, so the pattern is not what your rule is searching for. In case you want a rule that changes a sum of two powers of x to zero if the difference is 1, try the following: x^6 + x^5 /. x^(n_) + x^(m_) /; m == n + 1 -> 0. Jürgen -----Original Message----- From: Yacine Ait-Sahalia <fyaitsah@gsbux1.uchicago.edu> To: mathgroup@smc.vnet.net Subject: [mg12468] [mg12417] How does a rule get applied? >Hi, > >I'm having trouble understanding how rules are applied after /. Consider >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 > > >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? > >Thanks for your help. >