The Mandelbrot fractal set can be generalized by iterating the equation
zn+1 = f(zn) + c
where c is a chosen complex number and in general, we ask the function f to be:
Analytic
f(z) should be complex-differentiable to ensure rich and meaningful complex dynamics.
Nonlinear
f(z) must be nonlinear; linear functions like f(z)=az+b produce trivial or uninteresting dynamics.
With Controlled Growth
The function should grow fast enough to allow some orbits to escape to infinity, but not so fast that all orbits do so immediately.
Examples: polynomials, rational functions, or smooth transcendental functions.
Presence of Critical Points
f(z) must have at least one critical point (where f′(z)=0) whose orbit influences the global behavior of the system.
Examples of functions
Polynomial functions
The classic Mandelbrot set: f(z)=z^2
Polynomial Functions}:, f(z)=z^3, f(z)=z^4, or in general f(z)=z^p, with p>=2
Polynomials with multiple critical points, yielding more complex structures : f(z)=z+z^2, f(z)= z^2-z^3
Rational Functions}
f(z)= (z^2)/(1+z^2), f(z)=(1 + z^2)/(z^2 -1), etc
Transcendental Functions
f(z) = sin(z), f(z) = cos(z), f(z) = tan(z), f(z) =e^z, f(z)=log(z), etc
Steps to determine if a point c belongs to the set:
Choose a complex number c
We start with z0=0
We iterate the equation until ∣zn∣>2 (meaning the point escapes the set) or until reaching a maximum number of iterations Maxiter.
If after Maxiter iterations we have ∣zn∣≤2, then c belongs to the Mandelbrot set.
To visualize the fractal:
Points that do not belong to the set can be colored based on how many iterations they took to escape, creating gradient patterns that show the "distance" to the set.
Points that belong to the set are usually represented in black.
A very simple Python code for this could be the following:
import numpy as np
import matplotlib.pyplot as plt
# Function to determine if a point belongs to the Mandelbrot set
def mandelbrot(c, max_iter):
z = 0
for i in range(max_iter):
if abs(z) > 2:
return i # Number of iterations before escaping
z = np.sin(z)*(z ** 2) + c
return max_iter # Max iterations if the point does not escape
# Function to generate the Mandelbrot set within a given range
def generate(width, height, x_min, x_max, y_min, y_max, max_iter):
x_vals = np.linspace(x_min, x_max, width) # Generate x-axis values
y_vals = np.linspace(y_min, y_max, height) # Generate y-axis values
mandelbrot_set = np.zeros((height, width))
# Compute Mandelbrot set value
for i, y in enumerate(y_vals):
for j, x in enumerate(x_vals):
mandelbrot_set[i, j] = mandelbrot(complex(x, y), max_iter)
return mandelbrot_set
# Parameters for the Mandelbrot set visualization
width, height = 500, 500
x_min, x_max = -2, 1
y_min, y_max = -1.5, 1.5
max_iter = 100
# Generate and plot the Mandelbrot set
set = generate(width, height, x_min, x_max, y_min, y_max, max_iter)
plt.imshow(set, extent=(x_min, x_max, y_min, y_max), cmap='inferno')
plt.colorbar()
plt.show()
Examples of polynomial functions
A larger value of p means that z_n^p grows more rapidly in magnitude. As a result, points tend to escape to infinity more easily, which reduces the size of the core region of the set. However, this also allows for more intricate dynamics near the boundary, where finer structures begin to emerge.
Examples of polynomial functions with multiple critical points
Examples of rational functions
Examples of transcendental functions
A detail of the iteration with f(z)=z^3