MalakMMK

15 Reputation

4 Badges

2 years, 110 days

MaplePrimes Activity


These are replies submitted by MalakMMK

@Carl Love 

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 sir I truly appreciate your time and efoort to help me thank you

@MalakMMK 

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 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 like him 

@Carl Love 

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'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 

@Carl Love 

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

@acer 

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

Thank you for your time.

@acer 

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.

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

Wei_method.mw

@acer 

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;

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](%);

[1.]

 

[1.]

(2)

#(minr,maxr) := (min,max)(Re~(rts)):
#(mini,maxi) := (min,max)(Im~(rts)):
(minr,maxr) := -1, 1;
(mini,maxi) := -1, 1;

-1, 1

 

-1, 1

(3)

# One iteration of Newton's method
dee := diff(ee, z);
Newt1 := eval( z - ee/dee, z=zr+zi*I);

3*z^2

 

zr+I*zi-(1/3)*((zr+I*zi)^3-1)/(zr+I*zi)^2

(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]);

zr+I*zi-2*((zr+I*zi)^3-1)*(zr+I*zi)^2-(1/3)*((zr+I*zi)^3-1)*(1/6+(1/2)*(zr+I*zi)^2/((zr+I*zi-2*((zr+I*zi)^3-1)*(zr+I*zi)^2)^2*(1-6*(zr+I*zi)^4-4*((zr+I*zi)^3-1)*(zr+I*zi)))-(2/3)*ln(2-(zr+I*zi)^2/((zr+I*zi-2*((zr+I*zi)^3-1)*(zr+I*zi)^2)^2*(1-6*(zr+I*zi)^4-4*((zr+I*zi)^3-1)*(zr+I*zi)))))/(zr+I*zi)^2+3*(zr+I*zi-2*((zr+I*zi)^3-1)*(zr+I*zi)^2)^2

(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]);

NULL

Download Haf_Newton.mw

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

and the original paper: 

https://www.researchgate.net/profile/Mohammad-Hafiz-4/publication/346209872_An_optimal_fourth_order_method_for_solving_nonlinear_equations/links/611bc5a21ca20f6f862b7d39/An-optimal-fourth-order-method-for-solving-nonlinear-equations.pdf

@acer 

yes I did but he program keep running without any progress, 

it id for an academic project

1 2 Page 1 of 2