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
1
vote
2 answers

Mandelbrot Set through shaders in GLSL with LOVE2d renders a circle, not a fractal

I'm trying to render a Mandelbrot Set using GLSL, but all I get is a full circle... I have checked the maths a lot, and I simply cannot find the error, so I thought maybe the problem was semantic. Is anyone able to see what's wrong? Also, could…
Vitu Tomaz
  • 61
  • 1
  • 8
1
vote
1 answer

parallelize Mandelbrot with OpenMP

I have a function which calculate mandelbrot set I'm trying to parallelize it using openMP. I put #pragma omp parallel for private before each for static void calculer (Image * im, int nb_iter, double x_min, double x_max, double y_min, double y_max)…
vikash78
  • 19
  • 4
1
vote
1 answer

Change contents of BufferedImage, then update JFrame to reflect it

I am trying to make a Mandelbrot Set renderer with a GUI where you can click and drag to zoom into a specific area. When run, it will do the initial calculations and rendering fine, but when you try to click and drag to zoom in, the console says it…
Mat Jones
  • 936
  • 1
  • 10
  • 27
1
vote
1 answer

Mandelbrot set defined by a specific function

I'm experimenting with canvas and I'm trying to modify this piece of code, but unfortunately I don't understand some parts of it. My question is - how to customize the above code to be defined for example by f(z) = c^e(-z) (the formula is taken…
user3845133
1
vote
1 answer

Smooth coloring algorithm

This question has been posted a lot, but I've read through the questions posted on here and built my own implementation awhile ago. I ditched the project and decided to give it another shot just now after digging through some old projects and coming…
user4746908
1
vote
0 answers

Mandelbrot - Multi instead of Single color

I have the following code from a class: #include #include #include #include #include #include void destroy(void) { gtk_main_quit(); } static void put_pixel (GdkPixbuf *pixbuf,…
tinkerton101
  • 25
  • 1
  • 8
1
vote
1 answer

Usage and problems of mandelbrot set and julia set

What is the usage of mandelbrot set and julia set in programming? Is there any sample competitive problems that use these set?
user4849230
1
vote
1 answer

smooth coloring algorithm for the mandelbrot set

I know there are a lot of questions alrady answered about this. However, mine varies slightly. Whenever we implement the smooth coloring algorithim as I understand it. mu = 1 + n + math.log2(math.log2(z)) / math.log2(2) where n is the escape…
user4701199
1
vote
1 answer

Mandelbrot set won't render correctly

I am currently trying to make an animated Mandelbrot set visualisation. But right now it won't even render a single frame correctly. I don't know where I made the mistake. I guess there is an error in the math.Will you please have a look at it? Here…
BrainStone
  • 3,028
  • 6
  • 32
  • 59
1
vote
6 answers

How to render Mandelbrot Set faster?

I'm currently drawing the Mandelbrot set pixel by pixel with PhotoImage and tkinter. I'm using basically the algorithm directly with no modifications. Are there methods to make the calculation faster? Maybe filling in large areas of color quickly,…
qwr
  • 9,525
  • 5
  • 58
  • 102
1
vote
1 answer

I made a processing program that generates a mandelbrot set but don't know how to effectively implement a zoom method

I'm not sure if it is possible in processing but I would like to be able to zoom in on the fractal without it being extremely laggy and buggy. What I currently have is: int maxIter = 100; float zoom = 1; float x0 = width/2; float y0 =…
1
vote
1 answer

Mandelbrot plot error matplotlib python 3.4

I am trying to to do a Mandelbrot plot for z′ = z^2 + c where c =x +iy on an N × N grid spanning the region where −2 ≤ x ≤ 2 and −2 ≤ y ≤ 2. and N =100. my ccom method is c =x +iy and my zcom method is for z^2 and my zprime method is for z' part i…
FireFistAce
  • 41
  • 3
  • 12
1
vote
1 answer

Bad Coloring in Mandelbrot set with C++ & OpenGL

I have the following Mandelbrot set code in C++ for use with opengl but the colours are not correct, these are the desired colors: but I get this: int vala = 600; int valb = 600; //render one frame void Application::render(void) { // Clear the…
Cheknov
  • 1,892
  • 6
  • 28
  • 55
1
vote
1 answer

c programming - Mandelbrot set

I am trying to display Mandelbrot set fractal using c programming, openGL, glut on linux. Here is my code. it only displays a dot in the center. not able to figure out where I am going wrong. any help? #include // Header File For The…
KawaiKx
  • 9,558
  • 19
  • 72
  • 111
1
vote
0 answers

Xcode Example DispatchFractal does not run in OS X 10.9, why

DispatchFractal is a superb example of Mandelbrot calculation, graphical plotting and zoom. And a great example of an Xcode project. But it no longer runs on OS X 10.9, on my iMac 24 (Early 2009). Does anyone know why, and have you found a fix for…