# First hundred iterations of $f(x)=x^2-2$ in Devaney's A First Course in Chaotic Dynamical Systems

In Devaney's "A First Course In Chaotic Dynamical Systems," he produces 100 terms of the orbit of $x_0=0.01$ for $f(x)=x^2-2$. His stated results on page 23 are:

\begin{array}{cc} n & x_n\\ 0 & 0.01\\ 1 & -1.999\\ 2 & 1.999\\ 3 & 1.998\\ 4 & 1.993\\ 5 & 1.974\\ 6& 1.898\\ 7 & 1.604\\ 8 & 0.573\\ 9 & -1.671\\ 10 & 0.793\\ 11 & -1.370\\ 12 & -0.122\\ 13 & -1.985\\ \vdots & \vdots\\ 95 & 1.548\\ 96 & 0.398\\ 97 & -1.841\\ 98 & 1.391\\ 99 & -0.065\\ 100 & -1.995 \end{array}

To save area in the text, he doesn't give all 100 terms. Now, I use NestList to try to produce this same orbit. I won't post all of the orbit elements.

F[x_] := x^2 - 2
data = NestList[F, 0.01, 100];


The first three are:

data[[1 ;; 3]]


{0.01, -1.9999, 1.9996}

Looks good. But the last three are different from the results in Devaney's book.

data[[99 ;; 101]]


{-1.05888, -0.878782, -1.22774}

I know this has something to do with the number of digits being used (possibly just three) and the device (indeed, this was back in 1992 using Basic).

Now, here is my question. How can I use Mathematica to limit all the numbers to three digits while using NestList? If this is not the approach that will duplicate the result in Devaney's book, again, how can I limit the number of digits (the precision) while executing NestList to produce the same orbit as shown in Devaney's book?

I tried:

Block[{$MachinePrecision = 3}, NestList[F, 0.01, 100]]  But it produced the same list as: NestList[F, 0.01, 100]  Update: I've listed every digit that is given in the text. • One of the main results of chaotic dynamics is that long computations like this, made with inexact numbers are not reproducible from system to system. Jul 24, 2017 at 8:02 ## 2 Answers Given the chaotic nature of the system, it may very well be impossible to recreate Devaney's orbit without knowing the exact details of his implementation. However the following (simulating 8 digit arithmetic) gets surprisingly close: Block[{$MinPrecision = 8}, data = NestList[F, 0.018, 100]];


yielding:

data[[-3;;-1]]


{1.39299689, -0.059559672, -1.9964526454}

• I suspect that is coincidence more than anything. I would only be convinced if you were to show the deviation was small over the whole sequence. Jul 24, 2017 at 8:22
• Since the entire sequence was not given that is a bit hard... Jul 24, 2017 at 12:35
• It appears that Devaney used single-precision floats. I can reproduce the last three terms in C. (You can't exactly imitate single-precision with arbitrary-precision reals, I believe.) Jul 24, 2017 at 13:38
• @mmeent I've edited the original post and listed all of the numbers posted in the textbook. Jul 24, 2017 at 16:42

[Update: Simplified single-precision routines. They still do not account for under/overflow or subnormal numbers, which are not needed in this application.]

Following the hint of @mmeent, here is a way to emulate single-precision that agrees the given data to the number of digits given.

(* arithmetic rounded to single precision *)
round1[x_] := If[x == 0, 0, Round[x, 2^(Floor@Log2[Abs@x] - 23)]];
plus1[x_, y_] := round1[x + y];  (* assumes x, y are single-precision *)
times1[x_, y_] := round1[x*y];

N@ NestList[plus1[times1[#, #], -2] &, round1[0.01], 100]
(* {0.01, -1.9999, 1.9996, 1.9984, 1.9936, 1.97445, 1.89846, ...,
1.5486, 0.398168, -1.84146, 1.39098, -0.0651647, -1.99575}  *)
`