N does not work inside Replace ?
I just found a small but annoying problem with operating N inside a
s was actually part of an answer I got from Solve and I wanted to
leave the Rule, but change the right hand side to a machine real number.
A reduced form of the problem is given below. I'm using version 5.0.0
(ver 5.1 is on the way ... )
s = Rule[a, 10/3]
and the output is
now use a replace rule with N
s /. Rule[x_, y_] -> Rule[x, N[y]]
and the result is still a->10/3
using some other header in place of N
s /. Rule[x_, y_] -> Rule[x, g[y]]
and the results is as expected
Trying to convert the second argument to a machine real number in
s /. Rule[x_, y_] -> Rule[x, 1. y]
a -> 3.33333
Using Trace for the three cases reveals that N[y] is replaced by y
very early in the evaluation process, so it explains this unexpected
I tried then a simpler example
and then tried the same replacement idea
and still the results leave the rational numbers unchanged
but with the b/.x_Rational->g[x] or b/.x_Rational->1.0 * x Mathematica
works as expected.
So, again, is this a bug? If it is so in version 5.0.0, does it still
exists in version 5.1?
Thanks in advanced
Prev by Date:
Re: Condition , FullSimplify
Next by Date:
Re: Excel Link Problem
Previous by thread:
Re: Mathematica language issues
Next by thread:
Re: N does not work inside Replace ?