Re: FixedPoint[Cos, 1.0]

*To*: mathgroup at smc.vnet.net*Subject*: [mg119366] Re: FixedPoint[Cos, 1.0]*From*: DrMajorBob <btreat1 at austin.rr.com>*Date*: Wed, 1 Jun 2011 04:31:16 -0400 (EDT)

The series cycles between two DIFFERENT machine-precision numbers: RealDigits /@ Take[FixedPointList[Cos, 1.0, 100], -10] {{{7, 3, 9, 0, 8, 5, 1, 3, 3, 2, 1, 5, 1, 6, 0, 5}, 0}, {{7, 3, 9, 0, 8, 5, 1, 3, 3, 2, 1, 5, 1, 6, 0, 8}, 0}, {{7, 3, 9, 0, 8, 5, 1, 3, 3, 2, 1, 5, 1, 6, 0, 5}, 0}, {{7, 3, 9, 0, 8, 5, 1, 3, 3, 2, 1, 5, 1, 6, 0, 8}, 0}, {{7, 3, 9, 0, 8, 5, 1, 3, 3, 2, 1, 5, 1, 6, 0, 5}, 0}, {{7, 3, 9, 0, 8, 5, 1, 3, 3, 2, 1, 5, 1, 6, 0, 8}, 0}, {{7, 3, 9, 0, 8, 5, 1, 3, 3, 2, 1, 5, 1, 6, 0, 5}, 0}, {{7, 3, 9, 0, 8, 5, 1, 3, 3, 2, 1, 5, 1, 6, 0, 8}, 0}, {{7, 3, 9, 0, 8, 5, 1, 3, 3, 2, 1, 5, 1, 6, 0, 5}, 0}, {{7, 3, 9, 0, 8, 5, 1, 3, 3, 2, 1, 5, 1, 6, 0, 8}, 0}} Using a less strict SameTest (than the default) is the natural cure. We can also stop when a value repeats: values = {}; f[g_][x_] := (AppendTo[values, x]; g@x) FixedPointList[f[Cos], 1.0, SameTest -> (MemberQ[values, #2] &)] {Last@%, f[Cos]@Last@%} // RealDigits Length@%% {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} {{{7, 3, 9, 0, 8, 5, 1, 3, 3, 2, 1, 5, 1, 6, 0, 5}, 0}, {{7, 3, 9, 0, 8, 5, 1, 3, 3, 2, 1, 5, 1, 6, 0, 8}, 0}} 90 There you can see the same values that repeated before. The first is reached in 89 iterations, and the other requires one more iteration. Cycles CAN involve more than two values, of course. Bobby On Tue, 31 May 2011 06:49:00 -0500, J Siehler <jsiehler at gmail.com> wrote: > My numerical analysis students this past term pointed out to me that > the command > > FixedPoint[Cos, 1.0] > > which is the first example in the Information for FixedPoint doesn't > ever finish running (or, not in any reasonable amount of time). We > tried this on serveral versions of Mathematica (6.x, 7.x, and 8.x), > all on OS X, and got the same nonresult. > > It can be forced by specifying something like FixedPoint[Cos, 1.0, > SameTest -> (Abs[#1 - #2] < 10^-10 &)] or FixedPoint[Cos, 1.0, 40], > but it seems like that should be unnecessary, and the form given in > the documentation should work. Can anybody else confirm this > behavior? Am I missing something totally obvious here? > -- DrMajorBob at yahoo.com