Rational[a,b] vs Rational[1,2]
- To: mathgroup at smc.vnet.net
- Subject: [mg116618] Rational[a,b] vs Rational[1,2]
- From: Richard Fateman <fateman at eecs.berkeley.edu>
- Date: Mon, 21 Feb 2011 19:30:54 -0500 (EST)
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.