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
2
votes
1 answer

Zoom MandelBrot Set

My calculations seem to be moving the image around more than scaling it. Not quite sure where I'm going wrong. I thought I followed the other post on here correctly but it's not quite right. int xPos = ev.xbutton.x; int yPos = ev.xbutton.y; double…
Jarrod Cabalzar
  • 408
  • 1
  • 5
  • 24
2
votes
2 answers

How to divide each pixel calculation of Mandelbrot into different nodes?

My question here is what data structure should I use to distribute the work to each threads and get the calculated value from them. First thing in my mind is fill vector[0] .. vector[63999] (for 800x800 pixel) with struct that holds x,y and…
solti
  • 4,339
  • 3
  • 31
  • 51
2
votes
2 answers

MandelBrot set Using openCL

Trying to use the same code (sort of) as what I have used when running using TBB (threading building blocks). I don't have a great deal of experience with OpenCL, but I think most of the main code is correct. I believe the errors are in the .cl…
Mike Tarrant
  • 291
  • 2
  • 7
  • 19
2
votes
1 answer

some mandelbrot drawing routine from c to sse2

I want to rewrite such simple routine to SSE2 code, (preferably in nasm) and I am not totally sure how to do it, two things not clear (how to express calculations (inner loop and those from outer loop too) and how to call c code function…
user2214913
  • 1,441
  • 2
  • 19
  • 29
2
votes
2 answers

Low resolution Mandelbrot fractal not... high enough resolution?

Okay, here's a weird one that I'm having problems with (compiled with gcc btw) Below is source for a Mandelbrot fractal generator for command prompt. I've done this before and I wanted to speed test myself to see how fast I could produce the code…
Parad0x13
  • 2,007
  • 3
  • 23
  • 38
2
votes
1 answer

What is the relationship between julia set and mandelbrot set?

I wrote a mandelbrot set and I have read about the julia set that it's very similar but what is the relationship exactly? Can I use the mandelbrot formula to draw a julia set? What is the starting parameter? Read my code for a mandelbrot set: …
Micromega
  • 12,486
  • 7
  • 35
  • 72
2
votes
2 answers

How do I let multiple Threads paint onto an AWT component?

EDIT: solved, look below for my solution. first of all, this is my very first question here, so if I make any mistakes, please tell me. I am trying to write a Mandelbrot Fractal Program in Java, for training purposes. The ideal for all the…
Lucas Werkmeister
  • 2,584
  • 1
  • 17
  • 31
1
vote
1 answer

mandelbrot image creation using pthread

i am getting an error: invalid lvalue in assignment. this is the only error with my program, it looks like a fatal compile time error regards on specially pthread. i am trying to get the inputs in the runtime, using command line arguments, that's…
visanio_learner
  • 373
  • 3
  • 4
  • 12
1
vote
2 answers

how to find the center of the mandelbrot set

is it possible to find the center of the big black spot(the area which with the set?) I've tried to loop through all points which are in the set, sum their locationד and eventually divided by the num of points which are in the set. it didn't work…
igal k
  • 1,883
  • 2
  • 28
  • 57
1
vote
1 answer

OpenGL height-map painting using CUDA VBO

I've asked several questions regarding VBO previously here and from the comments i had received i decided that a new approach must be taken. To put it simply - I'm trying to draw the Mandelbrot set which is defined on a large FLOAT array, around…
igal k
  • 1,883
  • 2
  • 28
  • 57
1
vote
1 answer

Mandelbrot zooming difficulty

I'm not sure to which area this question is related , but I will give it a go. I'm trying to calculate the Mandelbrot set. The big difference is that my output is a 3D model. The set's calculation is done precisely, but once I try to zoom to a x,y…
igal k
  • 1,883
  • 2
  • 28
  • 57
1
vote
1 answer

Optimise Mandelbrot set plotter in python using pygame

I have used 2 for loops to check if the points are within the set, but apparently it takes too much time, giving less details on the plot itself. How can I optimise the code to run faster, and thus add more detail to the plot ? The pygame origin is…
astle dsa
  • 11
  • 3
1
vote
1 answer

A Mandelbrot Comparison Logic issue that refuses to be resolved

I want to see the implementation of the Mandelbrot Set working (script provided by BruXy.regnet.cz), but one line of code is giving me problems to resolve. In the While-loop, a logic AND comparison is made between two tests; while [ $B -le 32 -a $V…
Den
  • 173
  • 11
1
vote
0 answers

How to zoom/move into the mandelbrot set

I'm doing the Mandelbrot set in c as a school project.
This is my code: int mandelbrot(int x, int y, t_data *data) { double complex c; double complex z; double cx; double cy; int i; cx =…
1
vote
0 answers

parallelizing Mandelbrot using MPI

I am trying to parallelize the Mandelbrot. the correct output should be around 1.510659. however I am not getting that correctly. ** PROGRAM: Mandelbrot area ** ** PURPOSE: Program to compute the area of a Mandelbrot set. ** The correct…