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

how to do zoom in my code (mandelbrot)

i have the following code and i wanted to know how may i insert zoom into my code.(i read some similar subjects but i can't figure). GLsizei width = 600; GLsizei height = 600; int max = 500; double xpos=0,ypos=0; double xmax = 2.0; double xmin =…
George
  • 5,808
  • 15
  • 83
  • 160
0
votes
1 answer

paintfunction drawing out of size of panel and starting in upper left corner

I'm troubleshooting my program in which I want to draw the mandelbrot set, so I made it so it draws 1x1 rectangles on every pixel except it doesn't do every pixel, it only does 1 row. I've already tried setting the y to 400 and subtracting until it…
Space Kek
  • 49
  • 1
  • 4
0
votes
2 answers

Time complexity of mandelbrot set in term of big O notation

I'm trying to find the time complexity of a simple implementation of mandelbrot set. with following code int main(){ int rows, columns, iterations; rows = 22; columns = 72; iterations = 28; char matrix[max_rows][max_columns]; …
RAwais
  • 1
  • 1
0
votes
1 answer

How to zoom into a Mandebrot set with Matlab by calculating more points?

I am trying to zoom into a Mandebrot set with Matlab, which is based on a meshgrid. After the first plot you can pick two points which define the zoom area and between these two points a new meshgrid is generated. This new meshgrid is the origin for…
Amigo54
  • 5
  • 2
0
votes
1 answer

Implementing smooth coloring of Mandelbrot set

Recreating the way I color my Mandelbrot set I'm having a hard time implementing it in JavaScript. I currently use the common "escape time" algorithm: for(px = 0; px < a; px+=scale){ for(py = 0; py < b; py+=scale){ x0 = panX + px/zm; y0…
MMJM
  • 117
  • 1
  • 11
0
votes
1 answer

Calculate Mandelbrot set without complex objects

I am trying to calculate the Mandelbrot set in Python 3.6 and i don't want to use the complex objects to calculate it. Does anybody have a getIterationCount(x, y) function? I tried to rewrite java code to python but it didn't work. def…
MaxTheGuy
  • 51
  • 9
0
votes
1 answer

How to adjust panning while zooming

I want to pan while zooming into a Mandelbrot set so that the fractal portion of the function stays within the window. The code outputs a series of png images to later be made into a video. Right now, I have the zooming and panning working but I do…
Ferko
  • 1
  • 4
0
votes
0 answers

adding to QQueue crashes program

I'm trying to draw a Mandelbrot set in QT. All is done and it's looking good, but it need some time to calculate the color of pixel, so i wanted to split picture in 4 and give calculation to separated threads. Threads are working and the problem is:…
Lacwik
  • 1
  • 1
0
votes
1 answer

how to speed up multiprocessed python

I'm trying to generate a Mandelbrot Set image, but the image takes ages. The code is annoyingly slow, so If you can help me speed it up, that would be very helpful. thanks. Note that code compiles and runs from my IDE. I am new to multiprocessing,…
0
votes
0 answers

Weird behaviour with python on multiprocessing

I am coding a Mandelbrot set generator and I have parallelized it with 4 subprocesses, each one calculate a different region of Mandelbrot set. The parallelizing code is the following: def run_threads(self): # Parallelize calcs with 4…
Midepizzas
  • 11
  • 1
0
votes
1 answer

Use colorsys module to produce rainbow effect on Mandelbrot and Julia sets

I have some code that creates two images: two Mandelbrot sets, and one Julia set. However, I want to spice things up a bit by making them "rainbow-y" using colorsys. Here is my code so far: from PIL import Image import colorsys imgx, imgy = 512,…
Alex Ruan
  • 13
  • 4
0
votes
1 answer

Mandelbrot set rendering too slow

I have made a program on Javascript that creates the mandelbrot fractal and I drew it in an html canvas. My method to render it is to iterate per row, from 0 to 500 pixels and then simply do a loop that creates 500 rows of 500 pixels. My problem is…
0
votes
0 answers

Coordinate system of panels in c#?

I'm very new to c# and running into a problem while trying to program and visualize the Mandelbrotset. I have created a 400 by 400 panel and want to use this to graph the set. I want my graph to go from -2 to 2 on both axes so I'm using a scale of…
FleetL
  • 41
  • 1
  • 4
0
votes
1 answer

Noise in mandelbrot set

I am trying to create an Mandelbrot set in HTML5 canvas. But it is giving me noise surrounding the set. See the fiddle: https://jsfiddle.net/k1f9phw7/ I tried playing with every setting and tried to map brightness to the iteration count but with no…
0
votes
1 answer

gpu decimal precision

I have created a mandelbrot set in javascript which uses the gpu but because javascript decimals are not so accurate when I zoom in to much the screen goes pixely. If i were programing it on the cpu it would not be so hard but because I am using…