Learning with Mandelbrot and Julia

Venansius Tjahjono, Songhe Feng, Endah R.m. Putri, H. Susanto

Abstract

Recent developments in applied mathematics increasingly employ machine learning (ML)—particularly supervised learning—to accelerate numerical computations, such as solving nonlinear partial differential equations. In this work, we extend such techniques to objects of a more theoretical nature: the classification and structural analysis of fractal sets. Focusing on the Mandelbrot and Julia sets as principal examples, we demonstrate that supervised learning methods—including Classification and Regression Trees (CART), K-Nearest Neighbors (KNN), Multilayer Perceptrons (MLP), and Recurrent Neural Networks using both Long Short-Term Memory (LSTM) and Bidirectional LSTM (BiLSTM), Random Forests (RF), and Convolutional Neural Networks (CNN)—can classify fractal points with significantly higher predictive accuracy and substantially lower computational cost than traditional numerical approaches, such as the thresholding technique. These improvements are consistent across a range of models and evaluation metrics. Notably, KNN and RF exhibit the best overall performance, and comparative analyses between models (e.g., KNN vs. LSTM) suggest the presence of novel regularity properties in these mathematical structures. Collectively, our findings indicate that ML not only enhances classification efficiency but also offers promising avenues for generating new insights, intuitions, and conjectures within pure mathematics.

Introduction

Fractals like the Mandelbrot and Julia sets are defined by the asymptotic behavior of a dynamical system. Specifically, given a complex number $c$, the orbit is generated by the iteration $z_{n+1} = z_n^2 + c$. If the sequence remains bounded, the starting point belongs to the set; if it escapes to infinity, it does not. Traditionally, determining membership requires computationally expensive numerical "thresholding"—checking if the orbit escapes a radius after many iterations (e.g., 100 or more).

This paper explores using supervised machine learning to classify points in these sets based on just the first few iterations of their orbits. Surprisingly, standard models like Random Forests and K-Nearest Neighbors achieve up to 95% accuracy using only four iterations, vastly outperforming traditional numerical thresholding. This suggests that early fractal orbits encode deep geometric regularities, opening new avenues for using ML as an analytical tool to uncover hidden structures in pure mathematics.

Methodology

The authors treat the classification of fractal sets as a standard supervised learning problem.

  • Input Features: The real and imaginary parts of the first $I$ iterates of a point's orbit, where $I$ ranges from 1 to 4. This results in a low-dimensional feature space (up to 8 dimensions).
  • Models: Seven standard ML models were evaluated: Classification and Regression Trees (CART), Random Forests (RF), K-Nearest Neighbors (KNN), Multilayer Perceptrons (MLP), 1D Convolutional Neural Networks (CNN), and Recurrent Neural Networks (LSTM and BiLSTM).
  • Baseline: The models were compared against the classical thresholding method (THRESH) restricted to the same number of early iterations.

Datasets were generated by uniformly sampling points from three domains: the Mandelbrot set, a specific Julia set ($c = -0.5125+0.52129i$), and a zoomed-in boundary region of the Mandelbrot set. For each experiment, 10,000 training samples and 1,000,000 test samples were used, with ground truth labels determined by the classical algorithm run to 100 iterations.

Key Results and Insights

The experimental results demonstrate that machine learning significantly outperforms traditional thresholding when limited to early iterations.

Testing accuracy for Mandelbrot set classification with I=4 iterations.

For the Mandelbrot set at $I=4$, KNN and RF achieved accuracies of ~95.8% and ~95.6%, respectively, while THRESH only managed 78.9%. Similar trends were observed for the Julia set, where RF reached ~89.7% accuracy.

Testing accuracy for Julia set classification with I=4 iterations.

Several key insights emerged from the analysis:

  • Infinite behavior is visible early: It is highly counterintuitive that the infinite-time behavior of a chaotic fractal system can be accurately guessed from just 4 steps. The ML models' success implies that early orbit iterates encode significant, previously unexploited geometric information.
  • Simpler is better for short sequences: Random Forests and KNN consistently beat complex recurrent models (LSTM/BiLSTM). Because the input sequences are so short ($I \le 4$), the long-range temporal dependency modeling of RNNs is underutilized and merely adds model variance, penalizing performance.
  • Greedy algorithms fail on fractals: CART (decision trees) performed poorly on the Julia set. A Gini impurity analysis revealed that CART over-indexes on the very first iterate and discards the richer, more subtle dynamics found in steps 2-4.
  • A new mathematical conjecture: Driven by the empirical success of these models, the authors propose a formal mathematical hypothesis: that a measurable classification function exists mapping a finite number of early iterates to asymptotic boundedness.

Conclusion and Future Work

The authors acknowledge limitations regarding class imbalance in boundary regions, which caused some neural network models to collapse. Future work will focus on boundary-aware oversampling techniques and testing longer orbit sequences to see if/when RNNs surpass simpler models. Ultimately, this framework demonstrates that ML not only enhances classification efficiency but also offers promising avenues for generating new insights and conjectures within pure mathematics.

Summary updated

Abstract

Recent developments in applied mathematics increasingly employ machine learning (ML)-particularly supervised learning-to accelerate numerical computations, such as solving nonlinear partial differential equations. In this work, we extend such techniques to objects of a more theoretical nature: the classification and structural analysis of fractal sets. Focusing on the Mandelbrot and Julia sets as principal examples, we demonstrate that supervised learning methods-including Classification and Regression Trees (CART), K-Nearest Neighbors (KNN), Multilayer Perceptrons (MLP), and Recurrent Neural Networks using both Long Short-Term Memory (LSTM) and Bidirectional LSTM (BiLSTM), Random Forests (RF), and Convolutional Neural Networks (CNN)-can classify fractal points with significantly higher predictive accuracy and substantially lower computational cost than traditional numerical approaches, such as the thresholding technique. These improvements are consistent across a range of models and evaluation metrics. Notably, KNN and RF exhibit the best overall performance, and comparative analyses between models (e.g., KNN vs. LSTM) suggest the presence of novel regularity properties in these mathematical structures. Collectively, our findings indicate that ML not only enhances classification efficiency but also offers promising avenues for generating new insights, intuitions, and conjectures within pure mathematics.
BibTeX
@inproceedings{tjahjono2025learning,
  author = {Venansius Tjahjono and Songhe Feng and Endah R.M. Putri and H. Susanto},
  title = {{Learning with Mandelbrot and Julia}},
  booktitle = {Nonlinear},
  year = {2025},
  doi = {10.1007/s11071-025-11697-w},
}
Figure