Re: [mg 3410] substitution rules and patterns
- To: mathgroup at smc.vnet.net
- Subject: [mg3431] Re: [mg 3410] substitution rules and patterns
- From: Dave Snead <76300.3545 at compuserve.com>
- Date: Thu, 7 Mar 1996 02:23:26 -0500
- Sender: owner-wri-mathgroup at wolfram.com
Susan Rempe <rempe at euclid.chem.washington.edu>
writes:
>Could someone tell me why the first substitution rule
>works and the second doesn't----
>In[70]:= (c^2)^(d/2)/.{(a_^2)^(b_ /2)->a^b}
>Out[70]= c^d
>In[71]:= (c^2)^(5/2)/.{(a_^2)^(b_ /2)->a^b}
>Out[71]= (c^2)^(5/2)
>Thanks in advance,
>Susan Rempe
>rempe at u.washington.edu
d/2 and b/2 are each converted to the form Times[Rational[1,2],_] so they match.
However 5/2 is converted to Rational[5,2], so the match is lost.
Try:
In[5]:= (c^2)^(5/2) /. {(a_^2)^Rational[b_ ,2]->a^b}
Out[5]= c^5
Good Luck,
Dave Snead
76300.3545 at compuserve.com
==== [MESSAGE SEPARATOR] ====