Stories about Fractal Plotting




Contents Preparations: Canvases, Dynamical Systems and Iterations
The Divergence Scheme
The Mandelbrot Set and Its Complexity
The Convergence Scheme
Mandelbrot Fractals
Julia Fractals and Julia Sets
Newton Fractals
Enhancements
3D Renderings
Appendix
Fractal Coloring
Galleries
Gallery 2D
Gallery 3D
Speaking loosely without using technical terms such as the HausdorffBesicovitch dimension, a fractal is an object that is selfsimilar, i.e., a large part of it contains smaller parts that resemble the large part in some way; see Figures 0.10.5 below. Mathematician Benoit Mandelbrot coined the term “fractal” in 1975 and created a branch of mathematics called fractal geometry seven years later. As an "IBM Fellow," he had access to some of the best computers available for his research at the time.
Our world has fractals everywhere exemplified by trees, mountains, blood vessels, mycelium strands, stock market graphs, weather patterns, seismic rhythms, ECG signals and brain waves. In its article entitled "How Mandelbrot's fractals changed the world," the BBC states that fractal geometry has practical applications in diverse areas including diagnosing some diseases, computer file compression systems and the architecture of the networks that make up the Internet.
Figure 0.1. The Mandelbrot Set
 Figure 0.2. Julia Set
 Figure 0.3. Newton Fractal

The idea of fractal was not particularly new in mathematics for Mandelbrot's time or the computer age, as Georg Cantor introduced the prototypical "Cantor Set" in 1883 almost 100 years before Mandelbrot published his book entitled "The Fractal Geometry of Nature." During the early 20th century, Pierre Fatou and Gaston Julia laid the foundations for fractals generated by "dynamical systems." It was in 1980 when Mandelbrot showed the famous fractal called the "Mandelbrot set" generated by a simple dynamical system and a computer. Almost immediately after that, the novelty and complexity of the Mandelbrot set reinvigorated the interests in fractals and stimulated mathematicians to develop further theories in fractal geometry.
 Figure 0.4. Classical Fractals by Geometric Constructions


Koch Snowflake, 1904
 Sierpinski Rectangle, 1916
 Pythagorean Tree, 1942

On the other hand, chaos often associated with fractals, was basically born as a brand new subject in 1974 from biologist Robert May's computer simulations of population dynamics through the dynamical system called the logistic equation. Like "fractal," the word "chaos" was used as a mathematical term for the first time in 1975 when the American Mathematical Monthly published "Period Three Implies Chaos" by T.Y. Li and James Yorke. The paper received a great sensation especially because there appeared very little difference between chaotic and random outcomes even though the former resulted from deterministic processes. It is now known that fractals and chaos are closely related and together they provide applications not only in sciences but also in art.
Figure 0.5. Fractals Generated by the Logistic Equation
Painted on a sphere
Through Google, we find numerous websites that display stunningly beautiful computergenerated fractal art images. It indicates that a large population not only appreciates the digital art form but also participates in the eyeopening creative activity. Written below is a guide on how to program a computer and plot popular types of fractals generated by simple dynamical systems. It is not a text on computer programming or coding. Instead it tells the general principles needed for fractal plotting without going into too many specifics. It assumes the readers' basic programming experience and encourages them to be creative and engage in frequent computer experiments based on the essentials.
Particularly exciting is the moment the fractal image generated by our personal program emerges in our computer screen because of its rather unpredictable nature. The intricate fractal patterns often change dramatically when we alter some of the input values slightly  perhaps influenced by the unpredictable "butterfly effect" of chaos. The reader who may be merely intrigued by the general idea behind fractal plotting is encouraged to try it. Many of the images will stir our imaginations in the part of mathematics that is in fact quite deep and still filled with unknowns. Best of all, though, it is plain fun.
§ 1. Preparations
The readers who want to try it out need to know (a) fundamental algebra and geometry of complex numbers, (b) beginning calculus, and (c) basic computer programming in such language as C++, Delphi (Pascal) and Java.
(a) includes the practice of writing a complex number z as a point (x,y) in the xyplane as well as the standard algebraic expression z = x + yi and ability to do basic arithmetic of complex numbers such as multiplication, division and exponentiation. The complex plane means the set of all complex numbers z = (x,y) which coincides with the Cartesian xyplane. For each complex number z = (x,y), the absolute value of z means z = √(x^{2} + y^{2}) and it represents the distance of z from the origin O of the complex plane. More generally, if z and w are complex numbers, z  w represents the distance between the complex numbers. (b) includes the basic ideas about the
derivative and a critical point of a function where the derivative vanishes. Particularly important in (c) is a twodimensional (2D) array of numbers.
We now introduce several preliminary ideas needed for fractal plotting.
Canvases: We begin with a simple example.
Let R be the rectangle in the complex plane defined by 3 ≤ x ≤ 3 and 2 ≤ y ≤ 2 and suppose we wish to plot the graph of the inequality x^{2} + y^{2} ≤ 1 on R using a computer. We first decompose R into, say, 1,920 x 1,080 miniature rectangles of equal size called picture elements or pixels and then represent the pixels by pixel coordinates (i, j) in such a way that the upper left and lower right pixels are (0, 0) and (1919, 1079), respectively. Thus, the i and jaxes of the pixel coordinate system are the rays emanating from the origin O=(0,0) and pointing east and south, respectively; see the figure below on the right.
Let imax = 1919, jmax = 1079, xmin = 3, xmax = 3, ymin = 2 and ymax = 2. Then for each i = 0, 1, 2, · · ·, imax and j = 0, 1, 2, · · ·, jmax, the pixel (i, j), which is a rectangle, contains infinitely many complex numbers (x, y). For our computational purpose, we choose exactly one representative (x, y) in the pixel (i, j) by setting
(1.1) Δx = (xmax  xmin) / imax; Δy = (ymax  ymin) / jmax,
(1.2) x = xmin + i Δx; y = ymax  j Δy.
Consequently, we may view R as the rectangle comprising 1,920 x 1,080 pixels, each of which has a unique representative complex number. The rectangle R with the pixel structure is called a canvas for plotting the output image with the image resolution of 1,920 x 1,080 pixels.
Plotting the graph of the inequality x^{2} + y^{2} ≤ 1 on the canvas is now easy. We examine each pixel (i, j), er the representative complex number (x, y) on the canvas R. If it satisfies the inequality, color the pixel red, and otherwise, color it white. Since the coloring process uses only finitely many pixels of the canvas R, the output image that resembles the Japanese flag is an approximation of the true graph. The greater the number of pixels, the higher the image resolution and the more accurate the output image.
The pictures below depict a fractal called "Goldfish in Love" instead of the Japanese flag, but they illustrate all of the ideas discussed above. The picture on the left is the true graph in the complex plane (which we can not see as it is not computable) and the picture on the right (which is a resized image of the output) is its approximation by a computer on the canvas in the pixel coordinate system. Since imax and jmax are both sufficiently large, we assume that the approximation is sufficiently accurate.
Remark on Aspect Ratio: In the aforementioned argument, imax, jmax, xmin, xmax, ymin, ymax are input numbers to our computer program. An easier way is to input imax, jmax and the center and horizontal radius of the rectangle in the xyplane and program the computer to calculate xmin, xmax, ymin, ymax so as to ensure that the two rectangles in the above figures have the same aspect ratio.
Dynamical Systems and Iterations: When we solve a mathematical problem using a computer, we usually do it by exploiting what the machine does best, namely an iteration, which means repeating a certain process over and over, often for thousands or even millions of times, at a blinding speed. As an example of iterations, consider the equation called the Mandelbrot equation
(1.3)
z_{n+1} = z_{n}^{2} + p ,
which involves two indexed variables z_{n+1} and z_{n} and the third variable p called a parameter. All variables vary through complex numbers. The iteration index n is especially important for fractal plotting and it is there for us to iterate the equation to generate a sequence of numbers once the value of p and initial value z_{0} are given. For instance, let p = 2 and z_{0} = 0. Then setting the index n = 0, 1, 2, · · · in (1.3), our properly programmed computer iterates (1.3) and calculates the sequence of numbers
z_{1} = z_{0}^{2} + p = 0^{2}  2 = 2 ,
z_{2} = z_{1}^{2} + p = (2)^{2}  2 = 2 ,
z_{3} = z_{2}^{2} + p = 2^{2}  2 = 2 ,
and similarly, z_{n} = 2 for n = 4, 5, 6, · · · . If we hold the value of z_{0} at z_{0} = 0 and change the value of p from p = 2 to p = 1.9 in (1.3) then the computer again iterates (1.3) and calculates thousands of terms within a fraction of a second to give us the sequence of numbers
z_{0} = 0, z_{1} = 1.9, z_{2} = 1.71, z_{3} = 1.0241, · · · , z_{30} = 1.1626, z_{31} = 0.5483, · · · .
Similarly, if we leave the value of p fixed at p = 2 and change the value of z_{0} from z_{0} = 0 to z_{0} = 0.1, we get
z_{0} = 0.1, z_{1} = 1.99, z_{2} = 1.9601, z_{3} = 1.842, · · · , z_{30} = 0.7157, z_{31} = 1.4877, · · · .
Note that the behavior of the sequence may change drastically if we alter the value of p or z_{0} slightly. We exploit such changes to draw an intricate fractal with a variety of colors.
We have shown only real sequences for simplicity, but actual numbers involved in fractal plotting are complex numbers in the complex plane. Thus, the Mandelbrot equation (1.3) comprises infinitely many sequences of complex numbers, one sequence z_{n} for each choice of values of p and z_{0}. Because most of the infinitely many sequences hop around in the complex plane as n increases, it is appropriate to call the Mandelbrot equation a dynamic mathematical system or dynamical system. As we shall see in § 5, there are infinitely many dynamical systems including (1.3) and the logistic equation (5.3) that can be used for fractal plotting.
pCanvases, zCanvases and Orbits: Although the following idea applies on a wider variety of dynamical systems, consider, for the sake of simplicity, the dynamical system (1.3) with a fixed value of z_{0}, say, z_{0} = 0. As we have seen then, each value of p in (1.3) generates a sequence z_{n} of complex numbers, which we call the orbit of p (with the fixed value of z_{0}). "Sequence" and "orbit" generally have a subtle difference in mathematics but we won't distinguish them here for simplicity.
Recall that a canvas is a rectangle in the pixel coordinate system comprising r x s pixels for some positive integers r and s and that each pixel is identified with a unique complex number. Interpreting these complex numbers as values of p in (1.3), we call the canvas a pcanvas (with the fixed value of z_{0}) for the dynamical system (1.3). Thus for each p in the pcanvas, there is a unique orbit of p, and as we shall see in § 2 and § 4, we will plot a fractal on the pcanvas by looking at certain behaviors of the orbits. Figure 1.1 is a preview of what we might see on pcanvases.
Figure 1.1. Fractals on pCanvases Generated by the Mandelbrot Equation
Now, suppose p is a fixed constant in the dynamical system (1.3) while z_{0} is a variable. Then by the symmetric argument, we can talk about a zcanvas comprising finitely many pixels, each of which is identified with a unique value of z_{0}, which in turn gives rise to a unique sequence z_{n} called the orbit of z_{0}. Thus, as we shall see, we plot fractals on the zcanvas by looking at certain behaviors of the orbits of z_{0}. Figure 1.2 shows typical fractals we might see on zcanvases.
Figure 1.2. Typical Fractals on zCanvases


Back to the
Top


§ 2. The Divergence Scheme
We say that a sequence z_{n} of complex numbers diverges to ∞ if the real sequence z_{n} diverges to ∞, i.e., if z_{n} gets further away from the origin of the complex plane without bound as n gets larger. Our goal of § 2 is to introduce the fractal plotting technique associated with the notion of divergence of orbits of p using the aforementioned Mandelbrot equation (1.3) as an example.
Define a function f_{p} of a complex variable z involving a complex parameter p by setting f_{p}(z) = z^{2} + p and write the Mandelbrot equation as
(2.1) z_{n+1 }= f_{p}(z_{n}) = z_{n}^{2} + p.
The derivative of the function f_{p} is f_{p}'(z) = 2 z so the critical point of f_{p} is z = 0. As we go on, it will become clear why the critical point is important and why we often (but not always) use a critical point as the initial value z_{0}. If z_{0} is a critical point, we call the orbit of p a critical orbit. Throughout § 2  § 4, we set
(2.2) z_{0} = 0,
so all orbits are critical orbits of p.
Suppose R is the square in the complex plane with center 0 and radius 2.1, so it is bounded by xmin = 2.1, xmax = 2.1, ymin = 2.1, and ymax = 2.1, and regard R as the pcanvas with an image resolution of 400 x 400 = 160,000 pixels. As we have seen in the preliminary ideas, we may identify each pixel in the canvas with a unique parameter p in R. Paint the whole canvas white initially.
Let M = 500 and for every pixel, er parameter p, in the pcanvas R, iterate (2.1) at most M times. Thus, M is the maximum number of iterations, which is intended to "approximate" ∞ and also thwart the computer to get trapped in an infinite loop. Here's a simple instruction to our computer:
If
z_{1} > 2 then color the pixel p black ,
else if z_{2} > 2 then color the pixel p red ,
else if z_{3} > 2 then color the pixel p black ,
· · ·
else if z_{M} > 2 then color the pixel p red .
It can be shown that
(†)
z_{m} > 2 for some m if and only if the orbit z_{n} of p diverges to ∞ ;
hence the above scheme assigns a color to each pixel p in the pcanvas R according to how quickly the orbit z_{n} of p escapes from the circle of radius 2 before taking a long journey toward ∞. We call the algorithm the divergence scheme.
The divergence scheme can be streamlined in an actual computer program by using:
just two variables zold and znew instead of the array z_{0} , z_{1} , z_{2} , ... , z_{n} , ... ,
a greater number of colors, and
z_{n}^{2 }> 4 in place of z_{n}
> 2 to avoid the square root operation hidden in the absolute value.
The Mandelbrot Set: By definition, the famous Mandelbrot set, or the M set for short, is the set of all complex parameters p whose critical orbits do not diverge to ∞, or equivalently, the set of all parameters p whose critical orbits stay within the circle of radius 2 forever. The white "snowman" of Figure 2.1, which is left untouched by the above redblack divergence scheme and retains the initial white canvas color, depicts an approximation of the Mandelbrot set on the pcanvas given by replacing "forever" by "up until M = 500 ". Theoretically, such approximation gets better as M gets bigger, but for our small canvas of 400 x 400 pixels, the use of any M > 500 will just waste the computing time without improving the output image.
Choosing Good pCanvases: (†) implies that the Mandelbrot set stays within the circle of radius 2, which explains why we chose the pcanvas to be the square of radius little over 2. We also note in Figure 2.1 that the redblack pattern gets more intricate in areas nearer the boundary of the Mandelbrot set. It explains why we almost always zoom in on a small neighborhood of a point near the boundary of the Mandelbrot set so as to produce good fractals from the Mandelbrot equation (2.1). It is extremely unlikely to get something interesting without knowing a "global" image of the Mandelbrot set such as Figure 2.1.
Example: Figure 2.2 is given by zooming in on a small neighborhood of a point which is just outside of the Mandelbrot set but very near its boundary. It is a cropped and resized image from a fractal on a large pcanvas with 6400 x 3200 pixels centered at the point (0.2820607, 0.011014375) with the horizontal radius 0.0000011. The large canvas and M = 100,000 are used to allow a high resolution printout. The part of the Mandelbrot set shown in the figure is painted black and the exterior of the Mandelbrot set various shades of green, sky blue, blue and red. Note that the figure shows several replicas of the snowman painted black that look like small isolated islands.
Figure 2.2. Fractal by the Mandelbrot Equation and the Divergence Scheme
Choosing Good Parameters: To find a parameter such as p = (0.2820607, 0.011014375) shown above, plot a "global" image of the Mandelbrot set like Figure 2.1 on a larger canvas, choose a pixel (i, j) of our interest in the image and then convert the pixel coordinates (i, j) to Cartesian coordinates (x, y) = p using the conversion formula (1.2).
Threshold Values: The nimber, 2, in the inequality z_{n}
> 2 is called a threshold value of the divergence scheme. Interestingly, (†) implies that we can actually use any radius greater than 2, say 10, as a threshold value, so z_{n} > 10 works just as well or even better sometimes in plotting fractals from the Mandelbrot equation. Such observation becomes important when we deal with a different dynamical system without knowing what number to use as a threshold value.
Computer Experiments: There are many numbers in fractal plotting which we can "optimize" only by trialanderror computer experiments. For example, the maximum number of iterations M that produces a good output image within a reasonable computing time depends not only on the size of the canvas but also on what we are plotting and we can find it only through experiments.
.
§ 3. The Mandelbrot Set and Its Complexity
The Mandelbrot set is famous for a reason and it turned out to be one of the most complex figures ever plotted on a plane. Although it may not sound obvious unless we know something about fractal dimensions, the following celebrated theorem guarantees that no figures on the plane are more convoluted than the Mandelbrot set.
Shishikura's Theorem: The fractal dimension of the boundary of the Mandelbrot set is the same as the dimension of the plane, namely 2.
If we apply the divergence scheme on the Mandelbrot equation (2.1) with a greater number of colors and zoom in on a microscopic area near the boundary of the "snowman" in Figure 2.1, we may catch a glimpse into how complex the set really is. For example, Figure 3.1 is a cropped/resized image from a fractal on the pcanvas with 4,000 x 4,000 pixels centered at the point
p = (0.25000316374967, 0.00000000895902)
with a microscopically small radius ≈ 0.0000000000001 = 10^{13}. We note that the body of the white snowman in Figure 2.1 is bounded by a "cardioid," whose cusp (or sharp point) is at the point (0.25, 0); it is very near the point p.
Figure 3.1. A Snowman Under the Microscope
M = 1,500,000

 M = 500,000

The picture shows a replica of the "snowman" at the center but it actually contains infinitely many such replicas. With experience our eyes become sharper in spotting where many of the replicas hide and it helps us realize that the Mandelbrot set is indeed selfsimilar and a fractal in that sense. By the definition of the Mandelbrot set, the "colorful" area (which is painted in colors other than black) depicts outside or the complement of the Mandelbrot set. Here is another amazing theorem:
The DouadyHubbard Theorem: The Mandelbrot set is connected.
So, all of the replicas of the snowman are connected by an invisible network that belongs to the Mandelbrot set, thereby shaping the intricate and complex pattern shown in Figure 3.1. It is also known that the Mandelbrot set is "simply connected," i.e., the connecting network has no loops. Not surprisingly, therefore, it is also true that the complement of the Mandelbrot set comprising all those colorful pieces is connected as well.
Plotting the boundary of the snowman with reasonable accuracy always demands a higher maximum number M of iterations because of ∞ involved in the definition of the Mandelbrot set, and for the picture on the left in Figure 3.1, we used whopping M = 1,500,000. If we use M = 500,000 (still a large number) instead, the outline becomes blurry as shown in the picture on the right. It is astounding that the difference between the two pictures comes from so many additional iterations of the Mandelbrot equation.
Digression: I have two Pentium XP machines with 4 gigabytes of RAM and use one of them to do tedious and timeconsuming jobs. Many of the jobs involve a large canvas with as many as 6,400 x 6,400 pixels and often require days or even weeks of computing time. I bought the workhorse used for $89 by net shopping in 2015. We live in a good world, where computers are inexpensive and minimizing computing time is not such a big deal as it used to be.
Project for Multivariable Calculus Students: Computersavvy students who are used to draw geometric shapes such as spheres and pyramids in the threedimensional (3D) space can devise fun projects of creating 3D landscapes in digital art. In Figure 3.2 shown below, the first image is another closeup of the boundary of the Mandelbrot set and parts of it are mapped onto the sphere, cone and pyramids. Note that the 2D fractal image is also used as the night sky. In this website, we often plot fractals on nonplanar surfaces including spheres and tori so as to indicate expanded possibilities.
Figure 3.2. The Mandelbrot Set Near p = (0.68852, 0.27985) on Various Surfaces
Errors in Computation: Aside from programming bugs and other human errors, fractal plotting entails two unavoidable errors, each of which contributes to a loss of mathematical precision in the output. One is the truncation error resulting from "truncating" the infinite process after the finite number of steps given by M and the other is the roundoff error caused by our "imperfect" computer that has to round almost every real number involved. In my program, M is usually between 500 and 100,000 but it occasionally gets as large as 1,500,000 as shown in the above example. Using larger M is better in theory as it reduces the truncation error but is worse in practice as it makes the computing time longer and at the same time causes more roundoff errors to propagate. Balancing the good and the bad to find an optimum number M is a difficult problem in computing. Although it is not an issue if our goal is in art, it is something we should keep in our mind. Computers are great tools for mathematical research but they mislead us from time to time.
§ 4. The Convergence Scheme
We are not done yet with the complexity of the Mandelbrot set and still stay with it. The Mandelbrot set has become so illustrious, everybody with at least some interest in fractals knows its "snowman" shape in Figure 2.1 by heart: The main body is in the form of a heartshaped "cardioid" with a bunch of circular disks attached, and to each of the disks another bunch of disks are attached. The pattern repeats as if the cardioid has children, grandchildren, great grandchildren and so on so forth, but beyond that nobody knows exactly what's happening. Here, the cardioid means the bounding curve together with its interior.
As we have seen, the divergence scheme paints the cardioid and all of the disks in a single color like white as it is incapable of distinguishing them. Our current goal is to find their distinguished mathematical properties and paint them in various colors, like Figure 4.1 below, by developing a scheme that is different from the divergence scheme.
Figure 4.1. The Mandelbrot Set in Colors
A sequence z_{n} of complex numbers is called a cycle if there is a positive integer k satisfying z_{n} = z_{n+k} for any index n. The smallest such integer k is called the period of the cycle, and a cycle with period k is called a kcycle for short. For example, the sequence
1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, · · ·
is a 3cycle but not a 6cycle or a 9cycle. The sequence 0, 0, 0, 0, · · · is a 1cycle, which we identify with the constant 0. A sequence z_{n} is said to converge to a kcycle if it acts more and more like the kcycle as n gets bigger.
Example 1: The sequences 1/2, 1/3, 1/4, 1/5, 1/6, · · · and 1/2, 2/3, 3/4, 4/5, 5/6, · · · converge to the constants 0 and 1, or equivalently, to the 1cycles 0, 0, 0, 0, · · · and 1, 1, 1, 1, · · ·, respectively. Therefore, the sequence
1/2, 1/2, 1/3, 2/3, 1/4, 3/4, 1/5, 4/5, 1/6, 5/6, · · ·, 1/1000, 999/1000, 1/1001, 1000/1001, · · ·
converges to the 2cycle 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, · · ·, 0, 1, 0, 1, · · ·.
People who are familiar with the socalled "(N, ε) arguments" can define the aforementioned notion of convergence in a precise way and easily prove the following key fact for our purpose:
Theorem: If a sequence z_{n} converges to a kcycle then for any ε > 0, there is an integer N such that n > N implies
(4.1) z_{n+k}  z_{n} < ε.
Thus, our convergence scheme with period index k is given by replacing z_{n} > 2 of the divergence scheme by the inequality (4.1), where ε is a small positive real number such as 10^{6} or min{Δx, Δy}; see (1.1) and Computer Experiments.
The convergence scheme with period index k is intended to detect every parameter whose orbit converges to a kcycle and also the "speed of convergence" of the orbit that is used to color the parameter (pixel) just like the divergence scheme. We will talk about "a parameter whose orbit converges to a kcycle" frequently, so let's call such parameter a parameter of period k for short. In particular, a parameter of period 1 is the same as a parameter whose orbit converges to a single point (1cycle).
Weakness of the Convergence Scheme: The convergence scheme is based on the aforementioned theorem, which is unfortunately a oneway street and whose converse is not necessarily true. For example, the convergence scheme with k = 1 may be fooled by an orbit that diverges to ∞ very slowly and treat it like a convergent orbit. Secondly, the convergence scheme obviously confuses a parameter of period, say, 3 with a parameter of period 6 or 9. For almost all practical problems, however, we can overcome these shortcomings by carefully programming a computer to do the right thing.
Example 2: The figure on the left shows the output of a "good" computer program based on the convergence and divergence schemes. The convergence scheme detected: (1) the interior of the cardioid of the Mandelbrot set comprises parameters of period 1 and painted it by various shades of red; (2) the interior of the largest disk comprises parameters of period 2 and painted it by various shades of orange; (3) the interior of the second largest disks (there are two of them) comprises parameters of period 3 and painted it by various shades of orange; and so on so forth. The role of the divergence scheme is to paint the complement of the Mandelbrot set black and direct the convergence scheme to work only on the interior of the Mandelbrot set.
Periodicity Diagram: If we use Example 2 and label the cardioid with its periodicity 1, the largest disk with its periodicity 2 and the second largest disks with its periodicity 3, etc., we get a diagram similar to Wikipedia's Periodicity Diagram. The periodicities have interesting numerical patterns that are easy to recognize and will play a crucial role when we plot colorful "Julia sets" in § 6. For many of the dynamical systems, it is fairly easy to build our own periodicity diagrams with similar numerical patterns. We can use them to plot a wider variety of Julia sets.
The Eyeball Effect: The weakness of the convergence scheme mentioned above is not entirely bad as it sometimes acts up and gives us an interesting pattern. The picture below on the left is essentially the same as Figure 3.1 and is given by the divergence scheme alone while the one on the right is painted by the divergence scheme (with different colors) and the convergence scheme with k = 1. The "eyeballs" painted by the convergence scheme show which parameters are affected. Figure 6.7 illustrates the effect more vividly.
Figure 4.2. The Eyeball Effect (Right) Given by the Convergence Scheme
Fractal Enhancement: Figure 4.1 is given by the divergence and convergence schemes followed by an additional shading technique we discuss in § 8. The technique makes the Mandelbrot set look threedimensional.
Finally, what happens if the divergence and convergence schemes both fail and leave a hole in the fractal? The black "snowman" shown in Figure 4.2 above is an example of such hole and it is probably caused by orbits that converge to cycles of astronomically large periods that cannot be detected by today's computers. We can still plug the hole by applying another technique shown in § 8. In Figure 4.3 below, we painted two fractals, one with a hole and the other without, on spheres for a change.
Figure 4.3. The Mandelbrot Set (Right) Colored by a Technique of § 8
§ 5. Mandelbrot Fractals
Since it was published in 1980, the Mandelbrot set became so popular that a great many digital artists, mathematicians and computer programmers have explored around it and shown their fractal images on a variety of objects including webpages, posters, book covers, Tshirts, and coffee mugs. Although the complexity of the Mandelbrot set shown on a twodimensional canvas is boundless and the hidden beauty inexhaustible, it has become quite a challenge to unearth new patterns from the Mandelbrot equation (2.1) using available computers and software. Consequently, a creative work calls for a modification of the formula, and there are infinitely many formulas available for it.
We call a fractal given by a dynamical system of the form
(5.1)
z_{n+1 }= f_{p}(z_{n})
a Mandelbrot fractal if it is painted on a pcanvas, where f_{p} is any nonlinear elementary function containing a parameter p. The initial value for the orbits is often a critical point of f_{p} as in the case of the Mandelbrot set but it is not a requirement. There are functions f_{p} without convenient critical points, and even if f_{p} has one, a noncritical point often produces interesting fractals from f_{p}. We always have the advantage of having a fast computer that allows us to satisfy our curiosity by engaging in a computer experiment.
Figure 5.1. "Snowman" Shot by Arrow
The comical image shown above is a Mandelbrot fractal given by
(5.2)
z_{n+1 }= f_{p}(z_{n}) = z_{n}^{3} + z_{n} + p
with z_{0} = i / √3 which is a critical point of f_{p}. The tip of the arrowhead is at the origin (0, 0) of the pcanvas and the tiny isolated figure on the right is another snowman (who propelled the arrow); see the inset for an enlarged image. Here, the picture is actually given by rotating the output fractal 90^{o} counterclockwise to better fit in the webpage. In this article, we use rotations and horizontal/vertical reflections of fractal images freely for artistic effects.
The image shown below is a Mandelbrot fractal given by zooming in on the boundary of the tiny snowman. We often use it as a night sky of 3D landscapes like in Figure 5.2 and Figure 5.3 shown below. § 9 explains how to plot such 3D images.
Figure 5.2. "Mandelbrot Island"

 Figure 5.3. "Desert Rocks"

The Logistic Equation: In 1838 Pierre Verhulst introduced a differential equation called the "logistic equation," which became a widely used mathematical model for population dynamics. If we replace the derivative in the equation by its approximating difference quotient and do some algebra, we get the following formula that is more suitable for computer applications:
(5.3)
z_{n+1 }= f_{p}(z_{n}) = p(1  z_{n}) z_{n }.
It is again called the logistic equation (or logistic map) and is equally applicable in the population dynamics when the variables are restricted to real numbers.
In 1974, while conducting a computer simulation of certain population change, biologist Robert May discovered "very complicated orbits" of (5.3), which led us to the concept of chaos. In 1993, a "chaotician" appeared in Steven Spielberg's hit movie, "Jurassic Park," tacitly suggesting a possibility of chaos in the controlled dinosaur populations.
Figure 5.4. "Bifurcation"
So, it is natural that we plot Mandelbrot fractals of the dynamical system (5.3) by expanding its variables to complex numbers; see Figure 0.5. The source of chaotic orbits Robert May discovered is the real interval [α, 4] with α ≈ 3.57, which is a part of the horizontal "antenna" at the right edge of the "global" image (first image) of Figure 0.5. Figure 5.4 above is given by zooming in on a microscopic neighborhood of a point in the interval. In this example, a noncritical point z_{0} = 0.1 is used for a certain deforming effect.
By the way, people familiar with multivariable calculus might find a fun project in mapping an image like Figure 5.4 on surfaces like the ones shown below. We can see more examples of this sort in Gallery 3D.
The next two images are Mandelbrot fractals given by the cubic equation motivated by the Logistic Equation:
(5.4)
z_{n+1 }= f_{p}(z_{n}) = p(1 + z_{n})(1  z_{n}) z_{n }.

 Figure 5.5. "Rising Dragon"

§ 6. Julia Fractals and Julia Sets
Recall that a Mandelbrot fractal is generated by a dynamical system of the form (5.1) with a fixed initial value z_{0} and painted on a pcanvas comprising parameters p. A fractal is called a Julia fractal if it is given by a dynamical system of the same form with a fixed parameter p and painted on a zcanvas comprising initial values z_{0} instead. It is named after Gaston Julia, who was one of the early pioneers of fractals generated by dynamical systems.
For example, consider (again) the Mandelbrot equation
(6.1) z_{n+1 }= f_{p}(z_{n}) = z_{n}^{2} + p.
Figure 6.1 shows two nearly equal parameters and two Julia fractals given by (6.1) and the respective parameters. The first parameter belongs to the interior of the Mandelbrot set and the second parameter just outside but near the first parameter. We call the Julia fractals "Hydra of Lerna with Eleven Heads" and "Hydra's Ash," respectively. The green/blue Hydra on the left is painted by the convergence scheme with period index k = 11 and its background by the divergence scheme. Hydra's ash is given by the divergence scheme alone.
Figure 6.1. "Hydra of Lerna with Eleven Heads" and "Hydra's Ash"
Julia Sets: If p is a fixed complex value in (6.1), let S be the set of all initial values z_{0} in a sufficiently large zcanvas whose orbits do not diverge to ∞. By the Julia set of (6.1) with the fixed value of p or simply the Julia set of p, we mean the boundary of the set S. We then refer to the set S as the filled Julia set of p. For example, the Hydra shown above on the left is a filled Julia set and its boundary the Julia set of p; the Hydra's ash on the right is also a Julia set. The zcanvases are "sufficiently large" as they cantain the entire Julia sets. As we shall see, a Julia set of p is more intricate when p is closer to the boundary of the Mandelbrot set and it is what makes a Julia fractal visually delightful.
Note that the definition of the filled Julia set is very similar to that of the Mandelbrot set. Like the boundary of the Mandelbrot set whose extreme complexity was discussed in § 3, the Julia set is also among the most important objects in fractal geometry. It displays a variety of fractal and topological structures and it is also the source of chaotic orbits.
The concept of Julia set naturally extends to any polynomial in z_{n} (and more general dynamical systems with some modifications) and it appeared well before the computer era. The following theorem was established around 1920 and explains why the critical orbits are important in general and why the Mandelbrot set was built on the critical orbits of p in the first place.
The FatouJulia Theorem: Consider a dynamical system of the form
(6.2)
z_{n+1 }= f_{p}(z_{n}) = c_{m} z_{n}^{m} + c_{m1} z_{n}^{m1} + · · · + c_{2} z_{n}^{2} + c_{1} z_{n} + p ,
where m is an integer ≥ 2 and c_{m}, c_{m1}, · · ·, c_{2}, c_{1} are constants. Then the Julia set of (6.2) with a fixed value of p is connected if and only if every critical orbit of p stays within a finite bound.
Note that if m > 2 in (6.2), p may have multiple critical orbits as f_{p} may have multiple critical points. In case of the Mandelbrot equation (6.1), each p has a single unique critical orbit; hence the FatouJulia theorem is stated beautifully as:
The Julia set of p is connected if and only if p belongs to the Mandelbrot set.
For the Mandelbrot equation, it is also known that if the Julia set of p is disconnected then it must be a "totally disconnected" powderlike fractal called Cantor dust (named after Georg Cantor, the pioneer of set theory) and cannot be the disjoint union of, say, three connected components. For example, because of our choice of the parameters in Figure 6.1, the boundary of the Hydra on the left depicts a connected Julia set and the Hydra's ash on the right Cantor dust.
Figure 6.2. "Julia Lions" of Periods 14 and 42 by the Mandelbrot Equation
Plotting Julia Sets: Consider the Mandelbrot equation (6.1) first and recall (§ 4) that we can actually build a diagram similar to the Periodicity Diagram for the Mandelbrot set. Use the diagram and pick a disk of periodicity, say 14, attached to the cardioid just above its cusp, and choose a parameter p in the interior of the disk, say p = (0.296498, 0.020525); see how to choose good parameters.
The "gold lion" shown above on the left is painted by using (6.1) with p and the convergence scheme with period index k = 14 on a zcanvas centered at the origin and its background by the divergence scheme. So, the gold lion is precisely the filled Julia set of p = (0.296498, 0.020525). Since p is inside the Mandelbrot set, it follows from the FatouJulia Theorem that the Julia set which is the boundary of the lion is connected and so is the lion.
Again using the periodicity diagram, pick a disk of periodicity 42 attached to the aforementioned disk of periodicity 14. It can be done easily by noting 42 = 14 x 3 and simple numerical patterns shown in the diagram. The gold "lion" shown above on the right is given by choosing a parameter, say p = (0.296555, 0.020525), in the interior of the new disk and using the convergence scheme with period index k = 42. Recall that we use rotations and horizontal/vertical reflections of fractal images freely for artistic effects.
We can clearly see number 14 reflected in the shape of the left lion in Figure 6.2 above, but how about 42 = 14 x 3 in the right lion? If you note that the lions in Figure 6.3 below share the same period 85 = 17 x 5 and that they are not mirror images of each other then you have the right idea and sharp eyes. They are given by two parameters in the same disk but different locations that dictate the "curling" directions.
Figure 6.3. "Julia Lions" of What Period?
Additional examples of Julia sets coming out of the Mandelbrot set are shown in Gallery 2D. It tells us the astounding facts about the Mandelbrot set: In addition to the properties shown in § 3  § 4, the Mandelbrot set conceals infinitely many varieties of Julia sets!
Julia Sets by Other Dynamical Systems: We can follow the same process using the logistic equation (5.3) instead of the Mandelbrot equation. Figure 6.4 shown below is given by building a periodicity diagram based on the "global image" of Figure 0.5 and choosing a parameter in the interior of a disk of period 2.
Figure 6.4. "Dancing Seahorses" by the Dynamical System (5.3)
Figure 0.2 shown at the outset of this website is a Julia fractal generated by the dynamical system (5.2), for which the FatouJulia Theorem is applicable. Here, p = (0.185, 0.00007666) and the gold "twin dragons" is painted on a zcanvas centered at the origin by the convergence scheme with period index k = 2. If we alter the value of p and find its period, we get a variety of "twin dragons" including the pictures shown below.
Figure 6.5. "Twin Dragons" by the Dynamical System (5.2)
And here is another by a different dynamical system:
Figure 6.6. "Twin Dragons" by the Dynamical System (5.4)
Similarities of Mandelbrot and Julia Fractals: Although the precise reason is unknown, we note that in many cases Mandelbrot and Julia fractals from the same dynamical system have similar appearances "locally" if they are generated by nearly equal parameters. For example, the image below on the left is a Mandelbrot fractal given by the logistic equation (5.3) on a microscopic neighborhood of p = (3.000008596, 0.076065598) and the one on the right is a Julia fractal from the same equation with the fixed parameter q = (3.001, 0.075975) ≈ p.
"Fractal Elephants" by the Logistic Equation
The image on the left in Figure 6.7 below is a Mandelbrot fractal given by the Mandelbrot equation (6.1) on a pcanvas centered at p = (0.25000316374967, 0.00000000895902) that belongs to the body of the black "snowman." It is essentially the same as the images in Figure 3.1 whose amazing complexity was discussed in § 3; see Figure 4.2. As we mentioned in § 4, the period of p is unknown and probably astronomically large.
The image on the right is a Julia fractal given by the fixed parameter p on a zcanvas centered at the origin. Both images contain infinitely many "cuttlefish" with their eyeballs given by the eyeball effect of the convergence scheme. The divergence scheme painted all other areas except for the black "holes." Just like the Mandelbrot set described in § 3, the filled Julia set in the Julia fractal on the right comprises infinitely many black holes connected by invisible networks and it shapes the colorful and intricate Julia fractal.
The examples show that a Julia fractal can be as complex as the Mandelbrot set "locally," but even more impressive is the fact that the complex pattern is just one of the infinitely many varieties the Mandelbrot set possesses. This is just one of the facts showing that the Mandelbrot set is incomparably more complex than any of the Julia sets even though a Julia set can have an enormously complex structore.
Figure 6.7. "Partying Cuttlefish" by the Mandelbrot Equation
§ 7. Newton Fractals
A Julia fractal is called a Newton fractal if it is given by a dynamical system of the form
(7.1)
z_{n+1 }= z_{n}  g(z_{n})/g'(z_{n})
where the parameter p = 0 is invisible and g is an elementary function with its derivative g'. Although g is a function of a complex variable, the familiar rules of differentiation in high school calculus hold for g. In my program, g is almost always a polynomial which allows me to take advantage of the timesaving scheme called
Horner's Method to efficiently evaluate both g and g' that appear in the dynamical system. Horner's method is nothing but "synthetic division" taught in high school algebra, and it should be interesting for the reader to see how (differently) it is applied in computer programming.
The reader may have noted already that the dynamical system (7.1) is nothing but the NewtonRaphson RootFinding Algorithm, aka
Newton's Method. Hence, each orbit of (7.1) converges to a root of g quickly more often than doing something else, and it allows us to plot most of the Newton fractals by the convergence scheme (with period index k = 1) alone with a relatively small maximum number of iterations like M = 500.
Furthermore, if we know all the roots of g prior to the fractal plotting, we can modify the convergence scheme fairly easily so as to add more colors to Newton fractals of g. Because a Newton fractal is a Julia fractal, a "canvas" and an "orbit" always mean a zcanvas and an orbit of z_{0}, respectively, in this section.
Example 1 (Roots of Unity): Probably the simplest Newton fractals to plot are given by a polynomial of the form
g(z) = z^{ d}  1
as its roots are readily available by hand calculations or Googling "roots of unity."
Figure 7.1. Newton Fractals of g(z) = z^{ 5}  1
"Crab Queue"
The leftmost image of Figure 7.1 is a Newton fractal for g(z) = z^{ 5}  1 painted on a square canvas centered at the origin with radius 1.1. It uses five essentially different colors, sky blue, purple, red, amber, and blue, associated with the five roots of g. The sky blue region, e.g., comprises the initial values z_{0} in the canvas whose orbits converge to the root r = (1, 0) and is called the basin of attraction of Newton's method for the root.
Thus, there are five basins of attraction in the leftmost fractal and they are divided by the basin boundary. The basin boundary is precisely the Julia set of the Newton fractal, and that is where Newton's rootfinding algorithm behaves in a "chaotic" fashion and fails to provide a root. As we can see clearly, a Newton fractal is totally uninteresting unless it contains a part of the Julia set—just like the Julia fractals discussed in the preceding section. It is known that the Julia set is Cantor dust.
The second image of Figure 7.1 is a variation of the first and the third is given by zooming in on one of the "bands" in the second image.
Example 2 (Cyclotomic Polynomials): Another interesting example with known roots is a
Cyclotomic Polynomial. The picture on the left in Figure 7.2 is a Newton fractal of the "30th cyclotomic polynomial"
g(z) = z^{ 8} + z^{ 7}  z^{ 5}  z^{ 4}  z^{ 3} + z + 1
with the unit disk highlighted. Since g happens to be a factor of z^{ 30}  1, its roots are among the 30th roots of unity that lie on the unit circle. In the picture, the thirty dots on the unit circle show where the roots of unity are located and eight of them colored yellow show the whereabouts of the roots of g. The picture on the right is a Newton fractal of the "20th cyclotomic polynomial"
g(z) = z^{ 8}  z^{ 6} + z^{ 4}  z^{ 2} + 1.
Figure 7.2. Cyclotomic Polynomials with Eight Roots
Finding the Roots: As we have seen, a Newton fractal of a polynomial with colorful basins of attraction requires its roots to be known. So, if we don't know the roots, how can we find them? A natural choice seems to be the use of Newton's method, but unfortunately, its chaotic nature makes it difficult to program a computer and consistently find the roots. Another way is to use Müller's Method instead. Although Müller's method lacks the impressive simplicity and speed of Newton's method, it generally works well and automatically finds all roots of the polynomial. All Newton fractals shown in Gallery 2D use Müller's method even when the polynomials have known roots.
Figure 7.3 is a Newton fractal of a fifth degree polynomial whose roots are given by Müller's method. Just for fun, we painted it on a plane, a sphere and a torus.
Figure 7.3. Newton Fractal on Plane, Sphere and Torus
Figure 7.4 shows a Newton fractal of a 12^{th} degree polynomial painted on a plane and a sphere. The second image which is on a sphere is intended to give a 3D appearance. All of the twelve roots are again found by Müller's method quickly.
Figure 7.4. "Dragonfly" on Plane and Sphere
Figure 7.5 illustrates two Newton fractals of a fifth degree polynomial. We painted them by highlighting different parts of essentially the same image. Note that we can find numerous replicas of the "fish" in the "crab" and vice versa. Note also that each of the images shows white Cantor dust which is a part of the Julia set (or basin boundary) of the Newton fractal.
Figure 7.5. "Newton Fish" and "Newton Crab"
§ 8. Fractal Enhancements
Figure 4.3 of § 4 shows "beforeandafter images" of fractals, in which we patched the black hole left untouched by the divergence scheme by a fitting pattern. Because an orbit in a dynamical system may converge to a cycle with a very large period or diverge to ∞ too slowly for the current computers to handle, it is inevitable that we run into a fractal with a visible hole frequently. Also, fractals in general often come out with some shortcomings such as being flat and dull or helplessly cluttered. Like a painting, sometimes we can rescue a flat image by an appropriate "shading" to make it sharper as the following beforeandafter images illustrate.
The goal of § 8 is to show how to enhance fractals with some of these deficiencies, and here we use a few ideas described in our supplemental section on Fractal Coloring. Especially important is the idea of precolored fractal, which is an array of nonnegative integers over a canvas and which we convert to a visual fractal by various coloring techniques. The supplement shows simple ways to compute precolored fractals using the divergence and convergence schemes and generate colorful fractals using the 24bit "true colors."
Now we show totally different ways of computing precolored fractals, which turned out to be extremely useful not only in enhancing fractals but also in generating threedimensional (3D) landscapes as we will see in § 9. Let R be a canvas in the pixel coordinate system and suppose p = (i, j) and q = (m, n) are pixels on the canvas R. Then by the Pythagorean Theorem, the distance between p and q is given by
(8.1) D(p, q) = √ [(i  m)^{ 2} + (j  n)^{ 2}].
If S is a nonempty subset of the canvas R, then for each pixel p = (i, j) on R, we define the (integer) distance from p to S by
(8.2) d(i, j) = round {minimum[D(p, q)]} = round {minimum√ [(i  m)^{ 2} + (j  n)^{ 2}]},
where q = (m, n) varies over S. (8.2) often provides us with a precolored fractal over the canvas R, but it often forces our computer to evaluate millions of square roots for each pixel p = (i, j). Alternatively, we define the distancesquared between p and q by
(8.3) D^{ 2}(p, q) = (i  m)^{ 2} + (j  n)^{ 2}.
If S is as before, then for each pixel p on R, we define the distancesquared from p to S by
(8.4) D^{ 2}(p, S) = minimum[D^{ 2}(p, q)],
where q varies over S. Let
(8.5) d(i, j) = round {[D^{ 2}(p, S)]^{m}},
where m is a positive real number. If m = 1/2, it is easy to show that d(i, j) coincides with the distance given by (8.2) and that (8.5) uses square root only once for each pixel p = (i, j) on R.
If m ≠ 1/2, (8.5) still provides us with useful "semidistances" that we frequently use for our fractals. In fact, d(i, j) does not have to resemble the distance function at all, and if f is any nonnegative elementary function, then we set
(8.6) d(i, j) = round {f(D^{ 2}(p, S))}
to get a wider variety of d(i, j).
Example 1: Let S be the boundary of the Mandelbrot set in the first image of Figure 8.1 and compute the array d(i, j) of nonnegative integers by (8.5) with m = 1/2. So, each d(i, j) is the distance of the pixel p = (i, j) from the boundary of the Mandelbrot set. Using the basic coloring techniques shown in Fractal Coloring, we can convert the array into the second fractal of Figure 8.1.
The numerous "fireflies" shown in the fractal are caused by the small (invisible) black dots in the first image left untouched by the divergence scheme and they are treated as part of the Mandelbrot set. The third image is given by combining the first and the second images.
Figure 8.1. Applications of the Distance Function in Fractal Plotting
Topographical Contour Maps: For each pixel p = (i, j) on the above canvas, we may interpret the distance d(i, j) of p from the boundary of the Mandelbrot set as the altitude of a threedimensional (3D) terrain at p and plot a landscape like Figure 9.2 shown in the next section. Under such interpretation, we may regard the second image of Figure 8.1 as the "view from the top" or a topographical contour map of the 3D terrain, where each contour line is given by the same color. (8.6) shows that we have infinitely many precolored fractals over the same canvas (one for each f) and can plot numerous varieties of contour maps (without thinking about the underlying 3D pictures).
Fractal Shading: When we paint a 3D object such as a human face on a flat canvas, shading is one of the most important elements as it adds realism and a sense of threedimensionality. Without shading the painting usually looks flat and lifeless. So, how do we add shading to our contour maps and fractals in general? The answer is (surprisingly) the partial derivatives, which are among the most basic objects in multivariable calculus and are no more difficult to grasp than the ordinary derivative in singlevariable calculus.
Figure 8.2. Shading "Hydra with Nine Heads" by a Partial Derivative
Partial Derivatives: We'll discuss the idea using an example. The first image of Figure 8.2 shown above is a Julia fractal given by the Mandelbrot equation, which we call "Hydra of Lerna with Nine Heads," and the boundary of Hydra is a Julia set. Suppose S is the Julia set and compute d(i, j) on the interior of the Julia set by (8.6) with a function f of our choice and without "round." Then we approximate the partial derivatives of d(i, j) by setting the increment h = 1 in the definition, i.e., by the simple formulas:
(8.7) P_{i}d(i, j) = d(i+1, j)  d(i, j),
(8.8) P_{j}d(i, j) = d(i, j+1)  d(i, j).
We omit saying "approximation" and call (8.7) and (8.8) the "partial derivative of d(i, j) in the direction of the iaxis" and the "partial derivative of d(i, j) in the direction of the jaxis," respectively. We recall that in the pixel coordinate system, the iaxis and jaxis point "east" and "south," respectively.
To plot a fractal given by the partial derivative, say, P_{j}d(i, j) in the direction of south, normalize P_{j}d(i, j) to the range between 0 and 1 and call it a shade factor. Recall that black and white in the 3D color cube are (0, 0, 0) and (255, 255, 255), respectively, and all grays are colors of the form s x (255, 255, 255) where s is a number between 0 and 1. So, assuming that our canvas is white, paint each pixel p = (i, j) in the canvas by the color
(8.9) C(i, j) = P_{j}d(i, j) x (255, 255, 255)
if p is in the interior of the Julia set, and C(i, j) = (0, 0, 0), otherwise. Figure 8.3 shows two of the possible pictures by (8.9) that depend on our choices of f in the formula (8.6). Each image shows that the shading by the partial derivative means multiplication of the colors on the canvas by the normalized partial derivative. In fact, the second image of Hydra in Figure 8.2 is given by "multiplying" the colors of the first image in Figure 8.2 by the shade factors of the first image in Figure 8.3 in the interior of the Julia set.
Figure 8.3. Fractals by a Partial Derivative
To interpret the two images in Figure 8.3 given by the partial derivative P_{j}d(i, j) in the direction of south, imagine that the sun rises from north while we traverse the terrain on a straight path from north to south. Then the sunniest area we experience on the path is where we gain the altitude most rapidly and the shadiest area is where we lose the altitude most rapidly, and the partial derivative, like the ordinary derivative, measures the rate of change of the "altitude" d(i, j) relative to the horizontal distance. (Note that the "shadow" cast on the ground by objects such as trees is a separate problem and not part of the equation here.)
Directional derivatives: A directional derivative of a function that appear in multivariable calculus is a generalization of partial derivatives and provides shading relative to a more general direction. It is not difficult to modify (8.7) and (8.8) to write a formula for a simpler directional derivative in a direction such as southwest. We used them often in the fractals shown in this website including Figure 4.1.
§ 9. ThreeDimensional (3D) Renderings of Fractal Scenery
This section is for people who are familiar with the 3D xyzspace and have some experience with plotting the graph of a function like z = x^{2} + y^{2} by a computer. We recall that in such a graph, z represents the altitude of the graph at (x, y). Our goal of this section is to generate 3D landscapes using various 2D fractals already computed on canvases in pixel coordinates (i, j). So, we will continue to use the pixel coordinate system and also use letter w for the third dimension of the 3D space to talk about the ijwspace instead of the xyzspace.
Given a 2D fractal plotted on a canvas R in pixel coordinates, we can plot a 3D landscape in the ijwspace reflecting a characteristic of the 2D fractal once we find an appropriate altitude w of the graph at each pixel (i, j) on R.
The Basic Method: Start with a Mandelbrot, Julia or Newton fractal on a canvas R and recall that the 2D fractal is given by coloring an array d(i, j) of nonnegative integers over R called the precolored fractal; see Fractal Coloring. Set
(9.1) w = d(i, j)
at each pixel (i, j) on the canvas R. This gives us a quick graph in the 3D space, but because the 2D fractal is often closely tied with chaos, the 3D graph given by (9.1) tends to get literally "chaotic" with countless and abrupt ups and downs. The chaotic fluctuation of d(i, j) generally translates into intricate color changes of the 2D fractal but it is not welcomed in the 3D rendering. We may still find a few ad hoc ways to deal with them, however, and produce interesting fractal scenery.
The desert scene on the left in Figure 9.1 is based on a Mandelbrot fractal given by the logistic equation and the divergence scheme. It "shows" several hills, but if we look at the picture on the right, we note that the hills are actually holes shown upside down. The undesirable chaotic part of the picture was conveniently thrown into the holes.
The Popular Method: Perhaps the most commonly used 3D rendering is by means of the distance function (8.5) with m = 1/2 or its generalization (8.6) we discussed in § 8. For example, start with the Mandelbrot fractal of Figure 3.1, and let d(i, j) be the distance of (i, j) from the boundary of the Mandelbrot set. Just as in (9.1), let
(9.2) w = d(i, j)
so, the altitude of the 3D graph at each pixel equals the distance of the pixel from the boundary of the Mandelbrot set.
Figure 9.2 shown below is given by coloring the graph of the equation (9.2) in the ijwspace (where the axes are not uniformly scaled). The island is shaded by the directional derivative in the direction of northwest to define the sunny side. Perhaps the hardest part in plotting the image is casting the shadow of the island on the lower surface. It does not use anything from higher mathematics but requires the persistence of the programmer. Figure 5.2 shows the island from a different angle.
Figure 9.2. "Mandelbrot Island"
Figure 9.3 shown below is similar to but a little more involved than Figure 9.2. The "island" is based on the Mandelbrot set shown on the left and the function d(i, j) is a variation (8.6) of the distance. The "moon" is given by mapping the Mandelbrot set on a sphere (which is a little trickier) and the "stars" are another 2D fractal.

 Figure 9.3. "Mandelbrot Island"

Figure 9.4 shown below is based on the "Crooked Mandelbrot Set" shown on the left and given by another variation (8.6) of the distance from its boundary.

 Figure 9.4. "Crooked Mandelbrot Rocks"

The next two images are based on the 2D fractal used as the night sky shown below. The first image is given by the distance from the boundary of the Mandelbrot set and the second image by its variation. They show a drastic difference in the shapes of the mountains. We can actually find amazingly many varieties of 3D shapes from the formula (8.6) of § 8.
Figure 9.5. "Crater Lakes"
