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

Having trouble calculating mandelbrot set iterations

So I read up this article: http://www.wikihow.com/Plot-the-Mandelbrot-Set-By-Hand But I'm stuck at step 7. I'm drawing the set in javascript canvas. All I need is basicly the C value I guess. for (var y = 0; y < ImageHeight; y++) { for (var x =…
user625860
4
votes
1 answer

My Mandelbrot Set displays wrong outlines when plotting with few iterations

I'm writing a program that plots the Mandelbrot set in C. I've been able to display it and it looks fine however when I lower the number of iterations I get this effect that generates what I can only describe as "clouds": And here's how it should…
Gabriel
  • 75
  • 5
4
votes
1 answer

How to prevent my Mandelbrotset code from getting blurry

I have written the mandelbrotset in java,but if i want to zoom into it it gets blurry after around 14 clicks, no matter the Maxiterration number, if its 100 it gets blurry and if its 100000 it gets blurry after 14 zoom ins.Something i noticed is…
4
votes
1 answer

Using Julia to plot the mandelbrot with multithreading, race condition problem

I'm new to Julia and I am trying to implement Julia's multithreading but I believe I am running into the "race condition problem". Here I am plotting the mandelbrot but I believe because of the race condition the array index [n] is messing with the…
Fernando
  • 109
  • 1
  • 8
4
votes
1 answer

Mandelbrot set smooth colouring function

I programmed the Mandelbrot set with python but that was weird looking so I searched for smooth colors. I've programmed a smooth colouring function using log and linear interpolation but whatever I try I can't get what I want: self.palette = [(3,…
Hugo
  • 59
  • 10
4
votes
1 answer

AVX calculation precision

I wrote a program to display the mandelbrot set. To speed it up, I used AVX (really AVX2) instructions through the header. The problem is: The result of the AVX computation (with double precision) has artifacts, and it differs to the…
Feanor
  • 320
  • 2
  • 11
4
votes
1 answer

Shapes in the Mandelbrot Set

Are the intriguing and lovely Mandelbrot Set hoops and curls the result of floating point computation inaccuracy? I have written various Mandelbrot Set implementations, such as a dynamic zoom and playback. Some use fixed point arithmetic, others use…
Weather Vane
  • 33,872
  • 7
  • 36
  • 56
4
votes
2 answers

Mandelbrot Sequence with Python's Turtle

I am trying to draw the mandelbrot sequence with python's turtle graphics. I am using two classes, one to represent the mandelbrot sequence. class Mandelbrot: def __init__(self,c,limit=50): self.__limit = int(limit) self.__colormap =…
Connor Simone
  • 41
  • 1
  • 2
4
votes
2 answers

File Output using Gforth

As a first project I have been writing a short program to render the Mandelbrot fractal. I have got to the point of trying to output my results to a file ( e.g. .bmp or .ppm ) and got stuck. I have not really found any examples of exactly what I am…
sheepez
  • 986
  • 1
  • 10
  • 26
4
votes
4 answers

Some help rendering the Mandelbrot set

I have been given some work to do with the fractal visualisation of the Mandelbrot set. I'm not looking for a complete solution (naturally), I'm asking for help with regard to the orbits of complex numbers. Say I have a given Complex number derived…
Alex
  • 4,844
  • 7
  • 44
  • 58
4
votes
1 answer

LeafletJS: How to flip tiles vertically on-the-fly?

Background: I've produced a 1-terapixel rendering of the Mandelbrot Set and am using LeafletJS to zoom and pan around in it interactively. It works great. But since the Mandelbrot Set is symmetric along the real axis, I'm currently using twice as…
Todd Lehman
  • 2,880
  • 1
  • 26
  • 32
4
votes
1 answer

Unexpected error in Julia set rendering

I am playing with Mandelbrot and Julia sets and I encountered interesting problem. The Mandelbrot set can be rendered in double precision until zooms of around 2^56 at any place. However, the Julia set sometimes produces artifacts much sooner like…
NightElfik
  • 4,328
  • 5
  • 27
  • 34
4
votes
0 answers

How to smooth exterior color gradient in Mandelbrot fractal generation?

This is my progress with a mandelbrot fractal generation: It appears with cases where the edge cases between colors are small, it has a good "blending" effect. However, as the distance between colors become larger, you can see very explicitly and…
theGreenCabbage
  • 5,197
  • 19
  • 79
  • 169
4
votes
2 answers

Mandelbrot Set in OpenMP

Can someone help me to improve this code and give me some hints. I was trying to create an OpenMP version of Mandelbrot set on my own. I'm OpenMP beginner and here I'm not getting some speed up, it is probably because of #pragma omp critical but I…
Mite Ristovski
  • 231
  • 4
  • 9
4
votes
2 answers

Normalized Iteration Count does not work. What am I doing wrong?

As you can see from the title, I'm busy programming a little programm for visualizing fractals in Java. Anybody who deals with fractals will come to the point where he/she searches for a solution to get these stupid "bands" away, when you just…
1 2
3
24 25