## 15 Reputation

1 years, 325 days

## for loops and whatnot in 1D...

Hello Sir, Hope you are doing well I was woundering if would help me in that matter in which I can calculate the black points in basin of attraction as you suggested in the previous massage.

Thank you for your time and effort.

Kind regards

Malak

## @Carl Love  Thank you so so much s...

Thank you so so much sir I truly appreciate your time and efoort to help me thank you

## @MalakMMK  No actually have not ma...

No actually have not made it by myself I got help in maple prime I'm a complete begginner when it xomes to maple this why I'm trying to learn

but as I told you before when I tried implementing 8th order method it does not work on 1D input it just keep evaluating the code forever

this why I''m working with 2D to compare more method (black points wise)

## @Carl Love  Thamk you Sir for your...

Thamk you Sir for your great help,

I have a small problem when it comes to 1D input I can only work with simple 4th order method,

the 2D allows me it work with far more complicated method such as 8th and 16th orders

## @Carl Love I've changed it to 8...

I've changed it to 8 like him

## @Carl Love  It works perfectlu but...

It works perfectlu but accordiong to a the research paper in which this method is displayed , it says in z^4-2 at 8th iteration it supposed to have 1729 black pints while the code displays 3832

## @Carl Love Forgive me sir as I'...

Forgive me sir as I'm a little beginner in Maple,

I have tried both ways the "comma equal operaror" keeps making an error in the code

and the  numelems(BlackZ); is returning zero

## divergence point...

The divergence point are the black points in a basins of attraction graph, in which the method is not convergant

for example this is in 8th iteration of z^4-1 , it supposed to have 1729 black points at step 0.01

## The Codes...

Provided the code that I used to generate the images as the for loop method is proven to be easier and much faster than the prevous method my concern is only about the style.

King_iter_Ma.mw

King_iter_Ma2.mw

## Changing Colors...

Is it possible to use the same approach you did by using a for loop but,
getting a similar style to the first image because it is more explainable, this king at z^4-1, the black areas are very clear to identify and it has 4 colors, however, in the second image I'm Always getting 3 colors.

## The Code...

I tried doing it but the program keep running without any results.

Wei_method.mw

## @acer Hello, sorry for the delay,&n...

Hello, sorry for the delay,

This is what I'm trying to do:

I'm trying to compare multiple fourth-order method: including king's, and the one I'm currntly working on:

 > restart:

The following uses the Escape command from the IterativeMaps package.

It is reasonable fast (even with some relatively ineffient post-processing.

I have chosen to post-process the output data so that the coloring is
made according to the root to which the given x+y*I input point converges.

Optionally we can scale the saturation by the iteration count.

 > ee := z^3-1;
 (1)
 > ## For ee a polynomial we can compute all the roots. ## This is used to specify the colors, below. rts:=[fsolve(ee)]; ##rts:=[fsolve(ee,z,complex)]; evalf[1](rts); ## evalf[1](%);
 (2)
 > #(minr,maxr) := (min,max)(Re~(rts)): #(mini,maxi) := (min,max)(Im~(rts)): (minr,maxr) := -1, 1; (mini,maxi) := -1, 1;
 (3)
 > # One iteration of Newton's method dee := diff(ee, z); Newt1 := eval( z - ee/dee, z=zr+zi*I);
 (4)
 > # One iteration of Haf's method, u is xn uu is xn1 ####### F(u)is fx and F(v) is fy F := unapply(ee,z): dF:=D(F): v := u - (2*F(u)/3*dF(u)): #first step dFv := diff(F(v),u): nn := dF(u)/dFv: W := 1/6*(1+3*nn+(-4*ln(2-nn))): uu := v - F(u)*W/dF(u)+dF(v): Haf1 := eval(uu, [u=zr+zi*I]);
 (5)
 > H := proc(Z,N,maxiter,{scalesaturation::truefalse:=false})   local final,G,h,w,img,temp,temp2,newt,fzi,fzr;   uses IterativeMaps, ImageTools;   fzi := evalc( Im( Z ) );   fzi := convert(simplify(fzi),horner);   fzr := evalc( Re( subs(zi=zit, Z) ) );   fzr := convert(simplify(fzr),horner);   h,w := N, floor(N*(maxr-minr)/(maxi-mini));   newt := Escape( height=h, width=w,                        [zi, zr, zit],                        [fzi, fzr, zi],                        [y, x, y], evalc(abs(eval(ee,[z=zr+zit*I])))^2<1e-10,                        2*minr, 2*maxr, 2*mini, 2*maxi,                        iterations = maxiter,                        redexpression = zr, greenexpression = zit, blueexpression=i );   img:=Array(1..h,1..w,1..3,(i,j,k)->1.0,datatype=float[8]);   temp:=ln~(map[evalhf](max,copy(newt[..,..,3]),1.0));   temp2:=Threshold(temp,0.0001,low=1);   img[..,..,3]:=FitIntensity(zip(`*`,temp,temp2));   ## Done inefficiently, set the hue by position in the list of   ## all roots   G:=Array(zip((a,b)->min[index](map[evalhf](abs,rts-~(a+b*I))),                newt[..,..,1],newt[..,..,2]),datatype=float[8],order=C_order):   img[..,..,1]:=240*FitIntensity(G):   if scalesaturation then     img[..,..,2]:=1-~img[..,..,3]:   end if;   final := HSVtoRGB(img): end proc:

 > Newtimg := H(Newt1,400,200):
 > # scale down the saturation by the time to converge NewtimgS := H(Newt1,400,200,scalesaturation):
 > ImageTools:-Embed([Newtimg,NewtimgS]);
 > Haf1img := H(Haf1,400,200):
 > # scale down the saturation by the time to
 > Haf1imgS := H(Malak1,400,200,scalesaturation):
 > ImageTools:-Embed([Haf1img,Haf1imgS]);

The Maple code only works if I set the ee value to z^2-1

and the original paper: