Fractal Examples: Discover Nature's Patterns
The mesmerizing world of fractals, infinite patterns created by repeating simple mathematical formulas, is an exciting fusion of mathematics, art, and even nature. Fractals exhibit a unique property known as self-similarity, where parts of a pattern resemble the whole at all levels of magnification. Let's delve into the fascinating realm of fractals, exploring various examples that showcase their dazzling diversity.
Fractals are encountered in numerous fields, from computer graphics to physics, and have fascinating applications in various industrial and scientific domains. Before we dive into specific examples, let's first discuss two fundamental types: Iterated Function Systems (IFS) and L-systems.
Iterated Function Systems (IFS)
IFS fractals are generated by repeatedly applying a set of mathematical functions to an initial starting point. The power of IFS lies in its simplicity, as even a basic set of functions can lead to complex, rich fractal patterns.
One of the most well-known IFS fractals is the Sierpinski triangle, created by repeatedly removing triangles from an initial equilateral triangle. This process generates a fractal with self-similar, triangular structures at all levels of zoom.
Cantor Set
The Cantor Set is another prominent IFS fractal, where a initial line segment is repeatedly halved and the middle third removed. This iterative process results in an infinite fractal with a non-zero length but zero area, a paradoxical property that challenged early mathematicians.
Example code to generate a Cantor Set using Python:
def cantor(n):
if n == 0:
return ["1"]
else:
c = cantor(n - 1)
return ['®'.join(p) for p in c] + ['®'.join(p) for p in c] + ['®'.join(p) for p in c]
print('\n'.join(cantor(3)))
Mandelbrot Set
The iconic Mandelbrot Set is an IFS fractal generated by iteration of a simple complex quadratic polynomial. Each point in the complex plane is tested for whether it's within the fractal or not, resulting in an intricate, coastline-like boundary that exhibits self-similarity at all levels of zoom.
Example Python code using matplotlib to generate a basic Mandelbrot Set visualization:
import matplotlib.pyplot as plt
import numpy as np
def mandelbrot(c, max_iter):
z = c
for n in range(max_iter):
if abs(z) > 2:
return n
z = z*z + c
return max_iter
x = np.linspace(-2, 1, 600)
y = np.linspace(-1.5, 1.5, 600)
X, Y = np.meshgrid(x, y)
C = X + 1j*Y
Z = mandelbrot(C, 256)
plt.imshow(Z, extent=(x[0], x[-1], y[0], y[-1]), cmap='magma')
plt.show()
L-systems
Introduced by Aristid Lindenmayer in 1968, L-systems are a type of formal grammar used for generating fractals. Unlike IFS fractals, L-system fractals typically represent the development of plant and tree structures, based on iterative replacement of initial symbols according to a set of rules.
Dragon Curve
The Dragon Curve is an L-system fractal generated by repeatedly applying a set of rules to an initial starting string. Starting with an 'F', the curve grows by iteratively replacing 'S' with 'F+XF+F+XF', and 'F' with '+F-XF-FX+'. This simple rule set produces a remarkably complex, self-similar curve that resembles a dragon.
Example JavaScript code to generate a Dragon Curve using p5.js library:
let angle = 0.5 * PI;
let myRules = { 'X': 'F+XF+F downstairs F+X F', 'F': '+F-XF-FX+Fireworks' };
function setup() {
createCanvas(640, 640);
noLoop();
}
function draw() {
background(255);
drawDragonCurve('X', 10, height / 2, angle.pi / 3);
}
function drawDragonCurve(axiom, x, y, angle) {
let currentInstruction = axiom;
for (let i = 0; i < 15; i++) {
currentInstruction = replaceInstruction(currentInstruction, myRules);
}
let len = 8;
let i = 0;
while (i < currentInstruction.length) {
let instruction = currentInstruction[i];
if (instruction == 'F') {
line(x, y, x + len * cos(angle), y + len * sin(angle));
x += len * cos(angle);
y += len * sin(angle);
} else if (instruction == '+') {
angle += PI / 3;
} else if (instruction == '-') {
angle -= PI / 3;
}
i++;
}
}
function replaceInstruction(s, dict) {
return s.replace(/[FX]/g, function(key) { return dict[key]; });
}
Fractals permeate the natural world, reflecting the same mathematical principles that generate these stunning patterns. From the branching of trees to the crumpling of paper, fractals offer a fascinating window into the intersection of mathematics, nature, and art. Exploring fractals is not just an engaging visual journey but also a doorway into the captivating world of complex systems and their mathematical underpinnings.