Logo by Madman - Contribute your own Logo!

END OF AN ERA, FRACTALFORUMS.COM IS CONTINUED ON FRACTALFORUMS.ORG

it was a great time but no longer maintainable by c.Kleinhuis contact him for any data retrieval,
thanks and see you perhaps in 10 years again

this forum will stay online for reference
News: Visit us on facebook
 
*
Welcome, Guest. Please login or register. March 28, 2024, 03:31:10 PM


Login with username, password and session length


The All New FractalForums is now in Public Beta Testing! Visit FractalForums.org and check it out!


Pages: [1] 2   Go Down
  Print  
Share this topic on DiggShare this topic on FacebookShare this topic on GoogleShare this topic on RedditShare this topic on StumbleUponShare this topic on Twitter
Author Topic: Help about implementing the perturbation theory  (Read 2125 times)
0 Members and 1 Guest are viewing this topic.
CFJH
Alien
***
Posts: 31


« on: July 02, 2013, 08:35:52 PM »

Hello,

I'm reading very interested the topic about sft with the significant speedups by using the perturbation theory.

http://www.fractalforums.com/announcements-and-news/superfractalthing-arbitrary-precision-mandelbrot-set-rendering-in-java/

Now I want to implement this in my own plain fractal generator written in C. But I havn't really understand how the perturbation theory is working.
Reviewing the java-code of sft is difficult to me because I'm not a java developer and some used structures are unknown to me.

Can someone explain me, how is it working or give a abstract (programming language indepent) code fragment ?

Jürgen
Logged

Kalles Fraktaler
Fractal Senior
******
Posts: 1458



kallesfraktaler
WWW
« Reply #1 on: July 12, 2013, 01:16:49 PM »

I recommend that you take the time and read these two threads through and the linked pdf:
http://www.fractalforums.com/announcements-and-news/superfractalthing-arbitrary-precision-mandelbrot-set-rendering-in-java/
http://www.fractalforums.com/announcements-and-news/kalles-fraktaler-2/

Even if the Java code might be difficult to digest for a C/C++ programmer all info needed is there.
Logged

Want to create DEEP Mandelbrot fractals 100 times faster than the commercial programs, for FREE? One hour or one minute? Three months or one day? Try Kalles Fraktaler http://www.chillheimer.de/kallesfraktaler
http://www.facebook.com/kallesfraktaler
Gluecker
Forums Newbie
*
Posts: 9


« Reply #2 on: July 13, 2013, 01:07:28 AM »

the most significant speed boost will come from equation 1 (see sft_maths.pdf from the SuperFractalThing thread). Since the java code provided has additional tweaks, its not really easy to fully understand.
I will try to explain what I got so far:

- calculate one point (the reference X) near or inside your field of view at full precision and store the real and imaginary part of every calculation at lower precision. This point should be inside the M-set, or at least very close to it.

- compute the initial difference \bigtriangleup_0 between the point Y you want to render and the reference (using a lower precision)

- iterate over eq1 using \bigtriangleup_0 and the stored values for X. Its important to start with the correct index for X. (Eg. I stored the starting coordinates of X as X[0], my first calculation is then X[1], so my iteration counter is initially set to 1)

- as usual the iteration ends when the iteration counter hits the iteration limit. You also want to check if the distance \mid\bigtriangleup_n\mid gets bigger than a certain limit, since the assumption that "all the numbers are 'small'" was made. Re(\bigtriangleup_n)^2+Im(\bigtriangleup_n)^2<1E-5 works fine for me, but I am not done testing yet.

- when \mid\bigtriangleup_n\mid gets too big, we can calculate back to the current value of Y_n = \bigtriangleup_n + X_n and go on with the standart mandelbrot calculation. This also seems to work with lower precision, but again, not sure about that.

hope that helps.
cheers
« Last Edit: July 13, 2013, 01:11:51 AM by Gluecker » Logged
CFJH
Alien
***
Posts: 31


« Reply #3 on: August 07, 2013, 11:32:00 PM »

Hallo
in the past days I had a litte time to implememt something about the pertubation theory.
Now I've an (nearly) working function which is currently using the equation (1) only.

But my problem is the bailout-value, where the interartion exits. The standard für a mandelbrot is 4 but I've to use a value 64 to get an unbroken image in all cases.

the attached Images shows
test1s : calculated with the classical method
test2s : image with bailout of 64
test3s : broken image with standard bailout of 4


Code:
int tMandel::CalcPointPertub(int ix, int iy) {
double D0r,D0i; // Delta 0
double DNr,DNi; // Delta n
double Xr,Xi;   // aktuelles Xn aus dem Array
double Yr,Yi;   // berechneter Yn-Wert
double Ti,Tr;   // temporär
unsigned long pIter;
int Inside=1;

  mpf_set_d(a,ix-0.5*SizeX);
  mpf_mul(a,dx,a);
  D0r=mpf_get_d(a);

  mpf_set_d(a,iy-0.5*SizeY);
  mpf_mul(a,dy,a);
  D0i=mpf_get_d(a);
  // Reference point in the center
  // ∆n+1 = 2Xn ∆n + ∆n^2 + ∆0
  DNr=D0r;
  DNi=D0i;
  for (pIter=0;pIter<MaxIter;pIter++) {
    Xr=arx[pIter]; // reference values real part
    Xi=ary[pIter]; // reference values imaginary part
    
    // Calculation 2Xn ∆n
    Tr = 2.0*(Xr*DNr - Xi*DNi);
    Ti = 2.0*(Xr*DNi + Xi*DNr);
    // + ∆n^2
    Tr = Tr + (DNr*DNr - DNi*DNi);
    Ti = Ti + 2.0*DNr*DNi;
    // + ∆0
    Tr += D0r;
    Ti += D0i;
    
    DNr = Tr;
    DNi = Ti;
    
    // ∆n = Yn − Xn  -> Yn = ∆n - Xn
    Yr = DNr - Xr;
    Yi = DNi - Xi;
    
    //Abort
    if ((Yr*Yr+Yi*Yi)>64.0) {  // <----- problem !!
      Inside=0;
      break;
    }
    if (Aborted) {
      Calculation=FALSE;
      return -1;
    }
  }
  if (Inside)
    return 0;
  else
    return pIter;
}

Why is the image broken with standard bailout value ?
I can't find where is the problem in my code. Can somebody give me a hint ?


* base1s.jpg (18.88 KB, 640x480 - viewed 83 times.)

* base2s.jpg (22.51 KB, 640x480 - viewed 75 times.)

* base3s.jpg (19.46 KB, 640x480 - viewed 75 times.)
« Last Edit: August 07, 2013, 11:39:09 PM by CFJH » Logged

knighty
Fractal Iambus
***
Posts: 819


« Reply #4 on: August 08, 2013, 03:36:28 AM »

// ∆n = Yn − Xn  -> Yn = Xn + ∆n
Logged
Gluecker
Forums Newbie
*
Posts: 9


« Reply #5 on: August 10, 2013, 01:41:33 AM »

yea, Y = X+delta.
other than that, higher bailouts dont hurt since the assumption "|Z|> 2 escapes" also implies |Z|> 8 does.
Logged
knighty
Fractal Iambus
***
Posts: 819


« Reply #6 on: August 10, 2013, 01:56:25 PM »

Any zooms?  cheesy
Logged
CFJH
Alien
***
Posts: 31


« Reply #7 on: August 10, 2013, 06:38:22 PM »

Thanks for the hint,

but this solves the problem not completly. Now I can decrease the bailout value to 16 (instrad of 64) but the rendered image still looks different against an image rendered with standard method. A lower value as 16 produces a clipped image.
Is this normal or have I another bug ?

Jürgen
Logged

knighty
Fractal Iambus
***
Posts: 819


« Reply #8 on: August 10, 2013, 06:58:48 PM »

Don't know. If it's approximately the same as the 3rd picture then I would say there still is an error in Yn calculation.
Logged
Kalles Fraktaler
Fractal Senior
******
Posts: 1458



kallesfraktaler
WWW
« Reply #9 on: August 11, 2013, 01:08:52 PM »

Thanks for the hint,

but this solves the problem not completly. Now I can decrease the bailout value to 16 (instrad of 64) but the rendered image still looks different against an image rendered with standard method. A lower value as 16 produces a clipped image.
Is this normal or have I another bug ?

Jürgen
No it is NOT normal and yes you have a bug...
Sorry but I cannot find any error in you code either.
Here is my bailout validation, which looks very much like yours:
Code:
Di=D0i;
Dr=D0r;
for(antal=0;antal<m_nMaxIter;antal++){
Dnr = (m_db_dxr[antal]*Dr - m_db_dxi[antal]*Di)*2 + Dr*Dr - Di*Di + D0r;
Dni = (m_db_dxr[antal]*Di + m_db_dxi[antal]*Dr + Dr*Di)*2 + D0i;
yr=m_db_dxr[antal] + Dr;
yi=m_db_dxi[antal] + Di;

Di = Dni;
Dr = Dnr;

if(yr*yr+yi*yi > 4)
break;
}

Are you trying to do some coloring with the value of Yn? Because I have noticed that the value of Yn is unstable. It is accurate for calculating the bailout iteration, but it is not usable to do further coloring with the value since it get too far away for some locations.
« Last Edit: August 11, 2013, 10:48:32 PM by Kalles Fraktaler, Reason: NOT » Logged

Want to create DEEP Mandelbrot fractals 100 times faster than the commercial programs, for FREE? One hour or one minute? Three months or one day? Try Kalles Fraktaler http://www.chillheimer.de/kallesfraktaler
http://www.facebook.com/kallesfraktaler
CFJH
Alien
***
Posts: 31


« Reply #10 on: August 12, 2013, 11:39:58 PM »

Hello,
now I could find my problem in the calculation  smiley

My mistake was, that I compute the Yn values one step too late

correct:
Code:
      Tr = 2.0*Xr*DNr - 2.0*Xi*DNi +     DNr*DNr - DNi*DNi + D0r;
      Ti = 2.0*Xr*DNi + 2.0*Xi*DNr + 2.0*DNr*DNi           + D0i;   
      Yr=DNr+Xr;
      Yi=DNi+Xi;
      DNr = Tr;
      DNi = Ti;

wrong:
Code:
      Tr = 2.0*Xr*DNr - 2.0*Xi*DNi +     DNr*DNr - DNi*DNi + D0r;
      Ti = 2.0*Xr*DNi + 2.0*Xi*DNr + 2.0*DNr*DNi           + D0i;   
      DNr = Tr;
      DNi = Ti;
      Yr=DNr+Xr;
      Yi=DNi+Xi;

Thanks to all for the help!

Jürgen
Logged

laser blaster
Iterator
*
Posts: 178


« Reply #11 on: August 15, 2013, 06:59:49 PM »

Wow, this perturbation theory looks brilliant! I'm still struggling to wrap my head around the math, but if I understand it correctly, it should enable us to only have to iterate one point, store it's values at each iteration, and then discretely solve for the values of all other points in that area, without having to iterate them. That's huge! Even better, it seems like it could be applied to gpu rendering. I might be misinterpreting it, though.
Logged
cKleinhuis
Administrator
Fractal Senior
*******
Posts: 7044


formerly known as 'Trifox'


WWW
« Reply #12 on: August 15, 2013, 07:13:18 PM »

You still need to iterate, but single precision is sufficient then
Logged

---

divide and conquer - iterate and rule - chaos is No random!
Kalles Fraktaler
Fractal Senior
******
Posts: 1458



kallesfraktaler
WWW
« Reply #13 on: August 15, 2013, 08:26:01 PM »

You still need to iterate, but single precision is sufficient then
No single precision is not sufficient, at least I was not able to succeed with that
Logged

Want to create DEEP Mandelbrot fractals 100 times faster than the commercial programs, for FREE? One hour or one minute? Three months or one day? Try Kalles Fraktaler http://www.chillheimer.de/kallesfraktaler
http://www.facebook.com/kallesfraktaler
Gluecker
Forums Newbie
*
Posts: 9


« Reply #14 on: August 17, 2013, 01:28:16 AM »

At a certain magnification delta gets too small (if the reference is near the screen center) to be calculated with single precision (minValue for float: 1.18 × 10^−38).
One could try to find good references further away, but thats not trivial and I guess there are also other limits...

Logged
Pages: [1] 2   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Bud Perturbation UltraFractal Gallery bib 0 1011 Last post June 02, 2009, 09:58:38 PM
by bib
The Mandelbrot Set. Perturbation Theory. UltraFractal SeryZone 0 5607 Last post October 14, 2014, 07:54:14 PM
by SeryZone
Anyone thought of implementing Perturbation on Android? Smartphones / Mobile Devices simon.snake 0 2680 Last post August 29, 2015, 10:38:30 PM
by simon.snake
Implementing MixPinski Sierpinski Gasket « 1 2 ... 8 9 » mclarekin 124 18893 Last post January 14, 2017, 12:24:58 PM
by hgjf2
Implementing ABoxModKaliEiffie Amazing Box, Amazing Surf and variations « 1 2 3 » mclarekin 30 10422 Last post November 27, 2016, 11:52:55 AM
by Sabine

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.211 seconds with 24 queries. (Pretty URLs adds 0.024s, 2q)