Friday, March 27, 2015

Fractals

P: I am a fan of the Star Wars movies. Have you seen those?

M: Yes I have, what about them?

P: Well, the computer graphics in some of those movies are done with fractals.


Fractal Animation with Terragen
M: That’s amazing! Are video games also done that way?

P: Pretty much. Fractals are patterns emerged from recurring calculations. First you use a routine to calculate some outputs based on an input, then you put the outputs back to the same routine as inputs to get further outputs, and keep going. Do this many times and fractal patterns will appear.

M: Ach so, calculations done in a feedback loop fashion again. Show me some examples.

P: OK. This one is called the Mandelbrot set. It uses a formula zn+1 = zn2 + c, where c is a complex constant and z is a complex number. If you set z0 = 0 and c = 0.2 + 0.4i, then z1 = 02 + (0.2+0.4i) = 0.2 + 0.4i. And z2 = (0.2 + 0.4i)2 + (0.2+0.4i) = 0.08 + 0.56i. And z3 = (0.08+0.56i)2 + (0.2+0.4i) = -0.1072 + 0.4896i, and so on. Repeat this for about 300 times and plot these z numbers on the x-y axis and you will have a Mandelbrot fractal.

M2 1024.png
Mandelbrot Set z = z2 + c.
M: Such fractals look fascinating, but they don’t seem to be like the realistic rendering in actual movies.

P: That is because another ingredient is needed in the recursive recipe. It’s called the Stochastic Process, which means some random probabilities are assigned to the outputs/inputs. The math is complicated, but the software coding is not. Such Stochastic fractals look uncannily real as natural objects or landscape.

Mandelbrot island2.jpg
Mandelbrot island by Prokofiev.

M: Even the structure of some neurons can look like fractals!

Purkinje cell by Cajal.png
Purkinje cell by Cajal.

P: And why do you think that is so? My guess is that they both come out of recursive processes.

M: And with Stochastic randomness added in for texture?

P: Yes. Stochastic process can add naturalness into the picture. Take the growth of a plant for example. The recursive part is that a bud can branch out into leaves, the leaves branch out into stems, and the stems branch out into buds again, and the cycle repeats. The Stochastic part is that some stems will grow into shady confined spaces, and some into sunny open places. This development is a probabilistic randomness that affects how the plant will shape up later. The sunny open spaces allow the stems and leaves to grow bigger, whereas the shady confined spaces stunt their growth.

Fractal weeds.jpg
Fractal weeds.

M: I have heard that fractals are related to the Chaos Theory. What is that about?

P: I think the Chaos Theory comes from the unpredictable behaviors of some fractal formulas. A small change in a formula’s constant or variable can result in vastly different output/input values that follow later. There is a Chinese expression for this: 差若毫厘 缪以千里 - separation of a thousand miles originates in a difference of a millimeter. That expression is about paying due diligence at the beginning. If an astronomer misses setting a telescope’s angle by a tiny degree, s/he may be looking at a different star.
LogisticMap BifurcationDiagram.png
Logistic Map, Bifurcation Diagram of x = r x (1 - x).

See the plot of a recursive formula x = r x (1 - x) that maps variations of constant r vs. steady-state values of variable x. At r = 3, a small increase of r creates a fork of 2 final values of x. This happens again when r is near 3.45, and again at 3.55. The compound forkings turn x into myriads of possible subsequent values. This kind of dynamics is called bifurcation (furca = fork). The branches make a prediction of the final value of x basically impossible. It is like trying to predict which way a drop of water will flow at a river's bifurcation junction. The name chaos theory simple means that small changes and bifurcations make things unpredictable.

M: This bears a remarkable resemblance to the diversity trends in natural evolution. There are hundreds of different bird species and leaf shapes. Fractal bifurcation or chaos theory sounds like a very good explanation for that. In cybernetics there are positive feedback loops that can also amplify small differences into runaway divergence, which can also explain biodiversity. Since the two theories share a similar mechanism - fractals with recursive iterations and cybernetics with repetitive feedback loops - so likely their outcomes also share an analogous trend.

P: I like this kind of correlation. There is one interesting study on bifurcation by Ilya Prigogine. He won the 1977 Nobel Chemistry prize for his dissipative structures, described in a layman's book called Order out of Chaos: Man's new dialogue with nature. Something very paradoxical is observed about order and chaos in nature. When water is near its boiling point, it is bifurcating between bubbles and liquids before it turns into steam and escapes. From the outside the boiling water appears chaotic by the raging bubbles. But inside the bubbles, the water molecules are moving oddly in uniform directions. Kind of like soldiers obeying commander’s orders while a battle is raging. On the other hand, when water is in room temperature in a container, it appears very calm and orderly on the outside, with uniform clarity and stillness. But on the inside, the water molecules are zigzagging chaotically in a typical Brownian motion fashion. This is like a chess player studying the pieces on a board. He appears still. But in his head neurons are firing like firecrackers on the 4th of July. Anyway, I think I have some ideas about your cybernetic loops now.



No comments:

Post a Comment