Questions tagged [mandelbrot]

The Mandelbrot set is a fractal in the complex plane.

Many programmers write their own Mandelbrot generators as a way of sharpening their coding (and, to a lesser extent, maths) skills; there are interesting programming challenges to be solved, and a beautiful visual journey as you explore the depths of the set.

The algorithm

At its heart, plotting the Mandelbrot set is a question of complex maths:

  1. Map a grid of pixels to a region of the complex plane
  2. For each complex point, apply the formula Zn+1 = Zn + C, where:
    • C is the point's complex co-ordinates
    • Z0 = 0
  3. Iterate each point until the point is distance greater than 2 from the origin, or until you get bored (often a fixed iteration limit).
  4. If a pixel did not escape, it is part of the Mandelbrot set and traditionally represented by a black pixel; otherwise, apply your choice of colouring algorithm to decide what colour to paint the pixel.

Challenges

In the process of writing a non-naive Mandelbrot set plotter there are a number of algorithmic and architectural challenges to be solved.

On deep zooms it is possible to reach the limit of precision of the double type, leading to the question of how one might go further; arbitrary-precision arithmetic is one answer, while some brave souls implement their own fixed-point types.

Creating a plot is a very CPU-intensive process, so optimisation rapidly becomes important in order to be able to generate a plot in a reasonable time. As individual points do not depend on each other (with most plotting algorithms), it is possible to parallelise the work - which is itself a further challenge.

There is also the question of whether and how the user interacts with the plotter.

Further reading

  • Wikipedia has a detailed description of the fractal, its history, pseudo-code for the basic algorithm and descriptions of a number of extensions.
  • Wolfram has a purely mathematical description of the fractal and many links to related work.
361 questions
3
votes
1 answer

Why does this CUDA code for calculating a Mandelbrot set fail when setting the maximum iteration count higher than 5,500,000?

I'm writing a code synthesizer which converts high-level models into CUDA C code. As test model, I'm using a Mandelbrot generator application which executes the iteration count for each X-Y coordinate in parallel on a GPGPU. The image is 70x70…
gablin
  • 4,678
  • 6
  • 33
  • 47
3
votes
3 answers

What are the fastest algorithms for rendering the mandelbrot set?

I've tried many algorithms for the rendering of the Mandelbrot set, inclusive of the naive escape time algorithm, as well as the optimized escape time algorithm. But, are there faster algorithms that are used to produce really deep zooms efficiently…
Vivekanand V
  • 340
  • 2
  • 12
3
votes
2 answers

Multiplications with doubles c++

I'm new to C++ and I wanted to code the mandelbrot set in it to get some practise and compare the speed to Python. My function to iterate to see if the complex number blows up to infinity looks like this: int iterate(double ir, double ii, int…
kamelfanger83
  • 97
  • 1
  • 7
3
votes
3 answers

how do I get infinitely small numbers (for fractals)

I'm programming the Mandelbrotset with C++ using OpenGL, but I've run into a problem: the floats I'm sending to and calculating in my shader can only fit a certain amount of decimal places. So if I zoom in too far it just gets pixelated. I thought…
Space Kek
  • 49
  • 1
  • 4
3
votes
1 answer

multithreaded mandelbrot set

Is it possible to change the formula of the mandelbrot set (which is f(z) = z^2 + c by default) to a different one ( f(z) = z^2 + c * e^(-z) is what i need) when using the escape time algorithm and if possible how? I'm currently using this code by…
Leizer
  • 51
  • 1
3
votes
0 answers

Calculate Mandelbrot set for greater precision

Is there any practical way to perform calculations such as those involved in generating the Mandelbrot Set for values for precise that what double or long double can provide? I was thinking of possibly having two variables(either double or long),…
Yaakov Schectman
  • 301
  • 1
  • 2
  • 10
3
votes
1 answer

Genetic Programming with the Mandelbrot Set

I'm reading a chapter in this fascinating book about using genetic programming to interactively evolve images. Most of the function set is comprised of simple arithmetic and trig functions (which really operation on and return images). These…
3
votes
0 answers

Mandelbrot fractal smooth coloration with lookup continuous array

I know several questions about mandelbrot fractal smooth coloring techniques have already been asked (and answered). However none of them details how to build an array of continuous colors in plain C. I read extensively about smoothing color…
user3154898
  • 271
  • 1
  • 3
  • 13
3
votes
2 answers

Big float for shader-based mandelbrot explorer

I've managed to create a simple mandelbrot explorer using Open Gl, and the CGFX SDK provided by NVidia. It works well, but is currently float based, and therefore doesn't have much "depth" -- As the distance from the lowest complex number to the…
3
votes
3 answers

Coloring the Mandelbrot set in Matlab

I made a program to calculate points that are in the mandelbrot set. For the points not belonging to the mandelbrot set I keep track of how many iterations it take for the starting point to diverge to where the magnitude is greater that 2. Basically…
Slugger
  • 665
  • 1
  • 5
  • 17
3
votes
3 answers

How would you continuously improve the mandelbrot fractal?

I've seen many mandelbrot image generator drawing a low resolution fractal of the mandelbrot and then continuously improve the fractal. Is this a tiling algorithm? Here is an example: http://neave.com/fractal/ Update: I've found this about…
Micromega
  • 12,486
  • 7
  • 35
  • 72
3
votes
1 answer

Clojure/Java Mandelbrot Fractal drawing

I am trying to port this algorithm to clojure. My code is (defn calc-iterations [x y] (let [c (struct complex x y)] (loop [z (struct complex 0 0) iterations 0] (if (and (< 2.0 (abs z)) (> max-iterations…
Hamza Yerlikaya
  • 49,047
  • 44
  • 147
  • 241
2
votes
2 answers

Mandelbrot set reaches to its limit way too soon

im calculating mandelbrot set, with the ability of zooming and printing it to the screen using OpenGL. as you know mandelbrot set is defined by a rectangle(top right point and bottom left point) and every time i 'zoom in' and 'zoom out' i change…
igal k
  • 1,883
  • 2
  • 28
  • 57
2
votes
4 answers

Coloring mandelbrot set

I have came up to something like this: float MinRe = -2.0f; // real float MaxRe = 1.0f; float MinIm = -1.0f; // imaginary float MaxIm = MinIm + (MaxRe - MinRe) * WindowData.Height / WindowData.Width; float Re_factor = (MaxRe - MinRe) /…
Neomex
  • 1,650
  • 6
  • 24
  • 38
2
votes
2 answers

how to translate mandelbrot's size to its zooming value

my mandelbrot set is defined in a XY world as a rectangular shape, meaning at any given time i know its most bottom left and upper right corners. is there any way to know what is the total zooming percentage value from the original size by the size…
igal k
  • 1,883
  • 2
  • 28
  • 57