Fractalforums
Fractal Software => Programming => Topic started by: Adam Majewski on April 12, 2020, 01:22:23 PM

HI
I have made image of rational map:
\( f(z) = \frac{z^2}{z^21} \)
full code : https://commons.wikimedia.org/wiki/File:Reversed_Basilica_Julia_set_LCM.png
It works for escape time but not for distance stimation ( DEM/J)
My derivative is :
\( \frac{2 z}{z^21}  \frac{2 z^3}{(z^21)^2} \)
I compute it using c function :
unsigned char ComputeColorOfDEMJ(complex double z){
// https://en.wikibooks.org/wiki/Fractals/Iterations_in_the_complex_plane/Julia_set#DEM.2FJ
int nMax = iterMax;
complex double dz = 1.0; // is first derivative with respect to z.
double distance;
double cabsz;
complex double z2;
complex double z2m1;
complex double t;
int n;
for (n=0; n < nMax; n++){ //forward iteration
cabsz = cabs(z);
if (cabsz > 1e60  cabs(dz)> 1e60) break; // big values
if (cabsz< PixelWidth) return iColorOfInterior; // falls into finite attractor = interior
z2 = z*z;
z2m1 = z2  1.0;
t = (2*z)/z2m1  (2*z2*z)/(z2m1 * z2m1);
dz = t * dz; // (2*z)/(z^21)(2*z^3)/(z^21)^2 = (2*z)/z2m1  (2*z2*z)/(z2m1 * z2m1)
z = z2/(z2 +c ); /* forward iteration : complex quadratic polynomial */
}
distance = 2.0 * cabsz* log(cabsz)/ cabs(dz);
if (distance <distanceMax) return iColorOfBoundary; // distanceMax = BoundaryWidth*PixelWidth;
// else
return iColorOfExterior;
}
I see exterior and interior but not the boundary
Below level curves of escape time ( 7.png) and dem ( 1.png)

I think what is happening is that interior detection is taking precedence over boundary detection. Instead, just flag the point as interior, then outside the loop, check the boundary first, then if interior return interior color, else return exterior color.
While your derivative is correct, it can be simplified to 2z/(z^{2}1)^{2} by multiplying out the numerator instead.

Thx for the answer. Both tips are very important.
First I would like to make code work .
unsigned char ComputeColorOfDEMJ(complex double z){
// https://en.wikibooks.org/wiki/Fractals/Iterations_in_the_complex_plane/Julia_set#DEM.2FJ
int nMax = iterMax;
complex double dz = 1.0; // is first derivative with respect to z.
double distance;
double cabsz;
complex double z2;
complex double z2m1;
complex double t;
int n;
for (n=0; n < nMax; n++){ //forward iteration
cabsz = cabs(z);
if (cabsz > 1e60  cabs(dz)> 1e60) break; // big values
//if (cabsz< PixelWidth) { break;} // falls into finite attractor = interior
z2 = z*z;
z2m1 = z2  1.0;
t = (2*z)/z2m1  (2*z2*z)/(z2m1 * z2m1);
dz = t * dz; // (2*z)/(z^21)(2*z^3)/(z^21)^2 = (2*z)/z2m1  (2*z2*z)/(z2m1 * z2m1)
z = z2/(z2 +c ); /* forward iteration : complex quadratic polynomial */
}
distance = 2.0 * cabsz* log(cabsz)/ cabs(dz);
if (distance <distanceMax) return iColorOfBoundary; // distanceMax = BoundaryWidth*PixelWidth;
// else
return iColorOfInterior;
}
I have modified it. Still not work
(:((

I missed that you are iterating z = z2/(z2 +c ). Shouldn't it be z2/z2m1 + c?
What should work is something like this (I don't use c or c++ so may not be correct):
boolean IsInterior;
...
if (cabsz< PixelWidth) IsInterior = true;
...
if (distance <distanceMax) return iColorOfBoundary;
if (IsInterior) return iColorOfInterior;
return iColorOfExterior;
As I generally combine DE and other methods into one procedure for iteration, the general hierarchy I use for checking after iteration is orbit traps, boundary, other. The other is classified by the iteration as interior/exterior/in set.

Mset (\( z^2/(z^21) +c(pixel)) \) is nice too.
Zoom rendered normally and with exponential map, both using cellular orbit trap.