Title: About precision of doubles Post by: louwin on November 21, 2016, 12:13:14 AM I'm a retired programmer (assemblers, COBOL and BASIC mainly). A total newbie in C++.
Rather than use one of the few excellent programs available I'd like to write my own 88) "double" variables SHOULD go to E308 so could someone please explain to me why I can only "zoom" to about 1.0E13 before it gets all "blocky"? I even tried "long double" and that only went to about 2.0E18 :'( My research seems to suggest this is normal but I'd like to know why? This is the code I'm using.... Code: int MAXI, maxIterations; For simplicity I editted out extraneous details like writing bitmaps etc ;) Title: Re: About precision of doubles Post by: quaz0r on November 21, 2016, 12:26:14 AM because unfortunately the mandelbrot equation is limited by the mantissa precision, not the exponent. :sad1: on the other hand, the perturbation mandelbrot equation, should you choose to go down that rabbit hole, is mostly limited by the exponent, which is most fortunate indeed. :D
Title: Re: About precision of doubles Post by: louwin on November 21, 2016, 02:43:32 AM Thanks for your response :-\
But bear with me (NEWBIE!) but Doesn't the mantissa just hold some digits and the exponent the multiplier or divider? If the mantissa "fills up" don't you just add or subtract 1 from the exponent and carry on? :crazyeyes: :confused: Please explain (in newbie terms) or please provide me a link to the explanation :tongue1: :'( :sad1: Title: Re: About precision of doubles Post by: quaz0r on November 21, 2016, 02:58:31 AM well the problem is that C requires more and more mantissa as you go deeper. basically when you are at 10N C needs around N digits of mantissa. if you were just doing Z2 maybe it would only be limited by the exponent, but since you add C each iteration you are limited by C needing to have all its digits.
Title: Re: About precision of doubles Post by: ciric50 on November 21, 2016, 02:22:33 PM Maybe this will help.
When you're zoomed out, let's say you're looking at values on the x axis something like -2 to +2, so the the range is 2 - (-2) = 4. As you zoom in at some point, the edge values on the x axis get closer and closer together, say 1.00002 to 1.00003, for a range of 1.00003 - 1.00002 = 0.00001. The difference in values is very small. When you zoom in to range values that are very close together, the difference can't be done accurately without high precision. For example 1.00000000000000002 to 1.00000000000000003 in double precision won't work, because the difference between them is less than the smallest number that double precision can represent. Intuitively it seems like double precision should be more than enough for most calculations (and it is) but in the world of fractals you bump into the precision limitation fairly quickly as you zoom in. There is a pdf around somewhere with the title "Superfractalthing Maths" where the author explains a technique he found where double precision can be used for these kinds of calculations. Title: Re: About precision of doubles Post by: louwin on November 21, 2016, 11:31:28 PM Thanks for that VERY informative response ciric50 :D
I suppose that also explains why going to "long double" only increased the zoom range by about 100,000.... :o I was expecting, like, another 30 zeroes? But, as quaz0r suggested, going from 64 bits to 80 bits the mantissa only increases by a few bits :sad1: Now to research VS215 and the Intel Compiler for Quad precision. Putting off the move to pertubation and arbitary precision :-\ :hmh: Title: Re: About precision of doubles Post by: quaz0r on November 22, 2016, 02:15:36 AM i dont know if using the builtin float128 or float256 types is even worth it compared to just using mpfr. gmp/mpfr is written to be as efficient as possible, including the utilization of explicit vectorization, which could very well make it the best choice compared to some cheap softfloat implementation.
there is a handy c++ wrapper for mpfr called mpreal: https://bitbucket.org/advanpix/mpreal/downloads?tab=tags there is also an old thing called the qd library which gives some sort of supposedly efficient implementation of double-double and quad-double. internally it is implemented as multiple doubles. Title: Re: About precision of doubles Post by: louwin on November 23, 2016, 01:32:21 PM Thanks for the mpreal.h suggestion quaz0r. It DOES look interesting.... Have you actually tried it with VS2015 or the like?
I get errors with the embedded #include mpfr.h within mpreal.... commenting it out goes a bit further //#include <mpfr.h> But then I get lots of C:UsersLouisDocumentsVisual Studio 2015ProjectsProjTechProjTech../mpreal.h(365): error : identifier "mp_rnd_t" is undefined 1> friend const mpreal tan(const mpreal& v, mp_rnd_t rnd_mode); 1> ^ errors? Nobody else seems to have complained so it could just be me (newbie!?).... Thanks again.... Title: Re: About precision of doubles Post by: Adam Majewski on November 23, 2016, 06:13:30 PM You can also try mpc :
https://pl.wikibooks.org/wiki/Programowanie_w_systemie_UNIX/MPC if you want to try linux you can here find info about installations https://pl.wikibooks.org/wiki/Programowanie_w_systemie_UNIX/MPFR https://pl.wikibooks.org/wiki/Programowanie_w_systemie_UNIX/GMP and here are about perturbation https://en.wikibooks.org/wiki/Fractals/Iterations_in_the_complex_plane/Mandelbrot_set#Perturbation_theory HTH Adam Title: Re: About precision of doubles Post by: quaz0r on November 23, 2016, 07:25:57 PM hmm well mpreal.h is a c++ wrapper for mpfr.h so you need mpfr to be available and working :) i know people use mpreal with microsoft compiler but im not sure what the particulars are. |