Danish Toheed

15 Reputation

One Badge

1 years, 187 days

MaplePrimes Activity


These are replies submitted by Danish Toheed

@acer 

With all due respect, I am aware that I am making mistakes. As I mentioned before, I am a beginner and I am putting in my best effort to learn Maple. I kindly request your assistance in implementing all the changes you mentioned above to achieve the desired result.

Regards...

NM222.mw
i'm just talking about any general nonlinear equation. I wrote k^3-1 as an example.
And even if it doesn't find root for an equation i already shared an equation exp(k)-k-1 with initial guess 0.5 and multiplicity 2.
You can check it in the previously attached file.
Thanks for the reply

restart

Digits := 101

101

(1)

NM := proc (f_exp, t0, m, tolerence := 10^(-400), mx_iteration := 4) local iteration, f, w, t, y, u, v, z, r, s, p, Pi; iteration := 0; f := unapply(f_exp, k); t := t0; while tolerence < abs(f(t)) and iteration < mx_iteration do w := evalf(t+0.1e-1*f(t), 100); y := evalf(t+(-1)*m*0.1e-1*f(t)^2/(f(w)-f(t)), 400); u := evalf((f(y)/f(t))^(1/2), 400); v := evalf((f(w)/f(t))^(1/2), 400); z := evalf(y+(-1)*(3+2*m*u+(m-3)*v)*u*0.1e-1*f(t)^2/(f(w)-f(t)), 400); r := evalf((f(z)/f(y))^(1/2), 400); s := evalf((f(z)/f(t))^(1/2), 400); t := evalf(z+(-1)*s*((1-v)*(3+(5*r-3*u-6)*v)+m*(4+(r-3)*v)*v+2*m*(1+v+(2*r-1)*v^2)*u-m*(4*u*v-1/2-(1/2)*v)*u^2*v)*0.1e-1*f(t)^2/(f(w)-f(t)), 400); print(t); iteration := iteration+1 end do; return t end proc

proc (f_exp, t0, m, tolerence := 10^(-400), mx_iteration := 4) local iteration, f, w, t, y, u, v, z, r, s, p, Pi; iteration := 0; f := unapply(f_exp, k); t := t0; while tolerence < abs(f(t)) and iteration < mx_iteration do w := evalf(t+0.1e-1*f(t), 100); y := evalf(t+(-1)*m*0.1e-1*f(t)^2/(f(w)-f(t)), 400); u := evalf((f(y)/f(t))^(1/2), 400); v := evalf((f(w)/f(t))^(1/2), 400); z := evalf(y+(-1)*(3+2*m*u+(m-3)*v)*u*0.1e-1*f(t)^2/(f(w)-f(t)), 400); r := evalf((f(z)/f(y))^(1/2), 400); s := evalf((f(z)/f(t))^(1/2), 400); t := evalf(z+(-1)*s*((1-v)*(3+(5*r-3*u-6)*v)+m*(4+(r-3)*v)*v+2*m*(1+v+(2*r-1)*v^2)*u-m*(4*u*v-(1/2)*v-1/2)*u^2*v)*0.1e-1*f(t)^2/(f(w)-f(t)), 400); print(t); iteration := iteration+1 end do; return t end proc

(2)

NM(k^3-1, .5, 1)

-1880.239042992681393945332971544154464658664713204925176341379682052966577729049289678957882742820983698211078302232033985475006422380031777772893842623964161605963964745459952500541093797788860141630333772803017864231189929556286160345037783281985768079112724171671856498282432210814187537447904184151793382913030789393891102474571913250066976030236339950851742686479117071186049378163880619873197250+4560.964735929160175107578661025867009117158173628407798148892919856596374983824270516012134957747608773431613422118913985249198875185169608212995573187493238640216111512216139869556026097707115017675426803311537213843046541563431238777312426073236193129947339590864638204595544567534572545410940420527116837104962809966706734197068301241742796791698633461802583319074434293291655992347103669953832683*I

 

-550876571.0537524310372296624616133741817291235745287794528458366413511827656859353846240544589178744544074275348128203100927963415077544557839180926237971629723913973715099576574631732785293848778039427255200855485212129857066123359490209112800288618759633334409663479338592115821635235691364761776584574191965593360725458302576972294914894253140694074872205646901051965579998825805073211942155881396+235103299.0008602837078318896128271676995757872784274856878660154030569371202749911608208396407568052805905077633614146234958643958332429189556229944976250529384789473726331964548770658856217220143064590582534131628462207691448298139662472574794934040649294598662883982302057804814574108036868494500684670332685024599863276121077173097720604065342831189666318150405657262623016855559670856646040962060*I

 

379125172895726879356205.0073511697095057255274648734799435572906633022620003146936990457254689569858001813540865418304670694505331927959416477248715255139752358985192247693986630294370013763758905741431616248434425491779428020643262929861751011186005499248153949568408729819937895096521171401346913298576081005144717319746851430380020865748132932247900865547349117740052666697817840980130235328901959-1005209383177622900348700.613480010088151615885133565466021160044773408237286516315356664390326297472513858234215318594760233586208678621223559968049218901125370666974599928426223815306530656423755137256523614041617834801596648445580471967789373512971191601281697329651998040678827154675137697866743393966583457990655186801734901174440168929628720550192994128342810380041844790968962701522070608253945*I

 

5473812687515279524071643951991201418261723531330702300571825575654151.317713248778289059857451106403796647225504770200350774784698408140146887375099709466610178668981419211688186798978975317300170732577244524276422401198358356791181015983013177479585006057165126791101643482113041331309944180066975379363527432292943718954071005884903670677836415317218700222320645418297329900892506923755464633072518-2911278438329022566308938173010659232339206249815724236961405284941447.289355681121806262654134902261128840499087880898925009453079610176450142052210864844168169259822546336305845486402500652859661631665824522531634570074602773264849577936738203162170896892844278643223717979410950859008115494677104190645433017647583848227208807800896121660551946838140398388638386607539770778571135896709559108154635*I

 

5473812687515279524071643951991201418261723531330702300571825575654151.317713248778289059857451106403796647225504770200350774784698408140146887375099709466610178668981419211688186798978975317300170732577244524276422401198358356791181015983013177479585006057165126791101643482113041331309944180066975379363527432292943718954071005884903670677836415317218700222320645418297329900892506923755464633072518-2911278438329022566308938173010659232339206249815724236961405284941447.289355681121806262654134902261128840499087880898925009453079610176450142052210864844168169259822546336305845486402500652859661631665824522531634570074602773264849577936738203162170896892844278643223717979410950859008115494677104190645433017647583848227208807800896121660551946838140398388638386607539770778571135896709559108154635*I

(3)

NULL

NULL

NULL


 

Download NM222.mw

@acer 

@acer 

I apologize for mixing up so many things.
In this file, I have created a program file for an iterative method. The purpose of this program is to find the roots of a function. To use the program, you need to call it and provide the function ('f_exp'), the initial guess ('t0'), and the multiplicity ('m'). The program will then provide the root within the specified tolerance.

Now, I would like to know how to call this program for a specific function (mentioned (K^3-1)) and obtain its basin of attraction.
Also i used Maple 21 this time.

nm(2).mw

restart

Digits := 101

101

(1)

NM := proc (f_exp, t0, m, tolerence := 10^(-400), mx_iteration := 4) local iteration, f, w, t, y, u, v, z, r, s, p, Pi; iteration := 0; f := unapply(f_exp, k); t := t0; while tolerence < abs(f(t)) and iteration < mx_iteration do w := evalf(t+0.1e-1*f(t), 100); y := evalf(t+(-1)*m*0.1e-1*f(t)^2/(f(w)-f(t)), 400); u := evalf((f(y)/f(t))^(1/2), 400); v := evalf((f(w)/f(t))^(1/2), 400); z := evalf(y+(-1)*(3+2*m*u+(m-3)*v)*u*0.1e-1*f(t)^2/(f(w)-f(t)), 400); r := evalf((f(z)/f(y))^(1/2), 400); s := evalf((f(z)/f(t))^(1/2), 400); t := evalf(z+(-1)*s*((1-v)*(3+(5*r-3*u-6)*v)+m*(4+(r-3)*v)*v+2*m*(1+v+(2*r-1)*v^2)*u-m*(4*u*v-1/2-(1/2)*v)*u^2*v)*0.1e-1*f(t)^2/(f(w)-f(t)), 400); print(t); iteration := iteration+1 end do; return t end proc

proc (f_exp, t0, m, tolerence := 10^(-400), mx_iteration := 4) local iteration, f, w, t, y, u, v, z, r, s, p, Pi; iteration := 0; f := unapply(f_exp, k); t := t0; while tolerence < abs(f(t)) and iteration < mx_iteration do w := evalf(t+0.1e-1*f(t), 100); y := evalf(t+(-1)*m*0.1e-1*f(t)^2/(f(w)-f(t)), 400); u := evalf((f(y)/f(t))^(1/2), 400); v := evalf((f(w)/f(t))^(1/2), 400); z := evalf(y+(-1)*(3+2*m*u+(m-3)*v)*u*0.1e-1*f(t)^2/(f(w)-f(t)), 400); r := evalf((f(z)/f(y))^(1/2), 400); s := evalf((f(z)/f(t))^(1/2), 400); t := evalf(z+(-1)*s*((1-v)*(3+(5*r-3*u-6)*v)+m*(4+(r-3)*v)*v+2*m*(1+v+(2*r-1)*v^2)*u-m*(4*u*v-(1/2)*v-1/2)*u^2*v)*0.1e-1*f(t)^2/(f(w)-f(t)), 400); print(t); iteration := iteration+1 end do; return t end proc

(2)

NM(exp(k)-k-1, .5, 2)

0.1031482936686018313249625019731714203054530950002419817332309496261548181523617107782312689486879137070346650946075737406329638376940402730305947967264637863248981022411109354524996863009475015353432450992304397704046675422824169948832269833902791663834820031610091193339642167381846648905086144803735006522651285499035790399257061825032293475854835335726171846313393607694988072606037939986914410e-5

 

0.52190578799237742796510476121183497502882743504509648274698110991263283926479746313717736523170085631242876071229191393996086961769147855563201375744784061451900005289218656410865281166883444625872515735346696879937781912134719704178978978040839441949899540137366862035327740853295718808037203098299086539825393083004822685732235403597100071913263673252610340607374120551123e-51

 

0.52190578799237742796510476121183497502882743504509648274698110991263283926479746313717736523170085631242876071229191393996086961769147855563201375744784061451900005289218656410865281166883444625872515735346696879937781912134719704178978978040839441949899540137366862035327740853295718808037203098299086539825393083004822685732235403597100071913263673252610340607374120551123e-51

(3)

f_exp := k^3-1

k^3-1

(4)

plots:-densityplot(NM, -2 .. 2, -2 .. 2, grid = [201, 201], title = "NM method ", size = [300, 300], colorstyle = HUE, style = surface)

 

NULL

Download nm(2).mw

@acer I am trying to plot basins of attraction for the three step iterative scheme NM-1. I am rewriting my problem to clear the confusion if any.  My problem is:
Consider the polynomial f(x) = (x2− 1)2 , which has zeros {±1} with multiplicity two. I want to use a grid of 400 × 400 points in a rectangle D ∈ C of size [−2, 2] × [−2, 2] and assign color green to each initial point in the basin of attraction of zero '-1' and the color red to each point in the basin of attraction of zero ‘1' when using NM-1 method with x0 as initial guess, m is multiplicity. The inner do-loop evaluates the values of w,u,v,r and s which are used in three step iterative method having steps y, z and x as first, second and third steps.  The attachement was saved in maple 21 as some of the commands in maple 18 were not working properly. So i'm using both now. 

I am quite happy by the response and thankfull for giving your precious time and knowledge. Stay blessed 

Here is my three step iterative method but its not working as required. Giving error. Here is the code attached.

Thank you for your response. The code you suggested doesn't work properly at Maple 18 software. My problem is:
Consider the polynomial p1(z) = (z2− 1)2 , which has zeros {±1} with multiplicity two. I want to use a grid of 400 × 400 points in a rectangle D ∈ C of size [−2, 2] × [−2, 2] and assign color green to each initial point in the basin of attraction of zero '-1' and the color red to each point in the basin of attraction of zero ‘1' when using Newton method.

Page 1 of 1