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

Mandelbrot. Translating the coordinates of a canvas into the appropriate Complex number

I am trying to implement a simple java program to draw the MandelBrot Set using JAVA fx. I understand to count the iterations of when the number exceeds the absolute bound is z = z^2 + c, where z is growing. My question is, How do i translate a…
0
votes
2 answers

display bmp in statistic mandelbrot using c + mpi

#include #include #include #include #include #include #include #define NUM 512 int id,nproc; int colorbuf[NUM * NUM]; double cx0,cx1,cy0,cy1; int n; double dx,dy; int…
L.Y.C
  • 41
  • 2
  • 8
0
votes
1 answer

Mandelbrot set zoom limit

I've recently started learning Javascript/ WebGL and I've learned enough to put together a simple Mandelbrot fractal renderer. The program works fine but for some reason it won't let me zoom in more than about 20 times, and it starts looking…
0
votes
0 answers

Mandelbrot set using MPICH. Trying to learn but can't figure this bug out

I am trying to implement a master/slave relationship which solves the mandelbrot set and prints it into a ppm file. This is what I have so far: #include #include #include #include int…
tiger123
  • 23
  • 7
0
votes
1 answer

Printing an entire character array after looping through every point in a rectangular area

I'm using a double for-loop in order to check every point (coordinate pair) in a rectangular area from (-2.0, -1.12) to (0.47, 1.12) to see whether it belongs to the Mandelbrot set. If it does, I want to print a 1. Likewise, if it does not, I want…
0
votes
2 answers

julia set calculation with real numbers

I am trying to make a julia set image and programming this in C . I have tried researching an algorithm to create an image of the Julia set but am getting confused by most of the examples online (as most examples seem to be copied but with little…
0
votes
0 answers

Fast, arbitrary floating points in Python

So I'm trying to compute the mandelbrot set at very large magnifications, and have run into a bit of a brick wall. Using pythons own float paired with a jit gave me plenty of speed. But after having switched over to use decimal instead, my function…
0
votes
1 answer

Best language for generating Mandelbrot Set images?

I tried coding something in c#, which generates a mandelbrot set image (with smooth coloring), and it worked but produced very slow, probably because c# isn't the best language for it. What woould be the best language to generate lots of images in…
Potheker
  • 93
  • 8
0
votes
2 answers

16 million goroutines - "GC assist wait"

I'm running a go program that computes the mandelbrot set. A gouroutine is started for every pixel to compute convergence. The program runs fine for pixelLengthx = 1000, pixelLengthy = 1000. If I run the same code for pixelLengthx = 4000,…
jonathan
  • 29
  • 5
0
votes
1 answer

Zoom On Mandelbrot

I am trying to figure out a way to zoom in on my Mandelbrot set on click. I have it so when I click it slightly zooms in but it doesn't move the Mandelbrot accordingly. using System; using System.Collections.Generic; using…
James Barker
  • 11
  • 1
  • 3
0
votes
1 answer

C - Concatenate char arrays, then write to stdout different to writing single chars

so I have this task to create mandel fractals in C. I will keep the code simple as it's quite much. The Problem: in the given file, each pixel (char[3]) is calculated separately and then written to stdout via write(1, pixeldata, 3) NOW: as this…
iwilltry42
  • 45
  • 1
  • 10
0
votes
1 answer

Visualizing/saving an extremely large number of pixels with

I made a program in C++ which calculates the mandelbrot-set. Now I want to visualize it (save it in a picture). But when I try to save a 64k picture some problems come up. So what is the best way to save a picture of the pixels or at least to visual…
SgtDomo
  • 1
  • 1
0
votes
1 answer

c++ double more accuracy/precision

Is there any floating point type that stores more digits after the decimal point than double in c++ (or any alternative, which makes double stored more digits)? I've read that long double is maybe more accurate. In my program we can zoom into the…
csekri
  • 20
  • 1
  • 7
0
votes
1 answer

Mandelbrot using Pthreads, stepping through array

I am working on a project to rewrite a sequential C-code algorithm for creating a mandelbrot set into a parallel one using pthreads. I've gone up against a wall so to speak, as my version simply outputs a more or less black picture (and nothing to…
Jens Lomander
  • 111
  • 2
  • 10
0
votes
0 answers

Resolution with double layer matrix

Im currently trying to visualize shapes as a prep before eventually moving on to visualize the Mandelbrot Equation. I've got into some issues with the resolution though. In my render-method I'm fetching a matrix with complex values, and placing the…
Hazzlarn
  • 11
  • 4