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
votes
2 answers

Mandelbrot set in swift

I am trying to generate a Mandelbrot fractal using the draw function to draw CGRects of points included in set. The code doesn't work and I get a circle instead. Any help? I am a beginner so sorry if I posting this in the wrong place. This is the…
seddouguim
  • 504
  • 3
  • 12
-1
votes
1 answer

tensorflow variable.assign_add function is mysterious in this example

I'm trying to learn tensorflow from working examples online but came across the example where i'm literally wondered how it works. Can any explain the maths behind this particular function of tensorflow and how [ns] get its value out of boolean data…
M. Ilyas
  • 13
  • 3
-1
votes
1 answer

I need help implementing bigger more precise floats. (Mandelbrot Renderer)

__float128 is way too slow I am not experienced in GMP or MPFR what so ever. Is there anything I could do? this is a very cut down version of my code. The cut down code is missing many elements: Code I'm new to stack overflow #include…
Spl1ce
  • 9
  • 1
-1
votes
1 answer

OpenGL Crashes With Heavy Calculation

I am new to OpenGL. My first project consists on rendering a mandelbrot set (which I find quite fascinating) and due to the nature of the calculations that have to be done I thought it would be better to do them on the GPU (basically I apply a…
Jeff Ekaka
  • 75
  • 5
-1
votes
1 answer

Writing a mandelbrot set to an image in python

I am trying to write a mandelbrot set to an image in python, and am having a problem with one of my functions. The issue is: While I expect something like this. I am getting a plain white image. Here is my code: Quick Summary of code: Check if…
-1
votes
1 answer

Mandelbrot optimization in openmp

Well i have to paralellisize the mandelbrot program in C. I think i have done it well and i cant get better times. My question if someone has an idea to improve the code, ive been thinking perhaps in nested parallel regions between the outer and…
-1
votes
1 answer

Mandelbrot practice problems

i have been experimenting with the mandelbrot java thing and i seem to be stuck on drawing the image.I used a JFrame and Jpanel to create this. I know the for loops are wrong as I've just been experimenting with it. public Mandelbrot(){ JFrame…
kkk
  • 33
  • 5
-1
votes
2 answers

mandelbrot set vertical display

Just wondering how to display a mandelbrot set vertically, like a mandelbrot set as this is positioned horizontally: I was thinking more like viewing the smaller dimensions from the vertical axis.
john smith2
  • 45
  • 1
  • 7
-2
votes
1 answer

Zooming in on mandelbrot in python

This is my current code which is currently creating two images instead of zooming in. How would I change the code to create on fractal that zooms in its self? Thank you so much! import numpy as np import matplotlib.pyplot as plt SIZE = 50 def…
-2
votes
1 answer

Can't get color smoothness to work with mandelbrot set using CImg

So in a step to learn C++ i decided to try to implement the mandelbrot set using CImg. Here is my program: #include #include #include #define cimg_use_png #include "CImg.h" using namespace cimg_library; const int…
Toerktumlare
  • 12,548
  • 3
  • 35
  • 54
-2
votes
1 answer

Julia set code creates a circle instead of a fractal

I have this code: from PIL import Image import colorsys xmin, xmax = -2.0, 2.0 ymin, ymax = -2.0, 2.0 depth = 12 imgx, imgy = 512, 512 maxIter = 256 image = Image.new("RGB", (imgx, imgy)) for y in range(imgy): cy = y * (ymax - ymin)/(imgy…
Alex Ruan
  • 13
  • 4
-2
votes
2 answers

Add iterations control to Mandelbrot

I have calculated that the current Mandelbrot iterates 208,200 times. But if I use a break to control the iterations it outputs kinda like a printer that has ran out of ink half way through, so I am obviously not doing it correctly, does anyone know…
Stacker-flow
  • 1,251
  • 3
  • 19
  • 39
-2
votes
1 answer

Why does my bc-math doesn't work?

In my function I want to use php bc-math to improve the precision. I've tried to replace all operations to no avail. Is this is a float-to-string conversion problem? function complex_iterate($re,$im) { $re=strval($re); …
Micromega
  • 12,486
  • 7
  • 35
  • 72
-3
votes
1 answer

Why WebAssembly is so slow?

I'm implementing a Mandelbrot Set visualization using Rust with WebAssmbly, where my goal is to make it using multi-threading. I've implemented the Mandelbrot Set both in Javascript (using Typescript) and in Rust single-threaded so far. I've made…
Daniel Ramos
  • 2,115
  • 3
  • 18
  • 28
-3
votes
1 answer

How I can make my Mandelbrot plotter faster?

How I can make my Python program faster? This program calculates the Mandelbrot set and draws it with turtle. I think the problem is in the for loop. Maybe the steps are taking too much time. import numpy as np import…
akinoioi
  • 21
  • 2
1 2 3
24
25