The Mandelbrot algorithm is used to determine whether a given point in the complex plane belongs to the Mandelbrot set. The set is defined by iterating the function:
[ Z_{n+1} = Z_n^2 + C ]
where (Z_0 = 0) and (C) is a complex number. If the absolute value of (Z_n) remains bounded after a fixed number of iterations, (C) is considered part of the Mandelbrot set.
- Select a rectangular region of the complex plane.
- For each pixel ( (x, y) ), convert it into a complex number ( C ).
- Initialize ( Z = 0 ).
- Iterate using the equation ( Z_{n+1} = Z_n^2 + C ).
- If ( |Z| > 2 ) before reaching the iteration limit, the point is outside the set.
- Assign a color based on the number of iterations before escape.
- If the iteration limit is reached, the point belongs to the Mandelbrot set and is usually colored black.
- Repeat for all pixels to render the fractal.
- Worst Case: ( O(N) ) per point, where ( N ) is the maximum number of iterations.
- Best Case: ( O(1) ), when the escape condition is met quickly.
- Overall: ( O(W \times H \times N) ) for an image of width ( W ) and height ( H ).
- Iterative Approach: ( O(1) ) (only a few variables needed for computation).
- Storing the Image: ( O(W \times H) ).
- Sequential (Naïve): Compute each pixel independently in a loop.
- Parallelization: Use multi-threading, SIMD, or GPU-based approaches to improve performance.
- Optimized Escape: Use period detection to reduce unnecessary iterations.
- Color Mapping: Utilize smooth coloring instead of discrete escape iteration count.
- CLBG (Computer Language Benchmarks Game) Mandelbrot Benchmark
- Official Source: https://benchmarksgame-team.pages.debian.net/benchmarksgame/
- Fractals Everywhere by Michael Barnsley
- Wikipedia: Mandelbrot Set