To start, enter a seed above; the seed is how far around the unit circle to start,

e.g. the value 1/5 puts your first point 1/5 of the way around the circle (counter-clockwise starting at 1+0i).

The position is converted to a complex number, and will be represented on the complex plane on a unit circle (below).

Each time you iterate, a line is drawn from the current position to the current position squared, which becoms the new starting position for the next iteration.

The program squares the position as a complex number, but it is easier to visualize as a polar form (magnitude and angle instead of a + bi).

The magnitude is 1 (because the point is on a unit circle). When the complex number is squared, the magnitude is squared so it remains 1, and the angle is doubled.

In the example where the seed angle was 1/5 the line will be drawn from (in polar coordinates):

- [1, 1/5] to [1, 2/5] after one iteration

- [1, 2/5] to [1, 4/5] after the second iteration

- [1, 4/5] to [1, 3/5] after the third iteration

- [1, 3/5] to [1, 1/5] after the fourth iteration

Now try it (press Iterate several times). Notice those lines form an irregular polygon.
All rational seed angles will create a polygon when iterated. Try a few more seeds to verify that (enter a new seed and hit clear).

Hit clear and proceed to Step 2.

Because each point is stored as a complex number (a + bi, each rounded to appx. 14 places), it is subject to rounding error with each iteration.

Chaotic systems have a *sensitive dependence on initial conditions*. Because of the rounding error, the points quickly drift away from the initial polygon.

By iterating several times (default 25) you can see the effect:

- if rounding causes the magnitude to be ever so slightly less than one, the points approach (0, 0) (the center of the circle)

- if rounding causes the magnitude to be greater than one, repeated squaring causes the magnitude to approach infinity.

Once they reach that point, any further squaring has no effect.

Try it now; hit Iterate several times until you see the expected behavior. Perhaps try a few seed values to see that some approach 0 and others infinity.

Then, hit clear and proceed to Step 3.

Now, the error in magnitude is fixed after each squaring by dividing the vector by its magnitude.

In polar, this is equivalent to resetting the magnitude to 1 without changing the angle of the point.

However, this still leaves a rounding error in the angle.

Try a few iterations.

After several iterations, the resulting lines suggest a cardioid!

Why? Dunno.