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
0
votes
2 answers

Mandelbrot set won't accelerate using pthread

So, I'm writing a program to compute the Mandelbrot set using pthread. This is the thread function: void *partial_compute(void *arg) { cout << "enter" << flush; Range *range = (Range*)arg; Comp z, c; for (int i = range->begin; i <=…
Wei-Tsung
  • 297
  • 3
  • 12
0
votes
1 answer

Mandelbrot set in java doesn't calculate correctly

I'm still relatively new to Java. I've been working on a program to display the mandelbrot set. My current code generates an image that is close, but not quite the mandelbrot set. This is my generation code: private void generateMap () { //…
leopardGeckos
  • 91
  • 2
  • 8
0
votes
1 answer

java mandelbrot set moving wrong

so I've been trying to program the mandelbrot set in java, I know the code isn't very optimized but i've just started out doing this. The idea is that when i click a pixel it will put that pixel in the center (that represents a certain complex…
poffsan
  • 3
  • 1
0
votes
1 answer

Smooth Coloring Mandelbrot Set Without Complex Number Library

I've coded a basic Mandelbrot explorer in C#, but I have those horrible bands of color, and it's all greyscale. I have the equation for smooth coloring: mu = N + 1 - log (log |Z(N)|) / log 2 Where N is the escape count, and |Z(N)| is the modulus of…
Sam Kennedy
  • 95
  • 1
  • 7
0
votes
1 answer

Trouble with creating Mandelbrot Set plot in C

I am trying to create a Mandelbrot set in C code; my output will be a data file, one column of the real parts and one column of the imaginary parts to be plotted in the Argand or complex plane. I have all the complex math stuff defined in a header…
user1535776
  • 599
  • 2
  • 5
  • 10
0
votes
0 answers

Quadtree and kd-tree splitting and mandelbrot set?

I've read about a quadtree or kd-tree splitting and a mandelbrot set but what when the rectangle before the first split and the frame lies in the mandelbrot set or has the same iteration depth and the algorithm returns from tiling? How can I force…
Micromega
  • 12,486
  • 7
  • 35
  • 72
0
votes
1 answer

More then 53-bit floating point precision in php?

Possible Duplicate: How do I work with high precision decimals in PHP For a mandelbrot fractal I need more floating-point precision then just 53-bit in php. Is this possible? I've read this post about php floating-point but it's hard to…
Micromega
  • 12,486
  • 7
  • 35
  • 72
0
votes
2 answers

Mandelbrot bad image precision color cycle?

I've created a mandelbrot in php but the mandelbrot is looking a bit strange. How can I improve it? You can find a live example here: http://www.phpdevpad.de/index.php?id=190. Update: Mandelbrot-Zoom with 900 iterations: Update: I use this method…
Micromega
  • 12,486
  • 7
  • 35
  • 72
0
votes
1 answer

How to zoom correctly a mandelbrot?

I'm trying to zoom into my mandelbrot and I read this question: How to perform Simple Zoom into Mandelbrot Set but I have difficult to understand it and it doesn't work. When I calculate the new real and complex number like so: double Re_factor =…
Micromega
  • 12,486
  • 7
  • 35
  • 72
0
votes
1 answer

bmp segmentation fault in C

I'm making bmp images of fractals (Mandelbrot's and BuddaBrot's) in a square frame and if I make the width 1000 pixels, no problem, but if I increase its width to 2000 I get a segmentation fault on the fist line of the program. Whats…
Jordan
  • 1,564
  • 2
  • 13
  • 32
0
votes
2 answers

C# Struct on a Mandelbrot set?

Previously posted a question on a C#.Net Mandelbrot set a while back which was helpfully answered, however I have had to go back to this Mandelbrot set and implement a struct on it's double variables that define the (imaginary and real)…
wilbomc
  • 183
  • 3
  • 13
0
votes
1 answer

why mandelbrot's boundary is 2?

I'm trying to understand why we're iterating through Mandelbrot points until |z| < 4. why 4? is there somekind of a law? or is it based on statistical measurements? thanks, igal
igal k
  • 1,883
  • 2
  • 28
  • 57
0
votes
1 answer

Applescript or Automator to save Mandelbrot image from website progressivly

Hello I have recently created a C program for my UNI Computing course that generates a web server at localhost:2020 and sends a bmp file of the Mandelbrot set. If you dont know what that is dont worry, its the url part thats important. The URL is…
Jordan
  • 1,564
  • 2
  • 13
  • 32
-1
votes
0 answers

I have a segmentation error in a program that generates mandelbrot fractal with mpfr

Recently I modified my mandelbrot fractal generation program to be able to integrate gmp and mpfr in order to zoom deeper into the fractal. But since I did this I have a segmentation error when I try to run the program I’m pretty new to c language…
ena0
  • 1
  • 1
-1
votes
1 answer

making mandelbrot set multithreaded

I want to make a Mandelbrot set, and make the whole process multithreaded. I am trying to do this with the internal thread library (or how that is exactly called). I can't use openmp for some reason. I think that is because of my laptop (mac…
Blenrine
  • 3
  • 2