Re: FixedPoint stops "when elements no longer change"?
- To: mathgroup at smc.vnet.net
- Subject: [mg62825] Re: FixedPoint stops "when elements no longer change"?
- From: Jean-Marc Gulliet <jeanmarc.gulliet at Gmail.com>
- Date: Tue, 6 Dec 2005 00:04:03 -0500 (EST)
- Organization: The Open University, Milton Keynes, UK
- References: <dn0v44$8ge$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Steven T. Hatton wrote: > This is the example in The Mathematica Book for FixedPointList: > > FixedPointList[Cos, 1.0] > > {1., 0.540302, 0.857553, 0.65429, 0.79348, 0.701369, 0.76396, 0.722102, \ > 0.750418, 0.731404, 0.744237, 0.735605, 0.741425, 0.737507, 0.740147, \ > 0.738369, 0.739567, 0.73876, 0.739304, 0.738938, 0.739184, 0.739018, > 0.73913, \ > 0.739055, 0.739106, 0.739071, 0.739094, 0.739079, 0.739089, 0.739082, \ > 0.739087, 0.739084, 0.739086, 0.739085, 0.739086, 0.739085, 0.739085, \ > 0.739085, 0.739085, 0.739085, 0.739085, 0.739085, 0.739085, 0.739085, \ > 0.739085, 0.739085, 0.739085, 0.739085, 0.739085, 0.739085, 0.739085, \ > 0.739085, 0.739085, 0.739085, 0.739085, 0.739085, 0.739085, 0.739085, \ > 0.739085, 0.739085, 0.739085, 0.739085, 0.739085, 0.739085, 0.739085, \ > 0.739085, 0.739085, 0.739085, 0.739085, 0.739085, 0.739085, 0.739085, \ > 0.739085, 0.739085, 0.739085, 0.739085, 0.739085, 0.739085, 0.739085, \ > 0.739085, 0.739085, 0.739085, 0.739085, 0.739085, 0.739085, 0.739085, \ > 0.739085, 0.739085, 0.739085, 0.739085, 0.739085, 0.739085, 0.739085} > > A bit of poking around showed me that this is using SameQ for SameTest. > > "SameQ requires exact correspondence between expressions, except that it > considers Real numbers equal if their difference is less than the > uncertainty of either of them." > > I guess I'm not seeing all the decimal places used to generate to list > above. How would I determine the precision used to determine two > successive values are unchanged? > > I tried FixedPointList[N[Cos[#], 2] &, 1.0], but that changed neither the > display, nor the result. Hi Steven, Try the following: In[16]:= l = FixedPointList[Cos, 1.]; In[17]:= NumberForm[l, Floor[$MachinePrecision] + 1] Out[17]//NumberForm= {1.,0.5403023058681398,0.857553215846393,0.6542897904977791,0.\ 7934803587425656,0.7013687736227565,0.7639596829006542,0.7221024250267077,0.\ 7504177617637605,0.7314040424225098,0.7442373549005569,0.7356047404363474,0.\ 7414250866101092,0.7375068905132428,0.7401473355678757,0.7383692041223232,0.\ 7395672022122561,0.7387603198742113,0.7393038923969058,0.7389377567153445,0.\ 7391843997714936,0.7390182624274122,0.7391301765296711,0.7390547907469173,0.\ 7391055719265363,0.7390713652989449,0.7390944073790912,0.7390788859949921,0.\ 7390893414033926,0.7390822985224023,0.7390870426953322,0.7390838469650002,0.\ 7390859996481299,0.7390845495752126,0.7390855263619245,0.7390848683867142,0.\ 7390853116067619,0.7390850130484203,0.7390852141609171,0.739085078689123,0.\ 7390851699445545,0.7390851084737987,0.7390851498812394,0.7390851219886894,0.\ 7390851407774467,0.7390851281211138,0.7390851366465718,0.7390851309037208,0.\ 7390851347721744,0.7390851321663375,0.7390851339216606,0.7390851327392538,0.\ 7390851335357373,0.7390851329992164,0.7390851333606233,0.7390851331171753,0.\ 7390851332811648,0.7390851331706995,0.7390851332451103,0.7390851331949863,0.\ 7390851332287504,0.7390851332060064,0.7390851332213271,0.7390851332110069,0.\ 7390851332179587,0.7390851332132758,0.7390851332164302,0.7390851332143055,0.\ 7390851332157366,0.7390851332147727,0.739085133215422,0.7390851332149846,0.\ 7390851332152792,0.7390851332150808,0.7390851332152145,0.7390851332151244,0.\ 739085133215185,0.7390851332151441,0.7390851332151717,0.7390851332151531,0.\ 7390851332151657,0.7390851332151573,0.7390851332151628,0.7390851332151591,0.\ 7390851332151617,0.7390851332151599,0.7390851332151611,0.7390851332151604,0.\ 7390851332151609,0.7390851332151605,0.7390851332151608,0.7390851332151605,0.\ 7390851332151607} In[9]:= l[[-1]] - l[[-2]] Out[9]= 1.1102230246251565*^-16 $MachineEpsilon gives the smallest machine-precision number which can be added to 1.0 to give a result that is distinguishable from 1.0. In[11]:= $MachineEpsilon Out[11]= 2.220446049250313*^-16 In[12]:= l[[-1]] - l[[-2]] < $MachineEpsilon Out[12]= True In[18]:= $Version Out[18]= "5.2 for Microsoft Windows (June 20, 2005)" Best regards, /J.M