My Feather Fractal Was Just Two Blobs: Fixing 2 Rational Dynamics Bugs in WebGL & NumPy
🔗 Quick Links
- 🚀 Live Demo (60 FPS WebGL 2.0): https://fantasticfractals.pages.dev
- ⭐ GitHub (MIT Open Source): https://github.com/QuantumTechCoder/FantasticFractals
- 📦 PyPI:
pip install fantasticfractals→ https://pypi.org/project/fantasticfractals/- 📓 1-Click Google Colab: Open in Colab
Right after fixing the Sierpinski gothic arch and Koch snowflake slider bugs on FantasticFractals, I thought our 27 fractal formulas were finally rock solid.
Then user testing struck again.
Someone dropped two side-by-side screenshots into our issues:
- "Why does the Feather Fractal look like two smooth horizontal blobs? When I search Google Images, feather fractals have organic plume filaments."
- "What's wrong with the Nova Fractal? It looks like a 3-lobed bullseye instead of the iconic Paul Derbyshire crescent."
I opened Google Images, compared their search results against my WebGL canvas, and realized I had completely botched the complex rational math for both systems.
Here is the breakdown of what broke, why complex phase twists matter, and how we fixed both fractals in GLSL and NumPy.
Bug #1: The "Two Smooth Blobs" Feather Fractal 🪶
Here is what FantasticFractals was rendering when you selected the Feather Fractal:
It was literally two giant, smooth cyan circles with a central black oval. No plumes. No barbs. Zero feather-like structure.
The Math Mistake: $1 + z^2$ vs $1 + i|z|^2$
In my original code, I had implemented this formula:
$$z_{n+1} = rac{z_n^3}{1 + z_n^2} + c$$
// ❌ WRONG FORMULA: vec2 z2 = vec2(z.x * z.x - z.y * z.y, 2.0 * z.x * z.y); vec2 denom = vec2(1.0 + z2.x, z2.y); // <-- Standard complex 1 + z^2 Because $1 + z^2$ has real coefficients, the denominator is analytic and preserves standard bilateral symmetry. Near the origin, it just behaves like $z^3 + c$, which produces smooth, rounded cardioid lobes.
The Real Formula from Mandelbrowser
The authentic Feather Fractal (popularized by Mandelbrowser and fractal art forums) uses an imaginary phase coupling in the denominator:
$$z_{n+1} = rac{z_n^3}{1 + i |z_n|^2} + c$$
Look closely at that denominator:
$$ ext{denom} = 1 + i(x^2 + y^2)$$
It uses the Euclidean magnitude squared $|z|^2 = x^2 + y^2$, multiplied by the imaginary unit $i$!
Why this creates the "Feather" effect:
Because $|z|^2$ is purely real, multiplying it by $i$ forces the denominator to rotate the phase of $z^3$ by an angle that dynamically increases with distance from the origin:
$$ heta_{ ext{twist}} = -rctan(|z|^2)$$
This nonlinear phase rotation shears the escape trajectories, pulling the boundaries into razor-thin, dendritic plume filaments that burst outward along the diagonals.
The Fix in GLSL:
// ✅ THE FIX: vec2 z = vec2(0.0); int i = 0; for (; i < 500; i++) { if (i >= u_maxIterations) break; float r2 = dot(z, z); if (r2 > 16.0) { // Continuous potential shading float log_zn = log(r2) / 2.0; float nu = log(max(1.0, log_zn) / 0.693147) / 0.693147; iterVal = float(i) + 1.0 - nu; break; } // z^3 = (x^3 - 3xy^2) + i(3x^2y - y^3) vec2 z3 = vec2(z.x * (z.x * z.x - 3.0 * z.y * z.y), z.y * (3.0 * z.x * z.x - z.y * z.y)); // denom = 1 + i*|z|^2 -> divide by (1 + i*r2) float denNorm = 1.0 + r2 * r2; vec2 frac = vec2(z3.x + z3.y * r2, z3.y - z3.x * r2) / denNorm; z = frac + c; } Here is the exact same coordinate plane after deploying the fix:
Now it actually looks like an explosive plumage of organic fractal feathers.
Bug #2: The "Concentric Bullseye" Nova Fractal 🌟
The second bug was in our Nova Fractal. Here is what was on screen:
A symmetric 3-petaled blob surrounded by concentric bullseye rings.
If you search Wikipedia or Ultra Fractal for the Nova fractal, you don't see a bullseye—you see an iconic crescent-shaped central bay with intricate Mandelbrot filaments and satellite islands wrapping around its rim.
What Caused This?
Paul Derbyshire invented the Nova fractal in 1997 by taking the classic Newton-Raphson root-finding method for $f(z) = z^3 - 1$:
$$z_{n+1} = z_n - R rac{z^3 - 1}{3z^2}$$
And adding the coordinate $c$ at each step (with standard relaxation $R = 1$):
$$z_{n+1} = rac{2z_n + rac{1}{z_n^2}}{3} + c$$
My implementation had three distinct bugs:
Incorrect Critical Initialization ($z_0$):
I had initialized $z_0 = c$. But in the canonical Mandelbrot formulation of the Nova fractal, the iteration must start at the critical root anchor $z_0 = 1.0$ ($1 + 0i$)!
Starting at $z_0 = c$ scrambles the parameter dynamics into an arbitrary slice, collapsing the crescent.Accidental Coordinate Dampening:
In my shader, someone had written:
vec2 nextZ = (2.0 * z + invZ2) / 3.0 + c * 0.2; // ❌ WHY * 0.2?! Dampening $c$ by $0.2$ suppressed the chaotic perturbation, causing the Newton basins to dominate and form concentric rings.
- Wrong Default Center & Zoom: The center was hardcoded at
(0.0, 0.0). But because $z_0 = 1$, the main crescent of the Nova Mandelbrot set is centered near $x pprox -0.5, y = 0.0$.
The Fix in GLSL:
// ✅ THE FIX: vec2 z = vec2(1.0, 0.0); // Canonical critical anchor z0 = 1 int i = 0; for (; i < 500; i++) { if (i >= u_maxIterations) break; float d2 = dot(z, z); if (d2 < 1e-8) break; // 1 / z^2 float invD4 = 1.0 / (d2 * d2); vec2 invZ2 = vec2(z.x * z.x - z.y * z.y, -2.0 * z.x * z.y) * invD4; // Full c addition: (2z + 1/z^2)/3 + c vec2 nextZ = (2.0 * z + invZ2) / 3.0 + c; // Convergence check to fixed point: vec2 diff = nextZ - z; if (dot(diff, diff) < 1e-7) { iterVal = float(i) * 2.5; break; } // Divergence check: if (dot(nextZ, nextZ) > 100.0) { iterVal = float(i) * 2.5 + 50.0; break; } z = nextZ; } And centering the camera at defaultCenter: { x: -0.5, y: 0.0 }.
Here is the corrected Nova Fractal:
The authentic Paul Derbyshire crescent with its necklace of satellite Mandelbrot sets and delicate tendrils is fully restored.
Keeping NumPy Vectorization Synchronized 🐍
Because FantasticFractals is also a published Python scientific package (pip install fantasticfractals), fixing the WebGL shaders meant updating the vectorized NumPy array kernels as well.
Here is the NumPy vectorized kernel for the fixed Feather Fractal:
# Vectorized Feather Fractal in NumPy: Z = np.zeros(C.shape, dtype=complex) iters = np.full(C.shape, -1.0, dtype=np.float64) active = np.ones(C.shape, dtype=bool) for i in range(max_iterations): if not np.any(active): break z_act = Z[active] c_act = C[active] r2 = z_act.real**2 + z_act.imag**2 escaped = r2 > 16.0 if np.any(escaped): act_idx = np.where(active)[0][escaped], np.where(active)[1][escaped] r2_esc = r2[escaped] log_zn = np.log(r2_esc) / 2.0 nu = np.log2(np.maximum(1.0, log_zn)) iters[act_idx] = float(i) + 1.0 - nu active[act_idx] = False z_rem = z_act[~escaped] c_rem = c_act[~escaped] r2_rem = r2[~escaped] # Authentic 1 + i*|z|^2 denominator denom = 1.0 + 1j * r2_rem Z[active] = (z_rem ** 3) / denom + c_rem Both client-side GPU shaders and Python library functions now produce identical mathematical outputs down to floating-point precision.
Key Lessons
- Phase matters: If a fractal formula contains $i$ in the denominator (like $1 + i|z|^2$), you cannot treat it as a standard real polynomial. That imaginary unit is doing the heavy lifting of twisting coordinate space into fractal plumes.
- Critical values anchor parameter spaces: For Newton-type relaxation fractals like Nova, starting at $z_0 = c$ versus $z_0 = 1$ is the difference between a blurry bullseye and the true Mandelbrot crescent.
- Always visually cross-reference fractal literature: Unit tests can pass, but if you don't visually cross-reference against original papers or historical fractal databases, you can easily end up with smooth blobs pretending to be fractals.
Check Out the Fixes Live
Everything is pushed and deployed:
- 🌐 Live Web Visualizer: https://fantasticfractals.pages.dev
- ⭐ GitHub (MIT): https://github.com/QuantumTechCoder/FantasticFractals
- 📦 PyPI:
pip install fantasticfractals - 📓 Colab: Open in Google Colab
What's the weirdest bug you've ever encountered in numerical or shader math? Share your stories below! 👇




