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

How to perform Simple Zoom into Mandelbrot Set

I have a general question with the Mandelbrot set "zoom" view and the math pertaining to it. I have implemented the mandelbrot set for the 256 X 256 window size with values // ImageWidth = ImageHeight = 256; double MinRe = -2.0; double MaxRe…
Legolas
  • 12,145
  • 12
  • 79
  • 132
2
votes
1 answer

Python Tkinter mandelbrot set more accurate than c without a clear explanation

The following code draws a Mandelbrot set using Tkinter's Photo image format , using 256 iterations and a 256 color custom palette. If you run it it displays a beautiful image with long smoky filaments and no concentric boundaries between iteration…
Antoni Gual Via
  • 714
  • 1
  • 6
  • 14
2
votes
1 answer

Issue with Mandelbrot smooth coloring

I implemented the regular algorithm to display the Mandelbrot set and colour it, and now I'm working on the smooth colouring features using a 255 colourmap. This part is already well documented online (and even on this forum) and I choose the most…
Eccsx
  • 185
  • 2
  • 13
2
votes
2 answers

Problem coloring the Mandelbrot set on Android

I have a problem with coloring the Mandelbrot set. This is my onDraw() procedure: @Override protected void onDraw(Canvas canvas) { g = Math.round(60+(iter_count*(2500/16))); iter_count++; for(int xx = 1; xx <= xMax; xx++) { for(int…
Henry
  • 23
  • 2
2
votes
1 answer

Implementing series approximation/perturbation theory for WebGL2 based Mandelbrot viewer application

I have started building a mandelbrot viewer application with WebGL2 and JavaScript and am trying to implement series approximation at a basic level. I'm currently getting weird/distored/incomplete images depending on the number of iterations and the…
badross92
  • 93
  • 3
  • 6
2
votes
1 answer

Combining nine-fold cusp multibrot and enneagram using Python

I am working on Python and LaTeX (preferably vector graphics TikZ/Asymptote/PGF/Metapost/GeoGebra, in that order) codes that generates this animation by running simple code on your terminal. Here is a thread on Tex.SE in which several methods of…
2
votes
1 answer

Higher precision in JavaScript

I am trying to calculate with higher precision numbers in JavaScript to be able to zoom in more on the Mandlebrot set. (after a certain amount of zooming the results get "pixelated", because of the low precision) I have looked at this question, so I…
2
votes
2 answers

displaying Mandelbrot set in python using matplotlib.pyplot and numpy

I am trying to get a plot of a Mandelbrot set and having trouble plotting the expected plot. As I understand, the Mandelbrot set is made up of values c, which would converge if are iterated through the following equation z = z**2 + c. I used the…
bluecat
  • 23
  • 6
2
votes
1 answer

Mandelbrot in a Pixel Shader

I'm working for some days now on a DirectX 11 version of the Mandelbrot set. What I've done so far is create a quad with a texture on it. I can color the points with a Pixel Shader, but for some reason the Mandelbrot set in the Pixel Shader does not…
Gilles Walther
  • 126
  • 1
  • 7
2
votes
0 answers

How much precision is needed to represent n/2^k, given a boundary of -2 to +2?

Apologies for the poorly phrased title. I tried to do better, but perhaps someone can suggest a better title. As a test case for another project, I'm working with the Mandelbrot set, using only value that can be properly represented, ie. n/2^k. (at…
Zacariaz
  • 537
  • 2
  • 7
  • 13
2
votes
1 answer

Creating a coordinate lookup in a window

I'm working with PyGame and attempting to create a zoomable/scaleable Mandelbrot Set. I have this set up for square windows and coordinates that only from -1 to 1 on both axes in the complex plane. The way I do this is for every pixel on the screen…
2
votes
1 answer

When trying to create an inverted Mandelbrot-set it's distorted

When I make a normal Mandelbrot set, it works fine. But when I try to invert it into a teardrop-like thing (see here for more context: https://www.youtube.com/watch?v=mLJJUElQMRY) it is completely distorted and looks nothing like a teardrop. I've…
MorganS42
  • 656
  • 4
  • 21
2
votes
0 answers

Rendering the mandelbrot set in color (and making it look good)

I'm trying to render the Mandelbrot set in color and make it look good. I'm want to replicate the image from the Wikipedia page. The Wikipedia image also included an Ultra Fractal 3 parameter file. mandelZoom00MandelbrotSet { fractal: …
Indiana Kernick
  • 5,041
  • 2
  • 20
  • 50
2
votes
2 answers

Mandelbrot Set - Color Spectrum Suggestions?

Recently I started making Mandelbrot set, but I wasn't able to find a good color spectrum. Here's my result But I want to create something like this: Any Suggestions? Thanks!
user8108238
  • 79
  • 2
  • 4
2
votes
1 answer

Mandelbrot program isn't outputting correct data

I've been given an assignment for my class to make a program that draws Mandelbrot figures. We have to basically get the program to draw a bitmap of the result. Thing is, my CalcMBF function only outputs 2 as the Mandelbrot number. I have absolutely…