Fractal Cities

A fractal is a curve or geometric figure that is self similar, or said another way, each part has the same statistical character as the whole. Fractals are useful in modeling structures (such as eroded coastlines or snowflakes) in which similar patterns recur at progressively smaller scales, and in describing partly random or chaotic phenomena such as crystal growth, fluid turbulence, and galaxy formation. For this reason, fractals are particularly useful in simulations and are commonly used in movie studios.

The ability to use a simple formula to create something which mimics that natural variety int he world saves compute time. If you are particularly interested in fractal rendering, check out this app where you can create your own sophisticated city renderings.


In most modeling software, we are used to working with euclidean geometry. Euclidean geometry is likely the geometry you are familiar with from a high school geometry course. It allows us to do things like measure distances of s square, or the area of a sphere. We can create formulas that describe the general size and nature of a perfect form. For example A=πr² describes a perfect circle, but it hardly describes the rounded shapes we come across in the real world.

Euclidean Geometry

Jelly fish, lakes, trees and coastlines have more nuanced shapes. If we look at them they are imperfect with ridges, bumps and variations at every scale. Fractals help us describe the complexity of more naturally occurring geometries. Mathematician, Benoit Mandelbrot in his work “The Fractal Geometry of Nature,” described a fractal as, “a rough or fragmented geometric shape that can be split into parts, each of which is (at least approximately) a reduced-size copy of the whole.”

Mandelbrot was particularly interested in scale, and the difficulty of describing it. At the scale of a coastline it is paradoxically difficult to determine its length. Lets say you were to measure the coat line of California in feet. The first time you measure the coast you use a ruler that spans roughly a mile — this would not pick up on all of the intricacies of the rock formations that jug in and out along the coast line. The second time you measure you use a standard 1' ruler. Now your measurement of the California coast is much much larger. But this could become even longer still. Imagine you could measure along each individual rock. Thus, the measured length of the coastline depends on the method used to measure it and the degree of cartographic generalization.


Recursion: the repeated application of a rule to successive results. A recursive function is a function defined in terms of itself via self-referential expressions. This means that the function will continue to call itself and repeat its behavior until some condition is met to return a result.

n! = n x (n−1) x (n−2) x (n−3) ⋅⋅⋅⋅ x 3 x 2 x 1
n! = n x (n−1)!

If n is 6 than we would get 6 x 5 x 4 x 3 x 2 x 1.

n! = n x (n−1)! 
n! = n x (n−1) x (n−2)!
n! = n x (n−1) x (n−2) x (n−3)!

n! = n x (n−1) x (n−2) x (n−3) ⋅⋅⋅⋅ x 3!
n! = n x (n−1) x (n−2) x (n−3) ⋅⋅⋅⋅ x 3 x 2!
n! = n x (n−1) x (n−2) x (n−3) ⋅⋅⋅⋅ x 3 x 2 x 1!

Applying recursion with geometry

In mathematics, iterated function systems (IFSs) are a method of constructing fractals; the resulting fractals are often self-similar and were introduced in 1981.

Sierpinski Gasket

log 3/ log 2 = rate of copies / rate of reduction 
i.e. 3 copies will be made in each generation, and each copy within a generation will have a length is 1/2 the original length dimension.

Lets try our own! Can you:

  • Change the color?
  • Change the shape?
  • Change the global geometry?
  • Vary the color?
  • Use an image?
size(1000, 1000)
def circleDraw(x,y,radius):
ellipse(x, y, radius, radius)
if radius > 2:
circleDraw(x + radius/2, y, radius/2)
circleDraw(x - radius/2, y, radius/2)
circleDraw(x, y + radius/2, radius/2)

A bit more complex version from Daniel Shiffman:

Recursive Tree
by Daniel Shiffman.
Renders a simple tree-like structure via recursion. 
The branching angle is calculated as a function of
the horizontal mouse location. Move the mouse left
and right to change the angle.
def setup():
size(640, 360)
def draw():

a = (mouseX / float(width)) * 90
# Convert it to radians
# Start the tree from the bottom of the screen
translate(width / 2, height)
# Draw a line 120 pixels
line(0, 0, 0, -120)
# Move to the end of that line
translate(0, -120)
# Start the recursive branching!
branch(120, radians(a))
def branch(h, theta):
# Each branch will be 2/3rds the size of the previous one
h *= 0.66
# All recursive functions must have an exit condition!!!!
# Here, ours is when the length of the branch is 2 pixels or less
if h > 2:
# Save the current state of transformation
rotate(theta) # Rotate by theta
line(0, 0, 0, -h) # Draw the branch
translate(0, -h) # Move to the end of the branch
branch(h, theta) # call myself to draw two branches
# "pop" in order to restore the previous
# matrix state
# Repeat the same thing, only branch off to the "left"
with pushMatrix():
line(0, 0, 0, -h)
translate(0, -h)
branch(h, theta)

The Mandelbrot Set

One of the most fascinating aspects of fractals, is that with a very simple set of rules, you begin to notice emergent behavior. New patterns and variety emerge out of simple recursive rules. Some of the most complex simulations can emerge out of the simplest set of rules.

Cellular Automata and the Game of Life

Download the Cellular Automata and Game of Life Processing Python sketches here.

Fractal Cities

What are other instances you see of fractals in cities or in nature? What are the rule sets that create this? Why do cities have different rule sets and why do they repeat across scale?


Recursion in Video and Elsewhere

Fractals usually refer to the geometric and mathematical descriptions of self similarity or recursion. However, examples of recursion can also be seen in many other examples. The “Droste Effect” refers to the recurring image inside itself stemming originally from a company called Droste which featured an image of the box on its box.

You’re also probably familiar with recursion when you join a video call and point the camera at a live feed to the camera in the video call. The effect is an infinite picture that becomes increasingly smaller.

In Economics

“In economics, the macroscopic behavior of the economy is assumed to result from the aggregate effects of producers attempting to maximize their profits, and of customers attempting to maximize their utility.” Thus meaning, a stocks may show in aggregate the behavior of a market, but this is based on the many instances of individual purchases and behaviors. Thus behavioral economics aims to study and model individual behaviors to understand how they might influence a market in aggregate.

“Deterministic and Self-organizing models assume that the underlying subsystems are “fixed” in nature, while an evolutionary model attempts to deal with possible changes at that level as well.”

co-evolution of system and environment — environmental parameters will impact adaptations to the system behavior

Science and Complexity

Warren Weaver
Claude Shannon

  • Self Organization — within complex models, self organization emerges through local rules applied across many instances. The result is the emergence of a new order of a system stemming from the local level but appearing at the system level. This new behavior is referred to as emergent behavior.
  • problem of simplicity
  • problems of disorganized complexity — laws of temp and pressure from millions of disorganized air molecules
  • problems of organized complexity — disorganized agents create a complex organic whole

Micro vs Macro states

for a slot machine a:
micro — {cherry, lemon, apple} or {cherry, cherry, cherry}
macro — {lose} or {win}
macro state is the set of micro states