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 can I set the value of c when generating a Mandelbrot fractal?

The equation for generating a Mandelbrot fractal is Zn+1 = Zn^2+C. The issue is that, in a computer program, C is used for zoom/resolution and location on screen. My question is, how can I make it so that I can get a fractal like…
ack
  • 1,181
  • 1
  • 17
  • 36
0
votes
1 answer

Win2D: Correct usage of CanvasVirtualControl

I want to draw the mandelbrot-set taken from the Win2D-Example-Gallery and tweak it a little. At first I had all my code to generate the mandelbrot inside the CreateResources-Method of CanvasAnimatedControl, but due to performance issues I went on…
Manticore
  • 1,284
  • 16
  • 38
0
votes
2 answers

Code execution slower with OpenMP

I am trying to speed up the execution of the following code with OpenMP. The code is for calculating a mandelbrot and output it to canvas. The code works fine single threaded, but I want to use OpenMP to make it faster. I tried all sorts of…
martin49
  • 182
  • 2
  • 8
0
votes
1 answer

haskell, figuring use some defined function to draw the mandelbrot, need explanation

I've write several function that need to used in function mandelbrot to draw it, here are these: # sp that takes integer n, element y, list xs. insert the specified element y after every n elements. sp 1 'a' ['b','c','d'] =…
o1xhack
  • 87
  • 9
0
votes
0 answers

I'm trying to zoom in on a mandelbrot

I'm building an application where you can zoom in on the mandelbrot by clicking at a point in the mandelbrot. When clicked, the position of the click will be the center of the canvas and the scale will be multiplied by 2 (so you zoom in). But it…
jrip
  • 140
  • 1
  • 10
0
votes
1 answer

Point-Zoom on Mandelbrot Set in C# - It works, except when the mouse has moved

I'm able to point zoom on the Mandelbrot set, as long as the mouse doesn't move after zooming has begun. I've tried calculating a normalized delta (new coordinate - old coordinate)*(oldzoom), but what happens is the image appears to jump around to a…
applejacks01
  • 249
  • 1
  • 18
0
votes
2 answers

Comparison is always false due to limited range of data type trying to saturate colors

I'm trying to saturate my colors and make sure they do not overflow so that they will draw a pretty Mandlebrot set without being pixelated. I'm using an Altera DE2 board to try and print this Mandlebrot set via VGA connection to a computer screen…
Coltstick
  • 5
  • 4
0
votes
2 answers

Using a BufferedImage to draw the Mandelbrot set, only getting a solid color

I'm writing a Java program to display the Mandelbrot set for my introductory programming class. I believe I've got all of the math set up correctly, however when I attempt to draw the fractal I end up getting just a solid color. I've tested the math…
0
votes
3 answers

What would be the best choice of smooth coloring algorithm for Mandelbrot

I am rendering a mandelbrot set and have already achieved somewhat smooth coloring, but when looking closer the picture becomes very noisy. I am wondering, what would be the best way to improve my coloring to achieve better aesthetics. Would using…
0
votes
1 answer

Python code for printing Mandelbrot set

I am trying to print the Mandelbrot set in the following code but it print half screen white and half black. I have gone through the code many times but I don't know where I am going wrong. Can someone please help from tkinter import * size =…
ttt956618
  • 3
  • 3
0
votes
1 answer

Same function? runs about 10 time slower with GMP(C++)

I wrote a Mandelbrot zoom in c++ but the zoom was limited due to floating point inaccuracy. That's why I wrote the whole thing againg with the GMP library. But now I have problems with the performance. I'm new to GMP so maybe I just messed up a few…
Joel
  • 51
  • 4
0
votes
1 answer

Threaded Mandelbrot program C++

To preface this: I'm currently a first-year student who was allowed to enroll in some second-year classes. Because of this, I'm currently wrangling a language (C++) that I haven't really had the time to learn (First-years mostly learn C#), so this…
HBraaksma
  • 21
  • 2
0
votes
1 answer

Mandelbrot PPM drawing is always black

I want to draw Mandelbrot to PPM file in C. My code is working but my drawing is always black. I have this code from wikia. The key to my success is to think "alfa" (i think so). I have no idea what alfa should be. Here's my code: #include…
upgrade11
  • 57
  • 8
0
votes
2 answers

Love2d GLSL shader script fails to retrieve texture_coords variable

Heello, everyone! I've been trying to write a script that uses GLSL to render a Mandelbrot set, but something weird is happening. I call the effect functio like this: vec4 effect( vec4 color, Image texture, vec2 texture_coords, vec2…
Vitu Tomaz
  • 61
  • 1
  • 8
0
votes
3 answers

Last threads execute slower than first threads while writing to an array

I'm trying to optimize a Mandelbrot set generator, the problem is that i am trying to make it multi threaded by using the _beginthread() function. The computing problem I'm solving is running a function on a 2D plane, I am trying to run about 8…
Bruno
  • 77
  • 1
  • 2
  • 5