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
1
vote
2 answers

a function which determines if a given point(x, y) is in the mandelbrot set or not

So given any point (a + ib), the function will return 1 if it is in the mandelbrot set or 0 if not for n amount of iterations. I'm having difficulties trying to code this function, especially with the complex numbers. Can anyone help me or give some…
mandelbrot
  • 11
  • 2
1
vote
1 answer

Mandelbrot code not exciting when resolution is higher than 320 pixels?

I am learning C and trying new things to test what I can do. I have written code which produces a Mandelbrot set with a given resolution (RES) which is #define RES in the .h file. This works and produces good output for resolutions less than 321.…
Iain McL
  • 164
  • 1
  • 10
1
vote
1 answer

What's wrong with my maths in my attempt to draw the Mandelbrot set?

I am currently trying to code a programm in python which result in drawing the mandelbrot set. The shape of the fractal looks ok but the outline isn't precise at all. I am trying to figuring if the problem comes from my maths or my code I tried to…
1
vote
1 answer

Numba JIT giving LoweringError although code works fine otherwise

I have the following code in python to calculate the Mandelbrot set. It works fine, but when I try to compile it with JIT by adding @jit decorator before the function def, it doesn't work any more. Can anybody tell me why? I would appreciate if you…
1
vote
1 answer

Some problems with generating the Mandelbrot set

I wrote a program on processing to generate the mandelbrot set and was successful but once i changed c to a constant complex number, I was unable to get any patterns with my program. I must be having a blind spot since I can't seem to debug my…
Him Chan
  • 41
  • 1
1
vote
1 answer

My Mandelbrot sketching program in c# isn't working

I have to make a c# program which creates a form and one of its controls has to be a control that makes a sketch of a Mandelbrot set in which you can zoom in and tell on which point you want to centre. In my opinion i'm doing the right thing, but…
1
vote
0 answers

Third Mandelbrot's The Charm

for the third time, my project has been malfunctioning. Not malfunctioning per se, but it is absolutely not doing what I need it to do. So, basically, I need to draw a mandelbrot fractal. It needs to accept data from the user like maximum…
1
vote
1 answer

Mandelbrot Set in JavaFX using own Complex class

I'm trying to generate a Mandelbrot Set in Java using my own Complex class. It needs to be zoomable and have a coloring function, which I didn't implement yet. I'm using an algorithm written by my teacher, but for some reason, I'm getting an image…
1
vote
2 answers

Mandelbrot set on Java - Is there something wrong with my algorithm?

I was asked to display the Mandelbrot set on Java but I have encountered a problem. My teacher and I both are stumped to why this doesn't run correctly. I reckon it has something to do with the algorithm or the complex class since all values except…
matthew
  • 13
  • 4
1
vote
0 answers

Can not find mistake in mandelbrot set code SSE assembly

Im programming mandelbrot set in assembly using SSE. I use interrupt: mov ax,0x4F02 mov bx,0x107 int 0x10 to set video mode to 1280x1024 pixels with 256 colors, then I enable A20 gate and switch correctly to 32 bit protected mode and allow fpu and…
Segy
  • 213
  • 2
  • 12
1
vote
4 answers

Building and animating fractals

Can anyone recommend any software/books required to learn and build fractal patterns? I want to also be able to animate the fractal patterns too. Like something off of winamp.
user559142
  • 12,279
  • 49
  • 116
  • 179
1
vote
0 answers

Using Gaussian Filter in C++ AMP returning wrong colours

I'm trying to use a Gaussian filter on a generated Mandelbrot set, and I have a solution that will work sequentially. However, I do want to have a solution that works using GPU processing. I'm using C++ AMP to use GPU processing. An issue with…
Liam_Foth
  • 13
  • 2
1
vote
0 answers

Colormapping the Mandelbrot set by iterations in python

I am using np.ogrid to create the x and y grid from which I am drawing my values. I have tried a number of different ways to color the scheme according to the iterations required for |z| >= 2 but nothing seems to work. Even when iterating 10,000…
jskizz121
  • 11
  • 1
1
vote
2 answers

Simple Mandelbrot set in Python

I've looked at other questions regarding this, but I can't seem to figure out where I am going wrong. The goal is to "Write a program to make an image of the Mandelbrot set by performing the iteration for all values of c = x + iy on an N × N grid…
Nora Bailey
  • 15
  • 1
  • 5
1
vote
2 answers

Parallelism on two duo-core processor system

I wrote a Java program that draw the Mandelbrot image. To make it interesting, I divided the for loop that calculates the color of each pixel into 2 halves; each half will be executed as a thread thus parallelizing the task. On a two core one cpu…
nobody
  • 2,709
  • 6
  • 35
  • 37