Recursion in Nature and Art
Our first piece of recursive code will be a drawing a logarithmic
spiral. It was first described by Descartes. Jacob Bernoulli was
so impressed by it that he asked for it to be engraved on his
tombstone. He named it spira mirabilis, the miraculous
spiral. Here are examples of this spiral occurring in nature:
This spiral is also the path taken by a charged particle moving
perpendicular to a uniform magnetic field. It is also the path
taken by hawk honing in towards its prey. Here is the
code. In this code we have a
step size, a decay factor that shortens the step size, and an
angle the turtle turns after every drawing of a step. The
three parameters - step size, decay factor, and angle can be
changed to match observation.
We will examine some traditional recursive structures. We will
be drawing some well known fractals. A fractal has the
same basic form now matter how much you magnify it. In nature
you can find fractals in the form of outlines of clouds and
coastlines, snowflakes, mountains, and even trees.
- Sierpinski Gasket or Triangle
- We start with an equilateral triangle and join the mid points
of each side. This forms four smaller triangles. For each of the three
outer triangles we join the mid points of their sides and so on.
- Fractal Tree
- We define a tree as having a trunk and a smaller tree going off
to the right another smaller tree going off to the left. And then we
apply the same definition to both of the smaller right and left trees.
- H Tree
- To draw a H-Tree of order n, we use three lines in the shape
of the letter H. Then we add four H-trees of order n-1, connected to
each of the four tips of the original H. Each time the size of the
H-tree is halved.
- Hilbert Curves
- A Hilbert curve is a space filling curve that is a continuous
curve that passes through every unit square in a grid. We start
with a basic shape and the rest of the curve is generated by
reproducing that basic shape at various scales. Here is a short
tutorial on Hilbert curves. You may also want to look at
the link on other space filling curves like the Peano curves.
- Koch Snowflake
- The Koch snowflake is created as follows: Begin with an
equilateral triangle. Divide each side of the equilateral triangle
into three equal segments. On the middle segment draw an outward
equilateral triangle. Repeat the process for higher order snowflake.
- Mandelbrot
Sets
- IBM mathematician, Benoit Mandelbrot, popularized the term
fractal in the early eighties. What is fascinating about the
set is that the boundary contains numerous circular shapes, each of
which contains other circular shapes. The set is generated by an
iterated function system that involves compex numbers.
M. C. Escher (1898 - 1972)
Piet Mondrian
(1872 - 1944)
In most of the drawings that we did, we used straight line segments.
Here is an iterative code that uses very small straight line segments
to draw arcs. It then uses these arcs to form a
Sun like figure.
Recursion in Music
It turns out that musical rhythm is recursive. There are self-similar
patterns that repeat in music. Each composer has his own rhythmic
signature. Listen to this
NPR News Item.