Logo by Trifox - 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: Check out the originating "3d Mandelbulb" thread here
 
*
Welcome, Guest. Please login or register. October 03, 2018, 09:51:24 AM


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]   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! Newton fractal smooth shading  (Read 1303 times)
0 Members and 1 Guest are viewing this topic.
Softology
Conqueror
*******
Posts: 120


« on: January 17, 2011, 05:45:40 AM »

Hello All,

I have been getting back into root finding fractals (Newton, Halley and Schroder methods of root finding to generate fractals).

Getting the root finding code to work was realtively easy.  Got to love Wolfram Alpha that can spit out a second derivative within a blink of an eye.

My issue is trying to get a formula for getting smooth color shading (ie no visible banding).

Can anyone assist?

I have tried the formulas listed here http://www.hiddendimension.com/FractalMath/Convergent_Fractals_Main.html and think I have them correct code wise but get blank images and when debugging the "Sn" value it always ends up as a "NAN" value, so I must be doing something wrong.

Does anyone have a snippet of code that works for the root finding fractals?

I have the z and lastz and magz values, but I need a good formula to get the smooth color.  The closest I got was ....
floatval:=ln(cabs(cdiv(cone,csub(lastz,z))))/5.7456
floatval:=1-abs(floatval-trunc(floatval))
Which gets a value between 0 and 1 to smooth out the iterations, but this never worked 100% correctly and I have no idea why the /5.7456 was necessary.  It came from trial and error and is very picky with iteration counts and the formulas being used.

Any tips would be very appreciated.

Thanks,
Jason.
Logged
knighty
Fractal Iambus
***
Posts: 819


« Reply #1 on: January 17, 2011, 02:55:15 PM »

Quote
I have tried the formulas listed here http://www.hiddendimension.com/FractalMath/Convergent_Fractals_Main.html and think I have them correct code wise but get blank images and when debugging the "Sn" value it always ends up as a "NAN" value, so I must be doing something wrong.
Maybe the problem comes from exp() function when using relatively big argument (say, its absolute value > 10000). here is an evaldraw implementation that seems to work. smiley

Code:
(x,y){
   newton(x,y)
}
enum{mi=100};//max iterations
newton(x,y){
   delta=100;i=mi;s=0;
   while(delta>10^-4 && i>0){
      //denominator
      ir=1/(3*(x*x+y*y)^2);
      //z_n^3
      x1=2*(x^3-3*x*y^2)+1;
      y1=2*(3*x^2*y-y^3);
      //conjugate of z_n^2
      x2=x*x-y*y;
      y2=-2*x*y;
      //z_(n+1)
      x3=x1*x2-y1*y2;x3*=ir;
      y3=x1*y2+x2*y1;y3*=ir;
      delta=sqrt((x-x3)^2+(y-y3)^2);
      //if delta<10^-4 exp() behave badly
      if(delta>10^-4) s+=exp(-1/delta);
      x=x3;y=y3;
      i-=1;
   }
   return s*0.1/3;//i*1/mi
}
Logged
Softology
Conqueror
*******
Posts: 120


« Reply #2 on: January 18, 2011, 03:40:56 AM »

Thanks for the code.  It had the same issues.  Must be something with my calculation code that differs.

Anyway I found another method for newton smooth coloring within the source code here http://www.chiark.greenend.org.uk/~sgtatham/newton/ that did the trick.  It uses a few log calcs after the iteration loop, so it does not need the constant summing during each iteration.

Jason.
Logged
David Makin
Global Moderator
Fractal Senior
******
Posts: 2286



Makin' Magic Fractals
WWW
« Reply #3 on: January 18, 2011, 04:35:26 AM »

The standard Vepstas smoothing method can be adapted for areas of point convergence quite easily including using the *actual* convergence at bailout rather than an estimated value, for the fraction use:

If bailout is tested for using |#z-zold| against @smallbail then given:

  float clp = log(-0.5*log(@smallbail))

Then use either:

    float  f = real( (clp-log(-0.5*log(|#z-zold|))) / log(log(|#z-zold|)/log(|zold-zolder|)) )

Or:

  float f = real( (clp-log(-0.5*log(|#z-@fixedval|))) / log(log(|#z-@fixedval|)/log(|zold-@fixedval|)) )

Where |x+i*y| is x^2+y^2 and in the second case @fixedval is a known point attractor, #z is the final value of z, zold the penultimate and zolder the one before that.

« Last Edit: January 18, 2011, 04:38:43 AM by David Makin » Logged

The meaning and purpose of life is to give life purpose and meaning.

http://www.fractalgallery.co.uk/
"Makin' Magic Music" on Jango
Softology
Conqueror
*******
Posts: 120


« Reply #4 on: January 31, 2011, 12:36:46 AM »

Thanks David.  After I combined your method with the method from the website I linked to I finally have images with no banding or artifcats across many types of formulas and root-finding methods.

In case this may help someone else in the future, the final code was;

                                dist0:=cdistsquared(lastz2,lastz);
                                dist1:=cdistsquared(lastz,z);
                                logt:=ln(tolerance);
                                log0:=ln(dist0);
                                log1:=ln(dist1);
                                floatval:=(logt-log0)/(log1-log0);

cdistsquared returns the distance between the points without the sqrt calc.
floatval is the fractional iteration count you use to smooth the colors

Jason.
Logged
Pages: [1]   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Smooth Shading Mandelbrot plugin Fractal eXtreme panzerboy 6 2377 Last post February 20, 2013, 04:26:37 PM
by panzerboy
Livewire - Burning Ship Fractal Zoom - smooth shading Movies Showcase (Rate My Movie) thepookster 4 1284 Last post April 01, 2013, 02:37:39 AM
by thepookster
Newton Fractal Smoothing Programming fodinabor 6 1408 Last post April 24, 2015, 04:38:04 AM
by Pauldelbrot
Newton fractal roots in 3D space or arbitary dimension Help & Support misterstarshine 0 213 Last post November 15, 2015, 01:59:11 PM
by misterstarshine
Matlab: Newton-Fractal Programming Spalding 7 1241 Last post September 09, 2016, 05:04:42 PM
by superheal

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.153 seconds with 26 queries. (Pretty URLs adds 0.01s, 2q)