Re: Mathematica bugs?
- To: mathgroup at smc.vnet.net
- Subject: [mg67326] Re: Mathematica bugs?
- From: Bill Rowe <readnewsciv at earthlink.net>
- Date: Sun, 18 Jun 2006 05:13:23 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
On 6/17/06 at 4:36 AM, yaroslavvb at gmail.com (Yaroslav Bulatov) wrote: >When I run the following line x = Pi/4; For[i = 0, i < 56, i += 1, x >= 2*Abs[x - 1/2]]; N[x] I get 3. >But x should always stay between 0 and 1, why do I get 3? >Also x = Pi/4; For[i = 0, i < 50, i += 1, x = 2*Abs[x - 1/2]]; >N[Log[x]] gives me Indeterminate >How can I get an indeterminate here? The answer to both questions is loss of precision. Note, In[14]:= x=Pi/4;For[i=0,i<56,i+=1,x=2*Abs[x-1/2]] In[15]:= x//FullSimplify Out[15]= 56593902016227523-18014398509481984 Ï? That is x is the difference between two large numbers. In[16]:= N[x,20] Out[16]= 0.79387245267980382900 In[17]:= %%//N Out[17]= 0. And finally the same computation is done more efficiently as Nest[2 Abs[x-1/2]&, Pi/4, 55]//FullSimplify -- To reply via email subtract one hundred and four