Ubiquitous Mr. Karl Castleton Pacific Northwest National Laboratory
Jan 23, 2016
Ubiquitous
Mr. Karl Castleton
Pacific Northwest National Laboratory
Why discuss recursion?• Fundamental to many
aspects of life– Something being
defined by itself
– and some transformation between levels
– and some criteria to stop recursion
• Simple to state– Most recursive definitions are
very clean
• Intuitive in its definition– Other than the strangeness of
definition
• Difficult to “use” properly– Most software engineers shy
away from its use even though it is very useful
Fibonacci Sequence as an example:
• f(n)=f(n-1)
• + f(n-2)
• Where
• f(0)=1 and f(1)=1
• n>1
Generates the series
1 1 2 3 5 8 13 …
• Defined by itself
• and a transformation
• and a stopping condition– Defines first few
elements and stopping condition
A software implementation:
• f(n)=f(n-1)
• + f(n-2)
• Where
• f(0)=1 and f(1)=1
• n>1
Generates the series
1 1 2 3 5 8 13 …
• int fib(int n) {
if (n>1)
return fib(n-1)
+fib(n-2);
else return 1;
}
The Giant’s Shoulders
• Douglas R. Hofstadter in 1979 a book called “Goedel, Escher, Bach: An Eternal Golden Braid” (GEB for short)– A book I stumbled across but in its day was
quite a sensation– Many of the concepts presented here stem from
extensions of ideas presented in this book– By the way this book pre-dates the modern
personal computers and software tools
But lets not focus on Math and Computer Science
• Recursion occurs in many other aspects of life– We will start as far from Math and Computer
Science as we can get and then return to them for some interesting examples
– I have focused on cultural artifacts more than behaviors. So I do not show any recursive behaviors but we will find artifacts that seem to have recursive structures.
On to Music and Limericks
Does music contain recursion• A key is a series of notes that start and stop on the
same note (although the note could be in a different octave)
• In GEB, Hofstadter explains that “we hear music recursively-in that we maintain a mental stack of the keys”– This is to say when we start hearing a melody you tend to
wait for the starting note to come again– If we diverge from the melody our brains wait for a return
to the start of diversion before we expect to hear the original melody end
– An experiment: start humming a scale and stop somewhere in the middle. It does not feel quite right does it.
Self Defined, Transformed, and Stopped
• Key is a series of keys that we expect to hear
• They can contain time-compressed copies of itself, or shifted in frequency
• and is expected to end at each level of recursion
• Some of the most challenging music to play comes from this nesting a key in a key.
What about the words?
• Lets look at the typical limericks – There was an Old Man with a
beard, Who said, "It is just as I feared! - Two Owls and a Hen, Four Larks and a Wren, Have all built their nests in my beard!" [Edward Lear]
From: Self-similar syncopations:Fibonacci, L-systems, limericks
and ragtime by Kevin Jones
• Directly correlates the structure to the Fibonacci sequence– There is a “tree” that shows a
recursive structure that in the end generates the di-dum-di-dum rhythm of the limericks
• Author has degrees in Mathematics, Computer Science and Music
• He then goes on to show that ragtime music sometimes shows the same characteristics.
• Visit: http://plus.maths.org/issue10/features/syncopate/
For a more complete review
• Self-Similarity (another name for recursion) is the bridge between sound and music.
• Self-similar Synthesis: On the Border Between Sound and Music Masters Thesis at MIT for Shahrokh D. Yadegari
• The coherencies which exist in music have to agree with each other in any scale and dimension in which they are being perceived.– http://crca.ucsd.edu/
~syadegar/MasterThesis/node25.html
On to Art
Lets start with older cultural art.
• Rangoli: Ritual Patterns of Rural India– For sacred and festive
places
– Drawn by tracing lines around a grid of dots
• Dr. Ektare pointed out this example
Pattern is repeated ona smaller scale
Sometimes it is distorted
The Mandala is also recursive
• A mandala is an imaginary palace that is contemplated during meditation in Tibetan Buddhism
• A very complex design repeats itself in four rotations but also in the nested palace in a palace
The border of this mandala also has recursive properties
A more modern example (Escher)• Image below was
explicitly constructed for its recursive properties.
• M.C. Escher has a number of examples of recursion.
What would the close-up of his eye reveal
60’s Music Videos
• Video feedback was used to produce many.– Basically you point a video
camera at a monitor and then add some light source
– This was produced (by me) using a net cam and a monitor. The light source is the mouse
• The frame you see is the frame you saw plus the distortion of the alignment of the camera, and processing it stops at the limit of the camera resolution There is an intentional rotation
in the alignment between cameraand monitor On to Nature
Nature uses recursion frequently
• Nature has many fractals– Fractals are self-similar
structures
• This shell is related to the example video because the shell is a simple enlargement and rotation of the previous shell.
• The shell started as small as possible (for the creature)
Flowers and plants also have this self-similar behavior
• Plants are frequent examples
• Fractal ferns are a classic examples of recursive definition
• Vist: http://www.geocities.com/CapeCanaveral/Hangar/7959/fractalapplet.html
Even Sensing Nature Needs Recursion
• Sensing subaudible sound requires a special instrument
• Notice the eight sided star with the eight sided stars…
• That is the sensor used to sense sub-audible sound that elephants and weather produce
• An optical fiber infrasound sensor: A new lower limit on atmospheric pressure noise between 1 and 10 Hz
• Visit: http://klops.geophys.uni-stuttgart.de/~widmer/JASAfinal.pdf
On to Social Structures and Geography
Nesting of Elected Officials with Elected Officials
• The Federal representation structure (Executive, Legislative, Judicial, Press) is repeated at the state and local levels.– With some minor
transformations at each level (term limits, required age, etc.)
• This basically gives a structure that can govern many people with relatively few individuals
• It is not unlike the flower in the nature section
• Does the structure even extend into your household?
• Scientific and technical communities tend to have nested leadership organization as well.
Structure of the Electrical Grid
• The power grid is essentially a binary tree from the power plant to the consumer
• Here the transformation steps voltage up as losses occur over the transmission wires
How much coast line do we have to protect/govern?
• A rather simple question posed to Benoit B. Mandelbrot
• The solution he came up with was it depends– What scale do you want to
measure on– Can really be any answer
you wish– Any structure at one scale
has equivalent structures at a smaller scale
Back to Computer Science
Many Divide and Conquer Algorithms are Recursive
• Binary Search• Fast Fourier
Transformation• Recursive Decent
Parsers– Backus Naur Form is a
way of encapsulating recursive language structures
• And many many more.
Web Page Design• Nesting of
– Styles within styles
– Tables within tables
– Lists within lists
• A fundamental concept to the layout of web-pages
Back to Mathematics
The Mandelbrot Set• Simple Computation of
Complex Numbers– Zn+1=Zn
2+C• Has unlimited complexity• Coloring typically done by
the number of computations before divergence away from 0+0i
• Julia sets are a peek at the complexity of a single point of the Mandelbrot set
Another Approach to the Integration of a Function
• Consider the definition of integration where you take smaller and smaller dt until you reach the limit
• What “integrate” means you simply compare the area of one trapezoid including a and b to total area of two trapezoids a and m plus m and b. If the difference is “significant” “integrate” a to m add to “integrate” m to b stop when you hit the precision required
a b
a b
a b
a bm
-dt-
So where is Godel?
• Godel’s incompleteness theorem is a proof about proofs that uses recursion
• The ability to be comfortable with the concept of one level addressing something about a subsequent level is key
• I will Math professors explain it
more thoroughly or visit: http://home.ddc.net/ygg/etext/godel/godel3.htm
Some interesting contrasts• The recursive nature of the physical world may be the link
Wolfram should have used to make more clear the connection between simple programs and larger physical effects– This is a frequent criticism of ANKOS
• Recursive structures can typically be done in an iterative (step by step) structure but sometimes looses the essence of the concept.– The integration example is like this
– The recursive implementation is much easier to implement in a computer
Conclusions
• Recursive relationships are “everywhere”– If you are mathematician you should consider
recursive approaches and definitions (Godel did)
– If you are a computer scientist you should not be intimidated by a recursive algorithm
• I hope you enjoyed the tour of just a few examples of