This repository implements the algorithm of the Mandelbrot set to create both static and dynamic representations of the set on a complex plane.
The Mandelbrot set is a famous fractal named after the mathematician Benoît B. Mandelbrot. It is a set of complex numbers that produces a distinctive, infinitely complex boundary when plotted. The set is defined by iterating the function:
[ f_c(z) = z² + c ]
where ( z ) starts at zero and ( c ) is a complex parameter. The Mandelbrot set includes all values of ( c ) for which the orbit of ( z ) does not escape to infinity.
- Self-Similarity: The boundary of the Mandelbrot set exhibits self-similarity at different scales, meaning smaller portions of the boundary resemble the whole set.
- Complexity from Simplicity: Despite being generated from a simple iterative process, the Mandelbrot set produces highly intricate and beautiful patterns.
- Connection to Julia Sets: Each point in the Mandelbrot set corresponds to a specific Julia set, another type of fractal.
To determine if a complex number ( c ) is in the Mandelbrot set, we iterate the function ( f_c(z) = z² + c ) starting with ( z = 0 ). The number ( c ) is part of the Mandelbrot set if the absolute value of ( z ) remains bounded (does not go to infinity) after many iterations. Typically, the following steps are used:
- Initialize ( z = 0 ).
- Iterate the function ( z = z² + c ).
- Check if ( |z| > 2 ) (if so, ( c ) is not in the Mandelbrot set).
- Repeat for a maximum number of iterations or until ( |z| ) exceeds 2.
The number of iterations before ( z ) exceeds 2 can be used to color the point ( c ), creating a visual representation of the set.
- Static Representation: Generates a static image of the Mandelbrot set.
- Dynamic Representation: Creates an animated visualization of the Mandelbrot set's iterative process.
- Python 3.x
- Required Python libraries:
numpy
,matplotlib
,pyopengl
- Clone the repository:
git clone https://github.com/sparsh-karna/MandelbrotSet.git cd MandelbrotSet
- Install the required libraries:
pip install numpy matplotlib pyopengl
To generate a static image of the Mandelbrot set:
python static/mandelbrot_static.py
To visualize the Mandelbrot set dynamically:
python dynamic/mandelbrot_dynamic.py
static/
: Contains the script for generating static images of the Mandelbrot set.dynamic/
: Contains the script for creating dynamic visualizations of the Mandelbrot set.
Contributions are welcome! Please fork the repository and submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
For any questions or suggestions, please contact Sparsh Karna.