Effect of floating point precision on Mandelbrot calculations

  • 5 Replies
  • 178 Views

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 »
Hi,

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?

Cheers,

Tim



Offline lkmitch

  • *
  • Fractal Freshman
  • *
  • Posts: 8
« 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.

Kerry


Offline Adam Majewski

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

right !

Quote
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 :
https://arxiv.org/abs/math/0505036
"approximating a ?long? iteration of z in the neighborhood of
a parabolic point fast."


HTH


 

Offline claude

  • *
  • Fractal Frankfurter
  • *
  • Posts: 613
    • 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...)


xx
bounded floating-point format

Started by quaz0r on Off Topic

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

Started by saka on Fractal movie gallery

2 Replies
135 Views
Last post May 19, 2018, 11:29:12 AM
by saka
xx
OpenCL double precision in release 2.2.13

Started by piotrv on Mandelbulber

11 Replies
293 Views
Last post April 16, 2018, 02:58:42 PM
by mclarekin
xx
"Lost Quantum Effect"

Started by cricke49 on Fractal Image Gallery

0 Replies
48 Views
Last post March 01, 2018, 05:23:06 PM
by cricke49
xx
"The Tangier Effect"

Started by cricke49 on Fractal Image Gallery

0 Replies
38 Views
Last post March 26, 2018, 08:31:09 AM
by cricke49