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

Setting Mandelbrot Python Image Background Color to Cyan

How do I set the Mandelbrot Set background to cyan? I don't understand the code. Here's the code: # Python code for Mandelbrot Fractal # Import necessary libraries from PIL import Image from numpy import complex, array import colorsys # setting…
Neo
  • 29
  • 4
1
vote
0 answers

Is there a faster way to render the Mandelbrot set for an animation?

I'm trying to code the Mandelbrot set as a fun project. I did it on my own, so it probably isn't optimized very well. I have a few questions about how to make my code better and how to add certain things to it. I used the library p5js, but that…
Eli Bauer
  • 29
  • 5
1
vote
1 answer

Smooth Coloring Algorithm for the Mandelbrot set on Delphi

I have problems using the smoot coloring algorithm. I just don't get them implemented in my Code. This is the main code which causes an error after some calculated pixel rows: g:=StrToInt(Edit3.Text); //maximum iteration count for x:=0 to Width…
Henry
  • 65
  • 6
1
vote
2 answers

Multi-threading slower than single thread

I am new to parallel programming. I have been playing around with multi-threading and for some reason, multi-threading the Mandelbrot set is slower than running a single thread. I have been trying to figure it out for hours. Are there any…
Niralana
  • 179
  • 3
  • 12
1
vote
0 answers

Can you refer to an original variable value after using a while loop in Python 3 while making a Mandelbrot iteration bound/unbound tester?

So, I'm making a Python 3 program where it tells you to enter a rational number, converts that number into a floating point, passes it through a while loop where it actually iterates, then notifies the user if its bound or unbound (basically seeing…
1
vote
1 answer

Drawing a Mandelbrot Set

I'm trying to make the function of the Mandelbrot Set, and I'm not sure what I'm doing wrong or right, here's the code: private void StartCircles() { float savePower = BlackCircle.anchoredPosition.x; GameObject[] AllCircles = new…
1
vote
1 answer

Updated iPython: Make your own Mandelbrot image not appearing

This is my first question so I am not sure if the formatting is correct. I am reading the book Make Your Own Mandelbrot by Tariq Rashid using iPython (Jupyter Notebook). It seems that iPython has changed since this book was written so I have been…
1
vote
1 answer

CUDA- Invalid __global__ write of size 4

I have implemented the Mandelbrot set in Cuda. When I input the height and width present in the attached code I get this error by running the cuda-memcheck command. What is it caused by? I believe that it may be due to an overflow error of the index…
Tony
  • 13
  • 3
1
vote
1 answer

"Big Float" Mandelbrot runs slower on GPU than CPU

I just ported over my "big float" implementation over to OpenCL, but it turns out that the GPU was slower than the CPU? That's quite surprising as I thought that Mandelbrot was an embarrassingly parallel problem. GPU Preview render completed. Time…
Ignis Incendio
  • 190
  • 1
  • 10
1
vote
0 answers

How to (make a ) scale for C# in a panel?

Hi im new to c# and I am trying to learn how to (make a) scale in a panel. I have created a Mandelbrot, but now I have to zoom in on -2 to 2 in both axes. My question is, how do I make a scale (e.g x,y 0.01) for this panel in which I can choose the…
1
vote
2 answers

Mandelbrot Set C# not doing what it's supposed to

I am new to coding and I have started my journey by learning C# as my first programming language. As an assigment I am trying to code a program that draws a Mandelbrot set, but it is not drawing what it is supposed to and I can't seem to find any…
1
vote
0 answers

OOM on GPU with tensorflow while making Mandelbrot

Trying to get a beautiful Mandelbrot picture, the code works great with 16k resolution but I can't get it to render a 32k image I tried lowering cycles to 50 but still no difference Specs - i9 10900k & RTX 3090 24gb I get an OOM message saying W…
TheDOC
  • 11
  • 2
1
vote
0 answers

Increasing the float precision for plotting Mandelbrot fractal using GPU

I have written a program in python to plot the Mandelbrot set using pygame, multithreading and numba. Unfortunately, I can't zoom more than 1e-15 because of the limit of floats precision. When I do it become all pixelated. I heard about the decimal…
Biloba
  • 23
  • 4
1
vote
1 answer

Julia Set - problem with own Mathematica implementation

I've been working on my own Julia Set Plot Implementation. I don't want to use JuliaSetPlot, (however I'm eager to use JuliaSetIterationPoints and JuliaSetCount, I just don't really know how). I've come up with something like this, but I have a…
1
vote
0 answers

Adding axis to a .png file

On a mission i took to myself i tries to make the Mandelbrot set, and my next step is to add axis to the image. Since it's a picture and not a graph, this is very difficult. Can you help me? Thx
Yonatan
  • 7
  • 1