Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #2849

Re: FixedPoint[Cos, 1.0]

From DrMajorBob <btreat1@austin.rr.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: FixedPoint[Cos, 1.0]
Date 2011-06-01 08:31 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <is4tcd$b0b$1@smc.vnet.net> (permalink)

Show all headers | View raw


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@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@yahoo.com

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: FixedPoint[Cos, 1.0] DrMajorBob <btreat1@austin.rr.com> - 2011-06-01 08:31 +0000

csiph-web