The Quadratic Equation

This notebook can help you to study the quadratic equation in the real variable. The quadratic equation is defined by (Subscript[Q, c])(x) = (x^2) + c, where  c is a parameter.

Initialization cell

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

Equation = Function[x, (x^2) + c];
FunctionName = "quadratic equation";
$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. Choose the value of cwhich you want to analyze.

c = -2;
n = 2;

NthIterate = Nest[Equation, x, n];
FunctionPlot = 
        Plot[{Equation[x], x}, {x, -2, 2}, Frame -> True, 
          Axes -> 
            True, 
PlotLabel -> "The " <>  
              FunctionName , 
PlotRange -> {{-2, 
                2}, {-2, 2}}, FrameLabel -> {"x", "f(x)"}, 
          RotateLabel -> False, AspectRatio -> 1, 
          DisplayFunction -> Identity];
\(\(NthIteratePlot = 
        Plot[{NthIterate, x}, {x, \(-2\), 2}, 
          Frame -> True, 
Axes -> True, 
          PlotLabel -> "nth-iterate of the " <> \ 
              FunctionName\  <> ", n= " <> 
              ToString[n], 
PlotRange -> {{\(-2\), 
                2}, {\(-2\), 2}}, 
          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;
c = -2;
Iterates = 15;
DropIterates = 1;

    
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, \(-2\), 2}, Frame -> True, 
          Axes -> 
            True, 
PlotLabel -> "Graphical analysis of the " <> FunctionName <> \ \*"", (Subscript[x, 0])=""\  <> \ 
              ToString[x\_0], 
PlotRange -> {{\(-2\), 
                2}, {\(-2\), 2}}, 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[x\_0], 
          PlotRange -> {{0, Length[Orbit]}, {\(-2\), 2}}, 
          FrameLabel -> {"n", \*""\!\(x\_n\)""}, 
          RotateLabel -> False, 
          DisplayFunction -> Identity];\)\)
\(\(HistogramPlot = 
        Histogram[Orbit, HistogramCategories -> \ 500, 
          Frame -> True, HistogramRange -> {\(-2\), 2}, 
          PlotLabel -> \ \*""Histogram of the orbit of (Subscript[x, 0])="" <> ToString[x\_0], \ 
          FrameLabel -> \ {"x", "Freq."}, 
          RotateLabel -> False, \ BarStyle -> \ RGBColor[0, 0, 0], 
          DisplayFunction -> \ Identity];\)\)
Show[
        GraphicsArray[{{Show[{OrbitDiagram, 
                  OrbitLines}]}, {TimeSeries}, {HistogramPlot}}, 
          ImageSize -> 500]];
Clear[c];

Bifurcation Diagram

This cell helps you to visualize the bifurcation diagram for the quadratic equation. Choose the interval of c-values you want to plot, i.e., Initialc and Finalc. Divisions is used to divide the interval of c-values to make the plot neat. Also the value of Iterates and DropIterates can be modified at will. 

Note: when trying to plot the bifurcation diagram with Finalc = 0 we get an underflow error message because iterates of the Random[] seed (which lies between zero and one) under Q(x)  = (x^2)goes to values smaller than the limits assumed by Mathematica ($MinNumber) . If we want to avoid the message we can use Finalc = -(10^(-3)) instead of 0, for example.

Initialc = -2;
Finalc = -0.01;
Divisions = 750;
Iterates = 500;
DropIterates = 400;
ParameterRange = {Initialc, 
          Finalc, (Finalc - Initialc)/(Divisions + 
                1)};
OrbitFunction[c_] := 
        Take[NestList[Equation, Random[], 
            Iterates - 
              1], -(Iterates - 
                DropIterates)];
DataSet = 
        Table[{c, OrbitFunction[c]}, {c, ParameterRange[[1]], 
            ParameterRange[[2]], 
            ParameterRange[[3]]}];
DataPlot = 
        Flatten[Table[{DataSet[[n]][[1]], DataSet[[n]][[2]][[i]]}, {n, 1, Length[DataSet]}, {i, 1, 
              Iterates - DropIterates}], 1];
BifurcationDiagram = 
        ListPlot[DataPlot, Frame ->  True, Axes -> False, 
          PlotRange -> {{Initialc, Finalc}, Automatic}, 
          PlotJoined -> False, 
          PlotStyle -> 
            AbsolutePointSize[
              0], 
PlotLabel -> "Bifurcation Diagram \
of the " <> FunctionName  <>  ",  " <> 
                ToString[Initialc] " ≤ c ≤ " <> 
                ToString[Finalc], FrameLabel -> {"c", "x"}, 
          RotateLabel -> False, ImageSize -> 500];