In[3]:= Clear["*"];
approPi = N[Pi];
{Rationalize[approPi], Round[approPi, 10^-15]}
Out[2]= {3.14159, 3141592653589793/1000000000000000}
Above Rationalize failed to give a rational number probably because that, according to the Doc, there is no rational number "close enough" to approPi.
But apparently there exists a "close enough" rational number which is given by Round;
I know I can use Rationalize[x,dx] in this situation, according to the Doc:
Rationalize[x,dx]: yields the rational number with smallest denominator that lies within dx of x.
So below:
In[4]:= Clear["*"];
approPi = N[Pi];
{Rationalize[approPi, 0], Round[approPi, 10^-15]}
N[%, 20]
Out[2]= {245850922/78256779, 3141592653589793/1000000000000000}
Out[3]= {3.1415926535897931603, 3.1415926535897930000}
However, the error dx in the result 245850922/78256779 is by no means 0. Because 245850922/78256779, ie 3.1415926535897931603..., has the unnecessary 0.0000000000000001603 in it.
The result 3141592653589793/1000000000000000 of Round is the exact rational number equal to approPi. So I think the 3141592653589793/1000000000000000 I got via Round should be what Rationalize[approPi, 0] is supposed to output according to the Doc;
SetPrecision[]instead:SetPrecision[N[π], ∞]. See this as well. – J. M.'s missing motivation May 17 '20 at 14:45Rationalize's strange behavior. @J.M. – Murphy Ng May 17 '20 at 14:51ContinuedFraction[N[π]]andContinuedFraction[Rationalize[N[π], 0]]. Summary:Rationalize[],SetPrecision[], andRound[]all do quite different things. – J. M.'s missing motivation May 17 '20 at 14:56Rationalizedoesn't do what is said in the Doc. If the doc is wrong I need a clear definition ofRationalize– Murphy Ng May 17 '20 at 14:593141592653589793/1000000000000000isn't "close enough" to approPi? It's a strict equal, isn't it? – Murphy Ng May 17 '20 at 15:23