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

Drawing a rectangle while dragging the mouse on Mandelbrot Fractal ( Conversion to C# from Java )

This is my second post on Mandelbrot fractal conversion from Java to C#. As per my assignment, I need to Draw a mandelbrot fractal on a form, and once it is drawn, allow the user to Zoom in using the mouse, while also drawing a rectangle from the…
Bibhushan
  • 11
  • 5
0
votes
1 answer

Increase efficiency in Clojure Mandelbrot generator

I wanted to learn Clojure and started with a Mandelbrot generator using quil, I got it to work - however it takes some time to generate images and is a massive resource hog. Any advice for how to make it faster or if you spot any un-clojure-esque…
Xycaan
  • 1
0
votes
2 answers

In Java, map visible spectrum to RGB based on calculated integer (higher ints should be closer to ultraviolet, lower ints closer to infrared)

It's for a Mandelbrot set rendering (see: https://en.wikipedia.org/wiki/Mandelbrot_set); the color of each point should be based on the number of iterations it took for the complex number Z to escape the set. I would like to map the colors such…
Mat Jones
  • 936
  • 1
  • 10
  • 27
0
votes
1 answer

c++ mandelbrot function exporting fully black image

I'm supposed to be writing a program that exports a Mandelbrot image according to a file, but for some reason the ppm always comes out solid black. I understand that this means the values are always being printed as 0, but I'm not sure why. The…
0
votes
0 answers

Draw Mandelbrot using OpenCl

I want to write a program to draw a Mandelbrot set to an image. I'm using OpenCl and cl.hpp - wrapper to c++, but I don't know why this isn't working. I try draw image with different width and height, but mostly I get white image with random colored…
Blagalin
  • 799
  • 2
  • 8
  • 21
0
votes
1 answer

Mandelbrot Recursive Function for C

I am new to coding and am required to make a Mandelbrot function. For those of you who don't know, the Mandelbrot set is a set of complex numbers. Essentially, you take a complex number to start with, then square it and add it to the original…
Jon Smith
  • 1
  • 1
  • 1
0
votes
2 answers

extending mandelbrot to generate julia

working on a project requiring me to use same code ,note in the same file to generate mandelbrot set and julia sets ,i hav a working mandelbrot set but can see how to extend to julia set using same code. maybe am not getting the differences between…
user46772
  • 241
  • 1
  • 2
  • 13
0
votes
2 answers

Getting invalid operand to binary error in C Mandelbrot Program

I'm supposed to write a program in C to create the Mandelbrot. I have specific instructions to follow and I'm pretty sure I have followed them correctly. The question I have is that when I try to compile my code with gcc (using the make command) I…
0
votes
2 answers

Converting Screen Coordinates to Complex Coordinates

Can someone please show me how to convert from screen coordinates to complex? This picture shows the specific details about conversion Providing with the steps of how you get a relationship between the two would be really appreciated. Thanks
gmoney
  • 51
  • 1
  • 6
0
votes
1 answer

improper mandelbrot set output plotting

i am trying to write a code to display Mandelbrot set for the numbers between (-3,-3) to (2,2) on my terminal. The main function generates & feeds a complex number to analyze function. The analyze function returns character "*" for the complex…
Puneet S. Chauhan
  • 745
  • 1
  • 8
  • 17
0
votes
0 answers

Python - Color changing depending on coordinate?

i've successfully wrote a code that plots the mandelbrot set, but now i try to put different colors according to the iterations before it diverges, but i just can't get it to work. here is my code, i don't know what's wrong with it ... from math…
SlashBow
  • 1
  • 1
0
votes
1 answer

Mandelbrot set on python using matplotlib + need some advices

this is my first post here, so i'm sorry if i didn't follow the rules i recently learned python, i know the basics and i like writing famous sets and plot them, i've wrote codes for the hofstadter sequence, a logistic sequence and succeeded in…
SlashBow
  • 1
  • 1
0
votes
2 answers

Rendering an image, using C

I am currently working on a program that will generate the mandelbrot set. While I am able to code the set, I do not know how to produce an image using C. Do I have to write to a new file? Do I need a special program to draw? Are there any libraries…
Xanadu
  • 9
  • 1
  • 2
0
votes
1 answer

Changing the center of a GUI with mouseclick, and repainting

I've got a GUI that generates a graphics image using the Mandelbrot set. I've implemented some zoom buttons, but I'd like to be able to change the centre of my GUI with a mouseclick (make mouse coordinates the new centre-point). It's proving to be…
Graham03
  • 31
  • 4
0
votes
2 answers

Generating an image of the Mandelbrot set

I've been trying to generate an image of the Mandelbrot set but something is obviously very wrong. Here's the image this code produces: http://puu.sh/csUDd/bdfa6c1d98.png I'm using Scala and processing. The coloring technique is very simple but i…