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

Interior Distance Estimate algorithm for the Mandelbrot set

I'm looking for a way to estimate the distance to the boundary of the Mandelbrot set from a point inside of it for use in a GLSL shader. This page links to various resources online touching on the subject of interior distance estimation such as the…
user2464424
  • 1,536
  • 1
  • 14
  • 28
1
vote
1 answer

How to centre an imshow() image?

I have a project in which I need to create mandelbrot and julia sets using python. I have two different sets of functions that 'work'. The first doesn't fully meet my criteria because it isn't taking sets of values. The second does everything I…
Lewis Dean
  • 31
  • 1
  • 3
1
vote
0 answers

How to zoom into Mandelbrot set by clicking

I managed to create the Mandelbrot set in processing but am struggling to implement a zoom. Here is my code: float minvalX = -1.5; float minvalY = -1.5; float maxvalX = 1.5; float maxvalY = 1.5; float angle = 0; float di,dj; int…
Pathfinder
  • 23
  • 4
1
vote
1 answer

My Mandelbrot does not look like it should. Does anyone know why?

I recently found out about the Mandelbrot set and now I am trying to generate a Mandelbrot set in Processing 3.0. I found a tutorial on youtube about programming it and tried to impelement it in Progressing. background(255); size(1280,…
Niklas
  • 29
  • 1
  • 6
1
vote
1 answer

Multithreaded Mandelbrot set code outputs incorrect image

#include #include #include #include #include #include #include #include #include using std::chrono::duration_cast; using…
1
vote
1 answer

I'm trying to create a GIF of zooming into the Mandelbrot set in Python but having some trouble with floats

from PIL import Image import numpy as np import math class Fractal(object): def __init__(self, resolution=(720,720), x_range=(-2.0,2.0), y_range=(-2.0,2.0), maxIterations=255, zoom=0, zoomRate=0): self.resolution = resolution …
user9989618
1
vote
2 answers

Mandelbrot set visualization

I'm trying to visualize Mandelbrot's set with processing, and it's the first time I do something like this. My approach is pretty simple. I have a function Z, which is literally just the set's main function (f(z)=z^2+c) and i do a loop for each…
Chappie733
  • 45
  • 6
1
vote
2 answers

Mandelbrot Set Zoom Distortion in C

I'm writing a C program to render a Mandelbrot set and currently, I'm stuck with trying out to figure out how to zoom in properly. I want for the zoom to be able to follow the mouse pointer on the screen - so that the fractal zooms in into the…
Artur
  • 41
  • 6
1
vote
1 answer

mandelbrot set gets blurry at around 2^47 zoom

So i created a simple mandelbrot zoom code that zooms in(lmb) or out(rmb) where you click. The portion that is render is halved every click as it zooms in the curve. The problem is no matter how large the maxiter and additer count is, the fractal…
Orbital
  • 565
  • 3
  • 13
1
vote
1 answer

Mandelbrot Set: Stripes Appearing in Deeper Zooms (>1E14) (Java)

A few years ago my brother and I wrote a Java code for the Mandelbrot Set. Yesterday I wanted to find some cool zooms with it but as I did more intense zooms I started to notice an issue (at a zoom value of around 1E14). It appears that pixels are…
1
vote
0 answers

Mandelbrot set zoom in python using pillow libray

i can't figure out how to zoom in mandelbrot set and how to change coordinates to zoom. I wondering should i set center of image in for example: x= -0.3123 and y = -0.1212 and now zooming it or to change x,y by any number? Can anyone please explain…
Yoshow2137
  • 31
  • 5
1
vote
1 answer

How do you draw the Mandelbrot Set in Java using SWING/AWT?

I'm trying to draw the Mandelbrot Set, with points in the set as black, and everything else as white. In this initial version, I do not wish to be able to zoom in but rather just create a static image. I created a ComplexNumber class, as shown…
Michael
  • 39
  • 9
1
vote
0 answers

Is there a way to achieve better accuracy than double but with better performance than BigDecimal?

I am creating a mandelbrot set application in java, but after a certain zoom it starts to look weird because doubles are not accurate enough. I refactored my code to work with BigDecimals, but the performance was absolutely terrible. Is there a way…
Finni
  • 429
  • 5
  • 17
1
vote
3 answers

Code help to determine if point is in Mandelbrot set (check my solution)

Here is my function that tests two points x and y if they're in the mandelbrot set or not after MAX_ITERATION 255. It should return 0 if not, 1 if it is. int isMandelbrot (int x, int y) { int i; int j; double Re[255]; double…
Carpe Diem
  • 107
  • 2
  • 8
1
vote
1 answer

Visual representation of the Mandelbrot set

I want to generate a PNG photo of the Mandelbrot set using Java, the output should be easily found on a google images search. The set is defined as the following sequence: z_n+1 = z_n^2 + c where c and z are complex numbers, and z always has a…
anisgh
  • 23
  • 2