Skip to main content
48 votes

Increase performance creating Mandelbrot set in python

I'm going to reuse some parts of the answer I recently posted here on Code Review. Losing your Loops (Most) loops are damn slow in Python. Especially multiple nested loops. NumPy can help to ...
AlexV's user avatar
  • 7,278
27 votes
Accepted

Julia Fractal Drawing in C++

Unqualified names The namespace identifier is missing from a lot of names - e.g. std::sqrt, std::log, ...
Toby Speight's user avatar
  • 81.8k
20 votes

Increase performance creating Mandelbrot set in python

This will cover performance, as well as Python style. Save constants in one place You currently have the magic numbers 2000 and 3000, the resolution of your image. Save these to variables perhaps ...
Reinderien's user avatar
  • 65.6k
18 votes
Accepted

Barnsley's Fern

Trust the math. In elif clause of ...
vnp's user avatar
  • 57.3k
17 votes

Newton Fractal writen in C

Use complex numbers Since C99, C supports complex numbers, and has many mathematical functions that work on complex numbers. I would rewrite all your code to use ...
G. Sliepen's user avatar
  • 61.7k
15 votes
Accepted

Chaos with Newton’s method

Formatting Run your code through a style checker / formatter to make it more readable and follow a standardized code style. For example this one https://codebeautify.org/javaviewer Don't repeat ...
user985366's user avatar
  • 1,735
14 votes

Julia Fractal Drawing in C++

There's already a good answer, so I'm just going to raise a couple of small points. I had the same thought as Toby Speight about saving the square root of abs(z), ...
Peter Taylor's user avatar
  • 24.2k
14 votes

Increase performance creating Mandelbrot set in python

Don't use vectorized numpy, use numba jit instead Using numpy to calculate the Mandelbrot set is not really a good fit because the same data will be stored and loaded from and to memory repeatedly, ...
John's user avatar
  • 241
13 votes

Plotting the Mandelbrot set efficiently

Unnecessary use of OpenGL Using OpenGL to draw individual pixels is the completely wrong thing to do. Apart from requiring OpenGL support which might not be present on all systems, this has a huge ...
G. Sliepen's user avatar
  • 61.7k
12 votes

Increase performance creating Mandelbrot set in python

Mandelbrot-specific optimisations These can be combined with the Python-specific optimisations from the other answers. Avoid the redundant square root ...
trichoplax is on Codidact now's user avatar
9 votes
Accepted

Newton Fractal writen in C

I don't like parentheses around expressions returned. I do not understand init_roots(). Why not just initialise ...
greybeard's user avatar
  • 6,569
8 votes

Chaos with Newton’s method

I have some suggestions for your code. As @user985366 also stated in his/her answer, the biggest issue in your code, in my opinion, is the code duplication. For the colors, the ...
Doi9t's user avatar
  • 3,334
7 votes

OpenGL 3 Mandelbrot Set

This is pretty cool! Several people have posted their Mandelbrot generators here asking for advice on making them faster, and I always recommend that they implement it on the GPU. Glad to see someone ...
user1118321's user avatar
  • 11.8k
7 votes
Accepted

Drawing dragon curves using Turtle graphics

Whitespace There should be a blank line between two method definitions. Also, some blank lines inside of the methods would give the code room to breathe, and allow you to visually separate individual &...
Jörg W Mittag's user avatar
7 votes

Plotting the Mandelbrot set efficiently

First impression is that the code is very dense. Reading would be a bit easier if you give the code room to breathe! Variable names in particular are short and uninformative (why do we have both <...
Toby Speight's user avatar
  • 81.8k
7 votes

Plotting the Mandelbrot set efficiently

General Observations I would not want to maintain this code or delegate this code to someone else to maintain. It is difficult to read and even more difficult to modify. Before trying to optimize the ...
pacmaninbw's user avatar
  • 24.9k
6 votes

Mandelbrot Fractal Drawer in C++

I see a number of things that may help you improve your code. Fix the bugs There are a couple of bugs in this program that should be fixed. First, the include guard in ...
Edward's user avatar
  • 66.6k
6 votes
Accepted

Generating Julia set

1. Review Some of the variable names could be improved: complex_plane is an array of \$z\$ values for each pixel in the image, so naming it ...
Gareth Rees's user avatar
  • 49.7k
6 votes
Accepted

Sierpiński's carpet fractal animation for teaching Python 3

Algorithm You can simplify the code and make it run faster if you construct the next-level carpet by continuing to work on the previous image (punching more holes in it), rather than starting with a ...
200_success's user avatar
6 votes

Increase performance creating Mandelbrot set in python

I'm not a python expert. I am pretty good with Mandlebrot generation (I've spent a lot of time on my custom Julia Set generator.) So I'll say this: optimize the heck out of stuff that will be ...
Kevin's user avatar
  • 336
6 votes
Accepted

Mandelbrot Set image generator in Rust

Couple of things I noticed: infinity_limit is constant for a given call to draw_area. Its only use is in ...
ChrisWue's user avatar
  • 20.4k
5 votes
Accepted

Mandelbrot Fractal Drawer in C++

This is a lot of code to cover, so I'll touch on the highlights. Overall the code is pretty straightforward and easy to read. I like that you used std::complex ...
user1118321's user avatar
  • 11.8k
5 votes

Chaos with Newton’s method

I hope you don't mind that I mostly copy&pasted my last answer to one of your questions, but basically, the points are mostly still the same. Whitespace There should be a blank line between two ...
Jörg W Mittag's user avatar
5 votes

Newton Fractal writen in C

Suspected subtle bug Try ...
chux's user avatar
  • 33.7k
5 votes

Plotting the Mandelbrot set efficiently

Since you want to do this efficiently - measure how long each OpenGL call takes. I wouldn't be surprised at all if that takes most of the time. Find out how to store various pixel values int a buffer ...
gnasher729's user avatar
  • 2,664
4 votes

Optimizing rendering with a lot of transformations and save/restore

I see this was the second javascript question you posted here and it is unfortunate that there have been no responses in the nearly four years since then. Perhaps you have learned a few things about ...
Sᴀᴍ Onᴇᴌᴀ's user avatar
4 votes
Accepted

Drawing fractals with Turtle

Couple performance and code style related notes: if you can define something outside/before a loop, do so. For example, there is no need to define linSys inside ...
alecxe's user avatar
  • 17.3k
4 votes

Drawing fractals with Turtle

For each shape, you have this kind of code to generate the movement "recipe": ...
janos's user avatar
  • 112k
4 votes

Interactive Mandelbrot Set generator

private Color[] colorSet; in public class ImageSlicePainter is an instance property, and the (256) colors are computed each ...
Martin R's user avatar
  • 23.5k
4 votes

Sierpiński's carpet fractal animation for teaching Python 3

I only have a few small suggestions: I like to have "tweaks" that I may want to change later at the top of my file. This makes it easier to quickly alter them when playing around without needing to ...
Carcigenicate's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible