1

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 being grouped together and sometimes create a weird strippy effect.

Messed Up Mandelbrot Zoom

Above is a picture of the issue (this is supposed to be in 4k).

Here are some links of other, less deep zooms (they have to be google links because they are too big): https://photos.app.goo.gl/c2hUHM7sSmvKxYbQ6 https://photos.app.goo.gl/nG2cgjJ7vn7XYf8KA https://photos.app.goo.gl/TtpF1Q6hjojHSn747

The issue is amplified as you zoom further and further in until only one color appears. The Mandelbrot set works

When we made the program, we tried to use the shading shown in the images on the Wikipedia article about the Mandelbrot set. The only info we could find out about it was that it was a cubic interpolated coloring scheme which gave it a smooth transition look. We spent a long time trying to figure it out but eventually, we did. The thing that made it hard was the fact that the curve could not exceed the RGB limits of 255, so the curves also had to be monotonic and also the only thing we could really find to help were two Wikipedia articles about this type of interpolation. We created the code from scratch and once we figured out how to cade the cubic interpolation, I worked on getting the perfect colors to use with it. Attached is the .jar and our code (it's very messy, sorry were amateurs):

code: https://drive.google.com/file/d/186o_lkvUQ7wux5y-9qu8I4VSC3nV25xw/view?usp=sharing

executable file (if you want): https://drive.google.com/file/d/1Z12XI-wJCJmI9x0_dXfA3pcj5CNay3K-/view?usp=sharing (you must hit enter after you enter each value)

I am hoping someone can help me troubleshoot the issue. Or let me know if they have experienced this issue as well.

1 Answers1

0

First, it's not obvious that the image you provided is wrong. The nature of Mandelbrot is that new details spring up as the zoom increases.

If there is a problem, it's almost certainly numerical stability. Doubles have 53 bits of precision. Your code is pretty unreadable, so I'm not trying to read it. But if you're doing things like subtracting the upper window boundary from the lower when the window is centered away from the origin, say at (-1,0), but with tiny size... You mentioned ~10^-14. Then the subtraction result throws away significance of about 10^14. That's around 47 bits. What's left is only 6 bits, so the precision of computation has dropped to 1/64. That's not very precise. It gets worse farther from the origin and for smaller differences.

Consider reading What Every Computer Scientist Should Know About Floating-Point Arithmetic. It will let you see your code in a new light. Math translated directly to floating point computation often explodes. This paper explains the basis for avoiding the pain.

A less intimidating read is here.

One more note: I did scan your code briefly. Please check out Horner's Rule to improve both precision and speed.

Gene
  • 46,253
  • 4
  • 58
  • 96