Effect of floating point precision on Mandelbrot calculations

  • 5 Replies

0 Members and 1 Guest are viewing this topic.

Offline timhume

  • *
  • Fractal Freshman
  • *
  • Posts: 4
    • Spaceport Weather
« on: February 26, 2018, 11:47:03 AM »

I was wondering what effect the floating point precision has on Mandelbrot calculations. We often do thousands or tens of thousands of iterations, yet errors in the floating point arithmetic don't seem to accumulate or blow out, and we get beautiful pictures coming out at the end. So I wrote a quick piece of code which did 1000 iterations at a random point in the set using 32 bit reals, and another 1000 using 128 bit reals at the same random point.  I then computed the absolute value of the difference between the 32 and 128 bit calculations. Here is the code (in Fortran):

program error
    use, intrinsic  :: iso_fortran_env
    implicit none

    complex(kind=real128)   :: c128 = (-0.1, 0.5)
    complex(kind=real128)   :: z128 = (0.0, 0.0)
    complex(kind=real32)    :: c32 = (-0.1, 0.5)
    complex(kind=real32)    :: z32 = (0.0, 0.0)
    complex(kind=real128)   :: diff
    integer(kind=int32)     :: n
    do n=1, 1000
        z32 = z32**2 + c32
        z128 = z128**2 + c128
        diff = z128 - cmplx(z32, kind=real128)
        print *, n, z128, diff, abs(diff)
    end do
end program

And a plot of the difference is attached. I tried a few points, and always seemed to get the same sort of thing. For the first hundred or so iterations the difference between the 32 and 128 bit calculations would go up and down, and then it would flatten out at some value, or have small oscillations about some value.

Has anyone investigated this? I guess that it would be possible to choose a point right near the edge of the set where either the 32 bit or 128 bit calculations would diverge while the other remained constrained. I think this is a kind of important question - if we do a million iterations to plot a picture, how can we trust the picture is correct and not influenced by some floating point arithmetic errors?



Linkback: https://fractalforums.org/fractal-mathematics-and-new-theories/28/effect-of-floating-point-precision-on-mandelbrot-calculations/939/

Offline lkmitch

  • *
  • Fractal Fanatic
  • ***
  • Posts: 36
« Reply #2 on: February 26, 2018, 05:16:33 PM »
Hi Tim,

We have confidence in our Mandelbrot pictures because the underlying math is usually stable. That's evidenced in your plot--even with one-fourth of the precision (32 bit vs 128 bit), the differences settle down. That will happen with any (well-behaved) programming system for orbits of points that are either inside of the Mandelbrot set (often rendered black) or outside (often rendered in color). The orbits of the interior points will settle down into a loop and those of the outside points will "settle down" to a divergence to infinity. The only real questionable points lie on the exact boundary. The boundary is infinitely thin, so except in a few spots, it's not easy to tell if you're inside or outside. Then, the calculations can fluctuate and different implementations give you different results. In some programs (like Ultra Fractal), this is exploited by guessing the nature of the point to speed up the calculation. If you use this type of feature, you can see that it breaks down as you approach the boundary.


Offline Adam Majewski

  • *
  • Fractal Furball
  • ***
  • Posts: 254
« Reply #4 on: February 26, 2018, 06:05:51 PM »
The only real questionable points lie on the exact boundary.

right !

In some programs (like Ultra Fractal), this is exploited by guessing the nature of the point to speed up the calculation.

Can you expand it ?

In case of Julia set ( dynamical plane ) it is desrcibed :
"approximating a ?long? iteration of z in the neighborhood of
a parabolic point fast."



Offline claude

  • *
  • 3f
  • ******
  • Posts: 1378
    • mathr.co.uk
« Reply #5 on: February 27, 2018, 01:35:08 AM »
The only real questionable points lie on the exact boundary.

Indeed, which is why I asked: https://math.stackexchange.com/questions/2322608/dyadic-rational-boundary-points-of-the-mandelbrot-set (there are plenty of other boundary points, but the only ones that cause trouble are the ones exactly representable in binary floating point - assuming no one in practice is iterating with arbitrary precision rational numbers or constructive reals or whatever else...)

(Fixed precision) floating point performance: Best datatype?

Started by marcm200 on Programming

18 Replies
Last post January 30, 2020, 08:11:23 PM
by marcm200
bounded floating-point format

Started by quaz0r on Off Topic

0 Replies
Last post January 18, 2018, 07:10:30 PM
by quaz0r
The Dragon's Crown - Point Orbit Trap Mandelbrot Zoom

Started by saka on Fractal movie gallery

2 Replies
Last post May 19, 2018, 11:29:12 AM
by saka
The floating Gardens of Borduria

Started by Frakkie on Fractal Image Gallery

0 Replies
Last post November 19, 2018, 06:41:01 PM
by Frakkie
Moire effect

Started by alber on Fractal Mathematics And New Theories

4 Replies
Last post February 22, 2019, 05:22:50 PM
by claude