
Julia Sets via Lagrangian Descriptors
Visualize Julia sets of the map z² + c using discrete Lagrangian descriptors, with interactive parameters and animation.
About this notebook
This notebook draws Julia sets with the Discrete Lagrangian Descriptor method. The quadratic map f(z) = z squared plus c generates each orbit. The code sums per-coordinate increments of the orbit to build a scalar field. The gradient of that field marks the Julia set as bright filaments. No external dataset is used. The notebook uses marimo, PyTorch, NumPy, Matplotlib, colorcet, and wigglystuff. The method follows S. Conradi (arXiv:2001.08937).
You set the complex parameter c with two number inputs. Sliders control the iteration count N and the exponent p. Dropdowns select the resolution, the view, and the colormap. You press Render to compute the image inside a form. A second panel adds a CurveEditor widget from wigglystuff. You draw a path of points in the c plane. The editor follows the curve and recomputes the Julia set at each value of c. An inset shows the path and a red marker at the current c.
The core math runs on PyTorch in float64. It uses the GPU through CUDA when available. Otherwise it runs on the CPU. The code lifts each orbit onto the Riemann sphere by inverse stereographic projection. This step keeps the accumulated increments finite near infinity. A third panel exports an MP4. It resamples the path, computes a field for every frame, and encodes the video with FFmpeg. The code lifts the grid onto the sphere once and reuses it across all frames.











