The Doubling Function

This notebook can help you to understand the behavior of the doubling function, 
D(x)={({{2  x               0 ≤ x < 
                          (1/2)}, {2  x - 1       (1/2) ≤ x < 1}})
or more succinctly D(x) = 2  x mod 1.

Initialization cell

This cell will be automatically evaluated when you evaluate the other cells in this notebook.

Equation = Function[x, Mod[2  x, 1]];
FunctionName = "doubling function";
$TextStyle = {FontFamily -> "Times", 
          FontSize -> 14};
<< Graphics`Graphics`

The function and its iterates

With this cell we plot the function and its iterates. The value of n specifies the nth-iterate of the function to be displayed. The identity function y = x is also plotted.

n = 2;
NthIterate = Nest[Equation, x, n];

    
FunctionPlot = 
        Plot[{Equation[x], x}, {x, 0, 1}, Frame -> True, 
          Axes -> 
            True, 
PlotLabel -> "The " <>  
              FunctionName , 
PlotRange -> {{0, 
                1}, {0, 1}}, FrameLabel -> {"x", "f(x)"}, 
          RotateLabel -> False, AspectRatio -> 1, 
          DisplayFunction -> Identity];

    
\(\(\(NthIteratePlot = 
        Plot[{NthIterate, x}, {x, 0, 1}, 
          Frame -> True, 
Axes -> True, 
          PlotLabel -> "nth-iterate of the " <> \ 
              FunctionName\  <> ", n= " <> 
              ToString[n], 
PlotRange -> {{0, 1}, {0, 
                1}}, FrameLabel -> {"x", \*""\!\(f\^n\)(x)""}, 
          RotateLabel -> False, AspectRatio -> 1, 
          PlotPoints -> 100, 
          DisplayFunction -> Identity];\)\(
\)
    \)\)
Show[
        GraphicsArray[{{FunctionPlot}, {NthIteratePlot}}, 
          ImageSize -> 400]];

Orbit diagram, time series, and histogram of a particular seed (Subscript[x, 0])

This cell shows the orbit of (Subscript[x, 0])in three different ways. 

Note: If we want to have a good visualization of the histogram of the orbit we need to increase the number of Iterates drawn.

(Subscript[x, 0]) = 2/5;
Iterates = 100;
DropIterates = 10;

    
Orbit = 
        Take[NestList[Equation, (Subscript[x, 0]), 
            Iterates - 
              1], -(Iterates - 
                DropIterates)];
OrbitLines = 
        Graphics[{RGBColor[1, 0, 0], 
            Line[Flatten[
                Table[{{Orbit[[i]], Orbit[[i]]}, {Orbit[[i]], 
                      Orbit[[i + 1]]}}, {i, 1, Length[Orbit] - 1}], 
                1]]}];
\(\(OrbitDiagram = 
        Plot[{Equation[x], x}, {x, 0, 1}, Frame -> True, 
          Axes -> True, 
          AspectRatio -> 
            1, 
PlotLabel -> "Graphical analysis of the " <> FunctionName <> \*"", (Subscript[x, 0])= "" <> 
              ToString[N[x\_0]], 
PlotRange -> {{0, 
                1}, {0, 1}}, FrameLabel -> {"x", "f(x)"}, 
          RotateLabel -> False, 
          DisplayFunction -> Identity];\)\)
\(\(TimeSeries = 
        ListPlot[Orbit, Frame -> True, Axes -> True, 
          PlotJoined -> True, 
          PlotLabel -> "Time series of the " <> 
              FunctionName <> \*"", \!\(x\_0\)= "" <> 
              ToString[N[x\_0]], 
          PlotRange -> {{0, Length[Orbit]}, {0, 1}}, 
          FrameLabel -> {"n", \*""\!\(x\_n\)""}, 
          RotateLabel -> False, 
          DisplayFunction -> Identity];\)\)
\(\(HistogramPlot = 
        Histogram[Orbit, HistogramCategories -> \ 500, 
          Frame -> True, HistogramRange -> {0, 1}, 
          PlotLabel -> \ \*""Histogram of the orbit of (Subscript[x, 0])"" <> "= " <> ToString[N[x\_0]], \ 
          FrameLabel -> \ {"x", "Freq."}, 
          RotateLabel -> False, \ BarStyle -> \ RGBColor[0, 0, 0], 
          DisplayFunction -> \ Identity];\)\)
Show[
        GraphicsArray[{{Show[{OrbitDiagram, 
                  OrbitLines}]}, {TimeSeries}, {HistogramPlot}}, 
          ImageSize -> 500]];