π¨ Generative Art: Five More Mathematical Wonders
When mathematics steps out of textbooks and onto canvas, it speaks in elegant symmetries, chaotic systems, and organic tapestries. By exploring deterministic chaos, sound resonance waves, and complex limits, we can uncover profound aesthetic structures hiding within pure algebra.
This second collection features a highly diverse 1 × 5 subplot array generated cleanly using NumPy and Matplotlib. No hand-drawn lines, no stochastic random walks—just pure math rendering art.
π’ The Five Dynamic Systems at a Glance
The layout spans a \(1 \times 5\) canvas scaled to \(20 \times 8\) inches. Each cell tests a unique paradigm of algorithmic visualization:
| # | Visual System | Core Concept | Colormap / Style |
|---|---|---|---|
| 1 | Clifford Attractor | Nonlinear Strange Attractor Map | inferno (Scatter) |
| 2 | Chladni Resonance | Nodal Interference Patterns | twilight_shifted |
| 3 | Mandelbrot Boundary | Complex Polynomial Iterations | magma |
| 4 | Vector Flow Field | Dynamical Stream Differential Curves | viridis |
| 5 | Phyllotaxis Spiral | Golden Ratio Nature-Mimic Grid | Cycled Color Array |
π 1. Clifford Strange Attractor
A strange attractor maps a chaotic trajectory through iterative calculation. The Clifford Attractor updates a point's coordinates using four constant parameters over \(100,000\) iterations: \(x_{n+1} = \sin(a \cdot y_n) + c \cdot \cos(a \cdot x_n)\) and \(y_{n+1} = \sin(b \cdot x_n) + d \cdot \cos(b \cdot y_n)\). Plotted as tiny scatter coordinates with high transparency, it yields silky, smoke-like cosmic curtains.
ax.scatter() using an ultra-fine alpha value (\(\alpha = 0.01\)) and color maps bound to local array density.
π 2. Chladni Resonance Patterns
When a physical plate vibrates at a resonant frequency, sand settles naturally along stable, non-vibrating nodal lines. We simulate this phenomenon via the classic mathematical formula for acoustic plates: \(Z = \cos(n \pi x) \cdot \cos(m \pi y) - \cos(m \pi x) \cdot \cos(n \pi y)\). Using integers like \(n=6, m=2\), a deep contour mesh captures beautiful symmetrical geometric cells.
π¬ 3. Mandelbrot Fractal Boundary
By analyzing the complex number escape sequence \(Z_{n+1} = Z_n^2 + C\), we look into the edge of infinity. This panel zooms tightly into a busy boundary coordinate region of the Mandelbrot Set. The color intensity reflects the exact iteration count at which the sequence diverges past an escape radius of 2, producing high-contrast fractal feedback halos.
π 4. Vector Flow Field
Every coordinate point on a grid can house a velocity vector pointing in a specific direction. By defining derivatives \(U = \sin(Y)\) and \(V = \cos(X \cdot Y)\) across a 2D mesh, we generate a smooth, churning vector field. Utilizing Matplotlib's streamplot, we follow imaginary particles flowing gracefully along these field lines.
π» 5. Logarithmic Phyllotaxis Spiral
Nature packs seeds in sunflower heads with maximum spatial efficiency using the Golden Angle (\(\approx 137.5^{\circ}\)). Spawning \(1,500\) coordinate markers where radius scales as \(r = \sqrt{i}\) and angle scales as \(\theta = i \cdot 137.508^{\circ}\) creates an interlocking spiral matrix. Points expand radially outwards, mimicking natural plant growth structures.
⚙️ Reproduction Code
The entire five-panel visual gallery is produced seamlessly via a single execution of the native Python script below:
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(20, 8), facecolor="black")
# --- 1. Clifford Attractor ---
ax1 = fig.add_subplot(1, 5, 1)
n_points = 100000
x, y = np.zeros(n_points), np.zeros(n_points)
a, b, c, d = -1.4, 1.6, 1.0, 0.7
for i in range(1, n_points):
x[i] = np.sin(a * y[i-1]) + c * np.cos(a * x[i-1])
y[i] = np.sin(b * x[i-1]) + d * np.cos(b * y[i-1])
ax1.scatter(x, y, s=0.1, c=x, cmap='inferno', alpha=0.02)
ax1.set_title("Clifford Attractor", color="white", fontsize=12, pad=10)
ax1.axis('off')
# --- 2. Chladni Resonance ---
ax2 = fig.add_subplot(1, 5, 2)
X, Y = np.meshgrid(np.linspace(-1, 1, 300), np.linspace(-1, 1, 300))
n, m = 6, 2
Z = np.cos(n * np.pi * X) * np.cos(m * np.pi * Y) - np.cos(m * np.pi * X) * np.cos(n * np.pi * Y)
ax2.imshow(np.abs(Z), cmap='twilight_shifted', extent=[-1, 1, -1, 1])
ax2.set_title("Chladni Resonance", color="white", fontsize=12, pad=10)
ax2.axis('off')
# --- 3. Mandelbrot Boundary ---
ax3 = fig.add_subplot(1, 5, 3)
h, w, max_iter = 300, 300, 80
# Zooming closely into a boundary region
x_lim = np.linspace(-0.75, -0.73, w)
y_lim = np.linspace(0.1, 0.12, h)
m_grid = np.zeros((h, w))
for i in range(h):
for j in range(w):
c_val = complex(x_lim[j], y_lim[i])
z = 0.0j
for it in range(max_iter):
z = z*z + c_val
if abs(z) > 2.0:
m_grid[i, j] = it
break
ax3.imshow(m_grid, cmap='magma', extent=[-0.75, -0.73, 0.1, 0.12])
ax3.set_title("Mandelbrot Boundary", color="white", fontsize=12, pad=10)
ax3.axis('off')
# --- 4. Vector Flow Field ---
ax4 = fig.add_subplot(1, 5, 4)
Yf, Xf = np.mgrid[-3:3:15j, -3:3:15j]
U = np.sin(Yf)
V = np.cos(Xf * Yf)
ax4.streamplot(Xf, Yf, U, V, color=U, cmap='viridis', linewidth=1.2, arrowsize=0.8)
ax4.set_facecolor('black')
ax4.set_title("Vector Flow Field", color="white", fontsize=12, pad=10)
ax4.axis('off')
# --- 5. Phyllotaxis Spiral ---
ax5 = fig.add_subplot(1, 5, 5)
n_seeds = 1500
phi = (1.0 + np.sqrt(5.0)) / 2.0
golden_angle = (2.0 - phi) * 2.0 * np.pi
indices = np.arange(n_seeds)
r_vals = np.sqrt(indices)
theta_vals = indices * golden_angle
x_seeds = r_vals * np.cos(theta_vals)
y_seeds = r_vals * np.sin(theta_vals)
ax5.scatter(x_seeds, y_seeds, c=indices, cmap='hsv', s=6, alpha=0.8)
ax5.set_facecolor('black')
ax5.set_title("Phyllotaxis Spiral", color="white", fontsize=12, pad=10)
ax5.axis('off')
plt.tight_layout()
plt.savefig("generative_art_wonders.png", dpi=150, bbox_inches='tight', facecolor='black')
plt.show()
⏭️ Summary & Variations
By combining distinct algorithmic methodologies, the script runs entirely out-of-the-box using only core numeric tools. To expand these further, try animating the variables in the Chladni Resonance module to see patterns shift dynamically as audio frequencies rise, or explore deeper coordinate zooms inside the complex fractal planes.

No comments:
Post a Comment