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

Java Mandelbrot visualization questions on zooming and coloring

I am trying to program a visualisation for the Mandelbrot set in java, and there are a couple of things that I am struggling with to program. I realize that questions around this topic have been asked a lot and there is a lot of documentation online…
Eliturbo
  • 21
  • 2
2
votes
1 answer

Mandelbrot image generator in C++ using multi-threading "overwrites(?)" half the image

I don't really know how to explain my problem properly, but hopefully you can understand it using the images i provide. I made this Mandelbrot image generator using a template and a tutorial on the internet, and i'm trying to make the generation…
P. Protas
  • 416
  • 4
  • 15
2
votes
1 answer

How can I solve exponential equation in Maxima CAS

I have function in Maxima CAS : f(t) := (2*exp(2*%i*%pi*t) - exp(4*%pi*t*%i))/4; here: t is a real number between 0 and 1 function should give a point on the boundary of main cardioid of Mandelbrot set How can I solve equation…
Adam
  • 1,254
  • 12
  • 25
2
votes
0 answers

Explain "Coloring the Mandelbrot Set in Matlab" line 13

Preface on the Former Post I had a question related to this post from 4 years ago "Coloring the Mandelbrot Set in Matlab" but I don't have enough reputation to comment directly on the post. The code Chris Taylor provided in the post was…
ApBrown
  • 35
  • 7
2
votes
1 answer

Segmentation fault with memcpy in C in parallel mandelbrot algorithm: How to use pointers in a struct?

The goal is to write a parallelization out of a sequential mandelbrot algorithm. I'm having some problems with my the data types and pointers. This is how my main.c looks like: int main(int argc, char **argv) { /**** Here are initializations…
Laura
  • 21
  • 1
2
votes
1 answer

Mandelbrot set 'tearing' at different X and Y values

The most pressing problem i have with my code is that when i change the X and Y dimensions to for example X = 501, Y = 500 the mandelbrot set tears completely (see pictures). The X and Y axis are also inverted. My goal is to achieve a similar result…
xvy.
  • 81
  • 7
2
votes
2 answers

Gforth parallel processing

I have written a Forth Mandelbrot fractal plotter, and as much as a technical exercise as anything else I would like to try to speed it up with some parallel processing. For the time being I would be happy if I could just use both of my cores (have…
sheepez
  • 986
  • 1
  • 10
  • 26
2
votes
2 answers

Mandelbrot Set not displayed

a Mandelbrot set fractal using C programming and OpenGL. Here is my code. It is only displaying a dot in the center right now. I cannot figure out where I am going wrong. I'm pretty sure my math is correct. Maybe I have something in the wrong…
I31
  • 57
  • 1
  • 1
  • 11
2
votes
1 answer

Failing to render mandelbrot in pyopencl

I am working on optimizing my Mandelbrot renderer in pyOpenCL and want to split the iterations in chunks so i can better utilize my GPU. Example with max iterations=1000 and 2 "chunks": 1. Run the mandelbrot escape algorithm for iterations 0-500. 2.…
SleepProgger
  • 364
  • 6
  • 20
2
votes
1 answer

Rendering the mandelbrot set in OpenGl

I have to render the mandelbrot set and I was wondering if someone could point out some flaws with my code - at the moment, the output windows just shows a black screen. I think that my mandelbrot mathematics are correct, because I have used the…
Borzi
  • 537
  • 1
  • 5
  • 21
2
votes
1 answer

Smooth Zoom with mouse in Mandelbrot set (C)

I've been working on a C Mandelbrot set program for the past few days and I managed to make it work fine, however, my end goal is to be able to smoothly zoom in the set with my mouse and that's something I haven't yet been able to do yet so I might…
Dukev
  • 23
  • 1
  • 4
2
votes
0 answers

Error in write.gif using R

I'm trying to run the following code in R (taken from the bottom of the R Wikipedia page) as I'd like to play around with it myself once I get it up and running: library("caTools") jet.colors <- colorRampPalette(c("#00007F", "blue", "#007FFF",…
user11128
  • 295
  • 1
  • 2
  • 12
2
votes
1 answer

Failed JS Mandelbrot Set generator outputs odd structure

I made this simple Mandelbrot Set generator in Javascript last night, but it outputs a really strange structure. I think it looks similar to the mandelbrot set, yet oddly deformed. I have no idea why it distorts like this, and I've been trying to…
Irratix
  • 25
  • 4
2
votes
1 answer

mandelbrot using openMP

// return 1 if in set, 0 otherwise int inset(double real, double img, int maxiter){ double z_real = real; double z_img = img; for(int iters = 0; iters < maxiter; iters++){ double z2_real = z_real*z_real-z_img*z_img; …
Nancha
  • 21
  • 4
2
votes
2 answers

python3 memoryerror when producing a large list

I'm a beginner. I recently see the Mandelbrot set which is fantastic, so I decide to draw this set with python. But there is a problem,I got 'memoryerror' when I run this code. This statement num_set = gen_num_set(10000) will produce a large list,…
轩字语
  • 23
  • 1
  • 4