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
3 answers

How to reduce the effect of pixelation by computing the color value at several points within each pixel and taking the average?

This is an exercise from The Go Programming Language by Donovan & Kernighan: Exercise 3.6: Supersampling is a technique to reduce the effect of pixelation by computing the color value at several points within each pixel and taking the average. The…
Shangchih Huang
  • 319
  • 3
  • 11
1
vote
0 answers

multithreaded mandelbrot set generates no speedup

I'm using the following code to generate the Mandelbrot set fractal but no matter the number of threads I use the time for computation doesn't really change (around 5s). I'm using the Intel i5-4200M Processor so I should get different result to at…
Leizer
  • 51
  • 1
1
vote
0 answers

How can I colour this Mandelbrot set?

This Mandelbrot set I created works well although I don't know how to colour like other ones on places like Wikipedia. My version is just plain yellow (see below). from graphics import * zoom = 0.1 xOffset = -0.171 yOffset = 0.61 def…
1
vote
1 answer

Mandelbrot Set Wrong Shape

I am currently trying to code a program which generates a mandelbrot-set. however even though i did a lot of testing with each single method. The shape of the whole set seems to be wrong .I am looking for help and would be really glad if someone…
1
vote
1 answer

Zooming using scrollwheel in java

I am trying to make a Mandelbrot program that allows zooming, but the zoom doesn't seem to be working, and i don't see what is wrong with the way i have implemented the zoom.I am using eclipse and the program doesn't return any errors. Here is my…
1
vote
1 answer

How to make a gif of mandelbrot fractal zoom (Python)?

I have made a Mandelbrot fractal using PIL module in Python. Now, I want to make a GIF of zooming into one point. I have watched other code on-line, but needless to say, I didn't understand it, since the pattern I'm using is a bit different (I'm…
1
vote
0 answers

openMP and Mandelbrot in C

I have to parallelize using openMP the serial version of a program in C to visualize a Mandelbrot set. I tried to do it but I obtain something really strange. #include #include #include #include #include…
wrong_path
  • 376
  • 1
  • 6
  • 18
1
vote
2 answers

How to properly configure coloring for mandelbrot set using python?

Looking for trainings on python I decided to draw the mandelbrot set using a script. Drawing it wasn't too complicated so I decided to use color and I discovered the smooth coloring algorithm. Using this question I was able to render something…
Lich4r
  • 1,305
  • 2
  • 13
  • 27
1
vote
0 answers

haskell takes a (x,y) and return a infinite list with the a definition of Orbit(x,y)

There is a function P(x,y) defined as: P(x,y)(u,v) = (u^2 - v^2 + x, 2uv + y) and define Orbit O(x,y) of a point (x,y) to be an infinite list of items: O(x,y) = {(0,0), P(x,y)(0,0), P(x,y)(P(x,y)(0,0)), P(x,y)(P(x,y)(P(x,y)(0,0))),..} So I need to…
o1xhack
  • 87
  • 9
1
vote
2 answers

How is a mandelbulb rendered?

I've never understood how something like a mandelbulb can be generated from mathematical data. The only way that makes sense to me is to use voxels, which is obviously not used in the image linked here. So if anyone could explain this to me, please…
Somebody
  • 333
  • 3
  • 12
1
vote
2 answers

I get circle instead of mandelbrot

I tried to follow formula closely, but somehow all I get is a circle. It's in mandelbrot set coordinates, I understand that much. for(x=-50;x<50;x++){ for(y=-50;y<50;y++){ // Canvas pixel coordinates to -2,2 var x2 = x * 0.04; var y2…
Maksim
  • 357
  • 1
  • 3
  • 11
1
vote
1 answer

Representing Mandelbrot and Julia Sets Graphically in Java

I'm working on a problem where I'm needing to represent the Mandelbrot set graphically using OpenCL and working on my sequential code first. However, the image it is producing isn't very good and I'm unsure if I've missed something somewhere or if…
Syzorr
  • 587
  • 1
  • 5
  • 17
1
vote
1 answer

Plot black and white mandelbrot set

Below code is taken from here. I am trying to make following change to the code below If c is not part of the set, plot a white pixel, and if it is part of the set, plot a black pixel. I am getting this output: But I want to plot a black and…
Stupid_Intern
  • 3,382
  • 8
  • 37
  • 74
1
vote
1 answer

How to plot black and white color picture mandelbrot plot

Below code is taken from here. I am trying to make following change to the code below If c is not part of the set, plot a white pixel, and if it is part of the set, plot a black pixel. Use the imshow command to plot your image % Parameters: % …
Stupid_Intern
  • 3,382
  • 8
  • 37
  • 74
1
vote
1 answer

How to change the colour of my Mandelbrot Set display?

I found some code to display a Mandelbrot set in java, this one has a turqoise colour theme and I was wondering how to change this to another colour, for example a red colour theme. Here is the code: import java.awt.Graphics; import…
John Smith
  • 679
  • 1
  • 9
  • 17