Re: Rational[a,b] vs Rational[1,2]

*To*: mathgroup at smc.vnet.net*Subject*: [mg116640] Re: Rational[a,b] vs Rational[1,2]*From*: Murray Eisenberg <murray at math.umass.edu>*Date*: Tue, 22 Feb 2011 04:44:53 -0500 (EST)

I think this sort of thing has been discussed before in this list ad nauseam (although usually with respect to things involving I). On 2/21/2011 7:30 PM, Richard Fateman wrote: > I find it potentially hazardous that Head[] > does not distinguish the cases of Head[1/2] > > and Head[Rational[a,b]] > > Thus these both get transformed... > > 1/2 /. Rational[r_,s_]-> foo[r,s] > > Rational[a,b] /. Rational[r_,s_] -> foo[r,s] > > > but compare ... > > 1/2 /. 2->4 > > Rational[a,2] /. 2->4 > > I'm not saying I'm surprised by this, of course. > > Perhaps Rational[a,b] should be converted to a/b unless both > a and b are numbers. > > Oh, for some fun, try Rational[1/2,4]. > > > RJF > > PS, I used version 7. > > -- Murray Eisenberg murray at math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305