Chaos With a Heart

Practice with complex numbers, 
tangent lines, and parametric equations

© 1998, David Fowler
Center for Curriculum and Instruction
University of Nebraska-Lincoln

Getting started

If you are not familiar with Mathematica, or if you are viewing this notebook for the first time, you should read the following section "Read me first."

To access the information in this section, place your cursor in the blue cell bracket to the right of that section and "double click".

O. Read me first

Some things you should know about Mathematica

Often, you are instructed within this notebook to "evaluate" a cell or "define" a variable. Let's practice this skill as your ability to do this is crucial to using this courseware.

Place your cursor directly behind the Plot[Sin[x],{x,0,2π}] in the line below and hit either "Enter" (using the keypad on the right side of the keyboard) or "Shift+Return" using the main keyboard keys (that is, hold down the "Shift" key while you hit the "Return" key). This is what is meant by evaluating a cell: you are telling Mathematica to do something.

Plot[Sin[x], {x, 0, 2  π}]

Defining a variable has a similar process. To define (Subscript[α, 1]) below, place the cursor behind the line of data (directly behind (Subscript[α, 1]) = 5) and hit "Enter" or "Shift+Return"

(Subscript[α, 1]) = 5

Some things you should know about "Chaos with a Heart"

When you see a gray cell box, the student will be asked to answer a question or perform some task.

This notebook is just the introduction to a much larger collection of notebooks which will be released in the near future. Thus, you should be aware that not all comments may make sense (eg see section so-and-so... which does not exist).

I. Some motivating questions

1. What is the simplest quadratic function? 
2. What is an obvious experiment to try with this function? 
3. What is the dependence on the initial values?

Comments regarding the above questions

*The amount of time spent on motivation for this lesson is, of course, up to the teacher, and depends on the previous experiences of the students. A point that should be made is that mathematicians often proceed by learning about simple cases first. Often the information they get about a simple case can be extended. So what we learn about the simplest quadratic function may help us learn about more complicated examples.

*In the pre-computer age it was not so obvious that one would repeatedly apply a function. Now it's as natural as "hitting return." We'll refer to this repeated application as "iteration."

*The phrase "sensitive dependence on initial conditions" describes a fundamental characteristic of chaos theory. This lesson gives an excellent introduction to the subject.

II. First experiments

Let's look at a complex number. We'll use integer coefficients to make it easier for us [humans] to follow what happens when we repeatedly apply the square function to a complex number. However, before we begin squaring things, please define (Subscript[z, 1]) by evaluating the cell below.

(Subscript[z, 1])  =  2  +  3  I;

By doing this, Mathematica now knows what you mean by (Subscript[z, 1]). To verify your definition, place your cursor behind (Subscript[z, 1]) in the cell below and evaluate it.

(Subscript[z, 1])

Because Mathematica now knows what (Subscript[z, 1]) is, we can use it in calculations. Please use the definition of (Subscript[z, 1]) to evaluate the following cells:

((Subscript[z, 1])^2)

(((((Subscript[z, 1])^2)))^2)

((((((((Subscript[z, 1])^2)))^2)))^2)

To make it easier for us, we can carry out similar calculations using a custom-made Mathematica function called squareIt. [Instructions on how to create such a function are shown in the section: The Mathematica Way.] Please evaluate the following cells below:

squareIt[(Subscript[z, 1]),  3]

squareIt[(Subscript[z, 1]),  5]

We can see that the values are getting very large in just five iterations, so we'll stop here. [But see To boldly go...  for information on what happens when you ask Mathematica to do astronomical calculations.]

Q: Can you think of a complex number that does not get very large when one applies squareIt to it? Scoll back up and try it!

Let's look at what's happening, using another custom-made Mathematica function, called viewSquares:

viewSquares[(Subscript[z, 1]), 3];

To make it even easier to experiment, we have created a button: viewSquares[■]  which eliminates the need to type this function name over and over.

To use this button, first define a complex number ((Subscript[z, 2]) has been suggested below) by evaluating the defining cell below. Next, type a complex number (or a variable which has been defined as a complex number) and the number of times you which to iterate using your complex number. Finally, highlight the two elements you just typed in, (or select the cell bracket for the data), and click the button:

(Subscript[z, 2])  =  1  -  I;

(Subscript[z, 2]),  3

viewSquares[\[SelectionPlaceholder]]

Try a couple of different complex numbers using the viewSquares[■]  button above.

1  +  I,  3

Q: When the viewSquares button is used, what information is the graph giving you? Can you explain the picture?

III. Off-line thinking

Students should spend some time making sketches and discussing the meaning of a few of these plots before continuing. 
[See Teachers' Notes on On-line/Off-line thinking.]

IV. Which way did it go?

You can quickly verify your off-line sketches, using the showArrows[■] button. The arrows help understand which way the iteration is going. To use this button, highlight (Subscript[z, 1]),3 below and click the showArrows button.

(Subscript[z, 1]),  3

showArrows[\[SelectionPlaceholder]]

Try it again with (Subscript[z, 2]).

(Subscript[z, 2]), 3

Here's an interesting one:

.54  +   .84  I, 30

Mathematica has focused in on what it thinks is the most interesting part of the plot, but we would like to see all the arrows. Therefore, we introduce one more button, showUnitArrows[■] that will allow us to look at everything within a unit square. To use this button, highlight the data in the cell below and click the showUnitArrows button.

.54  +   .84  I, 30

showUnitArrows[\[SelectionPlaceholder]]

We'll close this section with a few other interesting examples, which will lead us into the next section. Highlight each data set and click the showUnitArrows button above.

Cos[π/6]  +  I Sin[π/6],  5

Cos[1.0]  +  I Sin[1.0], 30

Q: When the showUnitArrows button is used, what information is the graph giving you? Can you explain the picture? Can you find an initial complex number that "settles down" onto just a handful of points?

V. Off-line thinking

Students will need some practice plotting complex numbers by hand on the unit circle. 
[See Teachers' Notes on On-line/Off-line thinking.]

VI. Where is this discussion going?

The orbit of a complex number under iteration by the square function.

The set of values we get when we start with a complex number and repeatedly apply a function is called the orbit of the number under iteration by the function. We will study the orbits of numbers under the square function only. The arrows are useful for small iterations. We will come back to them in the section The Fate of Orbits. Now we are going to look at some fairly large interations of an important group of complex numbers, the numbers on a circle of radius 1-also known as the unit circle.

It turns out that when we continually apply and iterate the function f(x) = (x^2) to certain complex numbers, interesting patterns emerge.

Other notebooks go into gross detail about the "envelope" which is created by such iterative functions.

Weblinks

For other information on fractals and chaos using Mathematica, check out the following website

\(Mathematical\ Figures\ Using\ Mathematica

        \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ by\ Robert\ M . \ Dickau\ \)

VII. The  palettes for this notebook

.7

paraSlide[\[SelectionPlaceholder]]

paraSlide[ .7]

Initialization

<< Graphics`Arrow`

squareIt[z_,  n_]  :=  NestList[Function[x,  (x^2)],  z,  n];

reIm[z_]  :=  {Re[z],  Im[z]};

viewSquares[z_,  n_] := 
      ListPlot[Map[reIm[#]&, squareIt[z,  n]],  PlotJoined  ->  True];

mapSquare[z_,  n_] := Map[reIm[#]&, squareIt[z,  n]];

oneArrow[θ_] := 
      Graphics[{Hue[0], 
          Arrow[{Cos[θ],  Sin[θ]}, {Cos[2  θ],  
              Sin[2  θ]}]}];

showArrows[z_,  n_] := 
      Show[Graphics[{Hue[0], 
            Table[Arrow[mapSquare[z,  n][[i]],  
                mapSquare[z,  n][[i  +  1]]], {i, n}]}],  
        Axes  ->  True];

showUnitArrows[z_,  n_] := 
      Show[Graphics[{Hue[0], 
            Table[Arrow[mapSquare[z,  n][[i]],  
                mapSquare[z,  n][[i  +  1]]], {i, n}]}],  
        Axes  ->  True,  
        PlotRange  ->  {{-1,  1},  {-1,  1}}];

\(\(watchOrbit[z_, \ n_]\ \  := \ 
      ListPlot[Map[reIm, \ NestList[#^2&, \ z, \ n]], \ 
		
        PlotJoined\  -> \ True, \ 
        PlotRange\  -> \ {{\(-1.1\), \ 1.1}, {\(-1.1\), \ 1.1}}, \ 
        AspectRatio\  -> \ 1]; \)\)

<<  Graphics`FilledPlot`

\(\(sectX[θ_]\  := \ \ 
      FilledListPlot[
        Join[{{0. , 0. }}, 
          Reverse[Table[{Cos[z], Sin[z]}, 
              \ {z, \ 0, \ θ, \ θ/30}]]], 
		
        Fills\  -> \ {GrayLevel[1.0]}, 
	DisplayFunction\  -> \ Identity]; 
    \)\)

\(\(sect2X[θ_]\  := \ \ 
      FilledListPlot[
        Join[{{0. , 0. }}, 
          Reverse[Table[{Cos[z], Sin[z]}, 
              \ {z, \ 0, 2\ θ, \ θ/30}]]], 
		
        Fills\  -> \ {GrayLevel[0.9]}, 
	DisplayFunction\  -> \ Identity]; 
    \)\)

\(\(txt[θ_]\  := \ 
      Graphics[{Text["z", \ {1.1\ Cos[θ], \ 1.1\ Sin[θ]}], 
          
			Text[\*""\!\(z\^2\)"", 
            \ {1.1\ Cos[2  θ], \ 1.1\ Sin[2  θ]}], 
			
          Text["θ", 
            \ { .3\ Cos[θ\  - \ 0.2], \ 
              0.3\ Sin[θ\  - \ 0.2]}], 
          Text["2θ", 
            \ { .5  Cos[2\ θ], \ 0.5\ Sin[2\ θ]}]}]; \)\)

\(\(drawSketch[θ_]\  := \ 
      Show[{sect2X[θ], \ sectX[θ], oneArrow[θ], 
		
          txt[θ]}, 
        PlotRange\  -> {{\(-1.2\), 1.2}, \ {\(-1.2\)\ , 1.2}}, 
		
        AspectRatio\  -> 1, 
		TextStyle -> {\ FontSize -> 16}, 
        Ticks\  -> \ False, 
	DisplayFunction\  -> \ $DisplayFunction]; 
    \)\)

cardx[theta_] := (1/3) Cos[2 theta]+
                      (2/3) Cos[theta];
cardy[theta_] := (1/3) Sin[2 theta]+
                      (2/3) Sin[theta];

cardArc[θ_]  := 
      ListPlot[Reverse[
          Table[{cardx[z], cardy[z]}, 
             {z,  θ  -  0.3,   θ  +  0.3,  .05}]],  
        PlotJoined  ->  True,  DisplayFunction  ->  Identity];

\(\(paraText[θ_]\  := \ 
      Graphics[{
          Text[\*""\!\(P\_1\)"", 
            \ {1.1\ Cos[θ], \ 1.1\ Sin[θ]}], 
			
          Text[\*""\!\(P\_2\)"", 
            \ {1.1\ Cos[2  θ], \ 1.1\ Sin[2  θ]}], 
			
          Text["P", 
            \ {1.1\ cardx[θ], \ 1.1\ cardy[\ θ]}]}]; \)\)

\(\(paraTextT[θ_, \ t_]\  := \ 
      Graphics[{
          Text[\*""\!\(P\_1\)"", 
            \ {1.1\ Cos[θ], \ 1.1\ Sin[θ]}], 
			
          Text["P", 
            \ {1.2\ t\ Cos[2\ θ] + 
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 
                \((1 - t)\)\ Cos[θ], \ 
              1.1\ t\ Sin[2\ θ] + 
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 
                \((1 - t)\)\ Sin[θ]}, \ {1, \ 0}], 
			
          Text["t=", 
            \ {0.2\ , \ 
              1.1\ t\ Sin[2\ θ] + 
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 
                \((1 - t)\)\ Sin[θ]}, {1, \ 0}], 
			
          Text[t, \ {0.2\ , \ 
              1.1\ t\ Sin[2\ θ] + 
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 
                \((1 - t)\)\ Sin[θ]}, \ {\(-1\), \ 0}], 
			
          Text[\*""\!\(P\_2\)"", 
            \ {1.1\ Cos[2  θ], \ 1.1\ Sin[2\ θ]}]}]; \)\)

\(\(paraPoint[θ_, \ t_]\  := \ 
      Graphics[{Hue[0.7], PointSize[0.02], 
          Point[{t\ Cos[2*θ] + 
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 
                \((1 - t)\)\ Cos[θ], 
              t\ Sin[2*θ] + 
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 
                \((1 - t)\)\ Sin[θ]}]}, \ 
        DisplayFunction\  -> \ Identity]; \)\)

\(\(paraSlide[t_]\  := 
      Show[{sect2X[3  Pi/5], sectX[3  Pi/5], oneArrow[3  Pi/5], \ 
          paraTextT[3  Pi/5, t], \ paraPoint[3  Pi/5, \ t]}, 

        PlotRange\  -> {{\(-1.2\), 1.2}, \ {\(-1.2\)\ , 1.2}}, 
		
        AspectRatio\  -> 1, 
		TextStyle -> {\ FontSize -> 16}, 
        Ticks\  -> \ False, 
	DisplayFunction\  -> \ $DisplayFunction]; 
    \)\)

\(\(paraSketch[θ_]\  := 
      Show[{sect2X[θ], sectX[θ], oneArrow[θ], \ 
          paraText[θ], cardArc[θ]}, 

        PlotRange\  -> {{\(-1.2\), 1.2}, \ {\(-1.2\)\ , 1.2}}, 
		
        AspectRatio\  -> 1, 
		TextStyle -> {\ FontSize -> 16}, 
        Ticks\  -> \ False, 
	DisplayFunction\  -> \ $DisplayFunction]; 
    \)\)