# More on Julia & Mandelbrot Sets, Chaos

## Presentation on theme: "More on Julia & Mandelbrot Sets, Chaos"— Presentation transcript:

More on Julia & Mandelbrot Sets, Chaos
Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, April 7, 2004

Review: Fractals We have looked at three types of fractals:
Turtle Fractals Generated by recursive routines that give commands to a “turtle”. Can be modeled by string productions/L-systems. Such fractals are always curves at heart. Strange Attractors Attractors of an IFS. More on the next few slides … Julia Sets, the Mandelbrot Set, etc. More to come … 7 Apr 2004 CS 481/681

Review: Strange Attractors [1/3]
An iterated function system (IFS) consists of one or more functions (“maps”) that are repeatedly applied to their own outputs. IFS’s of various sorts are heavily used in mathematical modeling. The orbit of a point under an IFS is the set of all points that the IFS sends it to. The attractor of an IFS is the set of points that the IFS moves points toward. For example, the IFS on the real number line with the single map x → x/2, has the point x = 0 as its attractor. If an attractor is a fractal, then it is said to be a strange attractor. 7 Apr 2004 CS 481/681

Review: Strange Attractors [2/3]
If an IFS has a single map, and this map is an affine function, then it never has a strange attractor. We can create IFS’s with strange attractors by: Using multiple affine maps See ifs1.cpp. Using non-affine maps We have not done this yet. 7 Apr 2004 CS 481/681

Review: Strange Attractors [3/3]
To draw an approximation of an attractor, begin with a random point, and draw its orbit. That is: Choose a point. Repeat: Draw the point. Send the point through the IFS. If there are multiple maps, then this means choosing a random map and applying it. In some IFS’s points approach the attractor rather slowly. In these you may want to send a point through the IFS many times before you begin drawing. See ifs1.cpp for example code. 7 Apr 2004 CS 481/681

Review: Julia Sets [1/2] We have seen how to describe fractals as IFS attractors, as well as how to draw these. There is another way to create fractals using IFS’s: The fractal is the set of all points that are not “sent to infinity” by the IFS. A point is “sent to infinity” if its orbit is not contained in any bounded region. 7 Apr 2004 CS 481/681

Review: Julia Sets [2/2] Using this method, we can draw interesting fractals in the complex plane. The complex plane is just the collection of all complex numbers, represented using Cartesian coordinates. So the point (x, y) corresponds to the complex number x + yi. The Idea Pick a fixed complex number c = a + bi. Our IFS has one map: z → z2 + c. This map is not affine! The not-sent-to-infinity set for this IFS is called a filled Julia set (or “filled-in Julia set”). For every complex number, there is a corresponding filled Julia set. 7 Apr 2004 CS 481/681

Review: The Mandelbrot Set
Suppose we do the same process as with a filled Julia set, except that the number we add to the square is the number we started the iteration with. In other words, our map is z → z2 + c, where c is the first complex number in our iteration. So the sequence goes c, c2 + c, (c2 + c)2 + c, ((c2 + c)2 + c)2 + c, etc. When we use this process, the not-sent-to-infinity set is called the Mandelbrot set. There are many Julia sets, but only one Mandelbrot set. The Mandelbrot set is the collection of all complex numbers that lie in their own filled-in Julia sets (right?). 7 Apr 2004 CS 481/681

More on Julia & Mandelbrot Sets: Computation
How do we compute maps like z → z2 + c when z and c are complex? Write complex numbers as real & imaginary parts, and work it out. For example, let z = x + yi, and let c = a + bi. Then, So, representing each complex number as two real numbers, we have two maps, both of which are applied each time: x → x2 – y2 + a y → 2xy + b (be sure to use the old x-value here!) 7 Apr 2004 CS 481/681

More on Julia & Mandelbrot Sets: How to Draw [1/3]
How do we draw a not-sent-to-infinity set? Given a point, we need some way to figure out whether it is sent to infinity. In general, this is very difficult. So we find ways of making good guesses. Often the region around a set is actually more interesting than the set itself. So we look at a way of coloring the region around a set. 7 Apr 2004 CS 481/681

More on Julia & Mandelbrot Sets: How to Draw [2/3]
An Idea Pick a threshold distance. We will assume that, if a point eventually ends up farther than this from zero, then the point is heading to infinity. Given a point, apply the appropriate process to the point until: The distance from zero exceeds the threshold. In this case, we guess that the point is outside the set. OR: Some iteration limit is met. In this case, we guess that the point lies in the set. Now apply this to every point in our drawing region. Point in the set are one color (traditionally, black); points outside the set are a different color. Note: There are other methods; you may want to look into them. 7 Apr 2004 CS 481/681

More on Julia & Mandelbrot Sets: How to Draw [3/3]
It is often of interest how long a point outside the set “dwells” inside the threshold. This “dwells count” can result in a very nice way to color the region around Mandelbrot & Julia Sets. Simply choose a color based on the count. Threshold distance 2 works well with the Mandelbrot set. It has been proven that if a point ever exceeds distance 2, then it is definitely heading to infinity. So this threshold gives you a way to be sure a point is not in the M-set. However, it does not give you a way to be sure the point is in the M-set. As you view smaller & smaller regions, getting decent images will require increasing the iteration limit. 7 Apr 2004 CS 481/681

More on Julia & Mandelbrot Sets: Interface Issues [1/2]
Drawing Mandelbrot & Julia sets (and other fractals) can be very time-consuming. Thus, the standard GLUT approach (drawing the whole image at each display call) may not be appropriate. One Solution Keep an off-screen image, which starts blank and is slowly filled in. The display function draws this image. If the image is incomplete, then the idle function determines the color of a few more points in the image, and posts a redisplay event. 7 Apr 2004 CS 481/681

More on Julia & Mandelbrot Sets: Interface Issues [2/2]
Zooming in and out is a nice feature. Zoom in on a point the user clicks on? Or have the user outline a rectangle, and use this region as the new drawing region. Since images take time to render, it can be nice to render a lower-resolution version first. If a bit of thought is put into this, then the pixels the low-resolution image can become some of the pixels in the eventual high-resolution image. 7 Apr 2004 CS 481/681

More on Julia & Mandelbrot Sets: Other Maps
These ideas can be applied using just about any other map on the complex numbers. Suppose f is a function that takes two complex numbers and returns a single complex number. We can use z → f(z, c) in place of z → z2 + c. An obvious map to try next is z → z3 + c. 7 Apr 2004 CS 481/681

Chaos: Introduction A concept that has had a profound effect on much of the scientific thinking of the late 20th century is “chaos”. Chaos refers to the complex, difficult-to-predict behavior found in nonlinear systems. A function is nonlinear if it is not linear. We generally toss out affine functions, too. The first recorded instance of someone noticing chaotic behavior in a simple system was Edward Lorenz in 1960, while studying mathematical models of weather. Before this, the “standard wisdom” was that systems with simple descriptions always had simple behavior; now we know that this is not true. 7 Apr 2004 CS 481/681

Chaos: The Butterfly Effect
One of the important properties of chaos is “sensitive dependence on initial conditions”, informally known as “the Butterfly Effect”. This term possibly originated from the title of a talk Lorenz gave to the AAAS in 1972: “Predictability: Does the Flap of a Butterfly’s Wings in Brazil set off a Tornado in Texas?”. Sensitive dependence on initial conditions means that a very small change in the initial state of a system can have a large effect on its later state. In particular, you can eventually get the large effect, no matter how small the initial change was. 7 Apr 2004 CS 481/681

Chaos: Discovery Again, chaos was first noticed in 1960.
Lorenz was studying a mathematical model of weather. He was confused by the apparent fact that, in two runs of his program, the same input data was giving completely different output. The different results turned out to be caused by a very slight difference in the input data: a 6-decimal-place value in one input ( ) was truncated to 3 decimal places (0.506) in the other. This was still confusing, since the change seemed insignificant. However, we now know that weather is a chaotic system; the Butterfly Effect is real. Lorenz found a simpler system that exhibited the same behavior. This system (the Lorenz Butterfly) is now one of the standard examples of a chaotic system. Next we build up some background and define “chaos”. 7 Apr 2004 CS 481/681

Chaos: IFS’s & Dynamical Systems
Recall: An iterated function system (IFS) consists of one or more functions, repeatedly applied to their own outputs. The domains & codomains of all the functions must be the same. The IFS’s we consider here will each consist of a single function. Simple example: f(x) = x+5. Initial value: x0 = 2. Then x1 = f(x0) = 2+5 = 7. x2 = f(f(x0)) = f(x1) = 7+5 = 12. And so on … (no chaos here). A related concept is that of a “continuous dynamical system”. In an IFS (also called a discrete dynamical system), we describe the state of the system at discrete time intervals (0, 1, 2, …). In a continuous dynamical system, we describe the state of the system all the time, usually with a system of differential equations. In practice, continuous systems are often converted to discrete systems in order to approximate their solutions. So we can reasonably confine our attention to IFS’s. 7 Apr 2004 CS 481/681

Chaos: Orbits & Periodicity
Suppose we have an IFS with exactly one function: f:S → S. Recall: Given a point x in S, the orbit of x is the collection of all points that the IFS takes x to. That is, the orbit of x contains x, f(x), f(f(x)), f(f(f(x))), etc. x is a periodic point if repeatedly applying f eventually takes x back to itself. Put another way: A periodic point is a point whose orbit is finite. 7 Apr 2004 CS 481/681

Chaos: Definition An IFS with one function f:S → S is exhibits chaos (equivalently, it is chaotic) if it has the following properties: Sensitive dependence on initial conditions. Periodic points are dense in S. This means that, no matter where you are in S, there is a periodic point nearby (as near as you want). f is topologically transitive. This means that, if you pick two points x, y in S, then there is a point near x whose orbit takes it near y (again, both occurrences of “near” mean “as near as you want”). Some researchers have used other definitions of chaos; this definition appears to be the one most commonly used. Some informal essays on chaos suggest that sensitive dependence is the defining characteristic of chaos. But this is not true; consider f(x) = 2x. 7 Apr 2004 CS 481/681

Chaos: DEMO Demo time! In class, chaos.cpp was demonstrated.
7 Apr 2004 CS 481/681

Chaos: Notes Chaotic systems generally have strange attractors.
Think “pretty pictures”.  When we say a chaotic system is “unpredictable”, we do not mean that it is nondeterministic. A deterministic system is one that always gives the same results for the same input/initial values. Real-world chaotic systems are “unpredictable” in practice because we can never determine our input values exactly. Thus, sensitive dependence on initial conditions will always mess up our results, eventually. A chaotic system does not need to be very complex [for example, f(x) = ax(1–x) is pretty simple], but it does need to be nonlinear. So methods that approximate functions by linear/affine functions (e.g., Newton’s Method) can sometimes give qualitatively different behavior than that which they purport to approximate. 7 Apr 2004 CS 481/681