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

How to make a color progression out of a color palette

My goal with this algorithm I'm working on is to output a color progression out of some provided colors. By color progression I mean creating the "fade" effect between two colors (color A, color B) and store every color value ((R,G,B) tuple) in…
6
votes
0 answers

Webgl double precision emulation with two floats has no effect

While playing arround with Mandelbrot set generation in WebGl I've inevitably stumbled on a small accuracy of OpenGl's 32bit float. Yet, new hope was born when I found this great article. Carefully, I took functions from aforementioned source and…
Max Yari
  • 3,617
  • 5
  • 32
  • 56
6
votes
2 answers

Mandelbrot set displays incorrectly

This is my attempt to program the Mandelbrot set in Python 3.5 using the Pygame module. import math, pygame pygame.init() def mapMandelbrot(c,r,dim,xRange,yRange): x = (dim-c)/dim y = (dim-r)/dim #print([x,y]) x =…
6
votes
1 answer

C Mandelbrot Set Coloring

I am working on the following code in C. So far it has all been working and it is zoomed to the correct level, etc, however I am struggling with getting the colors to work as I want. Ideally I would like to end up with something like this regardless…
Kane
  • 61
  • 4
5
votes
1 answer

How do I zoom into the mandelbrot set?

I can generate a 400x400 image of the Mandelbrot set from minReal to maxReal and from minImaginary to maxImaginary. So, makeMandel(minReal, maxReal, minImaginary, maxImaginary); I need to modify it so that I can have, makeMandel(centerX, centerY,…
Alex
  • 239
  • 1
  • 3
  • 6
5
votes
0 answers

Getting bad results with distance estimator for Julia set

I've been working on drawing the Julia set using a distance estimator instead of the normalized iteration count. I usually use the code below and play around with the iteration count until I get a decent enough picture double…
Ozymandias
  • 839
  • 1
  • 8
  • 13
5
votes
2 answers

How to 'zoom' in on a section of the Mandelbrot set?

I have created a Python file to generate a Mandelbrot set image. The original maths code was not mine, so I do not understand it - I only heavily modified it to make it about 250x faster (Threads rule!). Anyway, I was wondering how I could modify…
Lobe
  • 415
  • 1
  • 5
  • 8
5
votes
2 answers

how to zoom mandelbrot set

I have successfully implemented the mandelbrot set as described in the wikipedia article, but I do not know how to zoom into a specific section. This is the code I am using: +(void)createSetWithWidth:(int)width Height:(int)height Thing:(void(^)(int,…
Nippysaurus
  • 20,110
  • 21
  • 77
  • 129
5
votes
1 answer

Fractals explained

For a while now I've been interested in fractals, the math behind them and the visuals they can produce. I just can't really figure out how to map the mathematical formula to a piece of code that draws the picture. Given this formula for the…
Dennis Haarbrink
  • 3,738
  • 1
  • 27
  • 54
5
votes
2 answers

Mandelbrot set implementation in Scheme is very slow

I am trying to learn Lisp/Scheme and I tried implementing a very simple version of the mandelbrot set in it to get practice. The problem I ran into is that the code runs very, very slow. At first I thought it was because I was using recursion…
5
votes
1 answer

Calculate a dynamic iteration value when zooming into a Mandelbrot

I'm trying to figure out how to automatically adjust the maximum iteration value when moving around in the Mandelbrot fractal. All examples I've found uses a constant of 1000 or less but that's not enough when zooming into the fractal set. Is there…
Anders Cedronius
  • 2,036
  • 1
  • 23
  • 29
5
votes
1 answer

How does Mandelbrot perturbation work?

Could someone please explain how perturbation described in this paper accelerates rendering the Mandelbrot set? I know how to render the Mandelbrot set using the traditional method where many iterations are performed for each pixel, but I don't…
zero
  • 51
  • 2
5
votes
1 answer

Export MATLAB figure into high resolution bitmap image

I have plotted a Mandelbrot image in using MATLAB with 7680*4320 pixels resolution, but when I export the image using bitmap or JPG format, the output file will have 1366*651 pixels which is my laptop screen resolution. How can I export the figure…
Babi
  • 131
  • 2
  • 4
5
votes
4 answers

quick/fast integer multiplication in ruby?

I am trying to make a quick/efficient Mandelbrot implementation in Ruby. A long long time ago, one way to speed it up was using fixed point integers instead of floats. So i made the following benchmark, comparing float and integer raising to a…
nathanvda
  • 49,707
  • 13
  • 117
  • 139
5
votes
2 answers

Zooming in on Mandelbrot set fractal in Java

I am beginning to make a mandelbrot set fractal viewer. I am having a lot of issues when it comes to zooming in on the fractal. If you try to zoom, the viewer will just close in on the center. I have done as much as I can to understand this dilemma.…
user1938979
  • 79
  • 1
  • 1
  • 5
1
2
3
24 25