Re: 2 dimension Newton Raphson
- To: mathgroup at smc.vnet.net
- Subject: [mg71349] Re: 2 dimension Newton Raphson
- From: "dimitris" <dimmechan at yahoo.com>
- Date: Wed, 15 Nov 2006 06:44:39 -0500 (EST)
- References: <ej1q7l$e2l$1@smc.vnet.net>
There is a new book called Complex Analysis with MATHEMATICA® by W. Shaw (see here http://www.amazon.com/Complex-Analysis-MATHEMATICA-William-Shaw/dp/0521836263/sr=8-1/qid=1163459323/ref=pd_bbs_sr_1/103-5414680-6091022?ie=UTF8&s=books ) which contains much material about Newton-Raphson iteration within Mathematica. Dimitris ms z wrote: > I have tried to solve the roots of the simultaneous nonlinear equations > (x-4)^2 + (y-4)^2 = 5 > x^2 + y^2 = 16 > > by writing this function: > > nr2method[xl1_, xl2_, es1_] := > Block[{x1, x2, ea, es, x1new, u, v}, > u = (x1 - 4)^2 + (x2 - 4)^2 - 5; > v = x1^2 + x2^2 - 16; > ea = 100; es = es1; > For[i = 1, ea > es, i++, > (x1new[x1_, x2_] = x1 - (u*D[ > v, x2] - v*D[u, x2])/(D[u, x1]*D[v, x2] - D[u, x2]*D[v, x1]); > If[i == 1, x1 = xl1, x1 = b]; > x2 = xl2; > b = x1new[x1, x2]; > ea = Abs[(b - x1)/b 100]; > Clear[x1, x2, x1new];)]; > ea = 100; es = es1; > For[i = 1, ea > es, i++, > (x2new[x1_, x2_] = x2 - (v*D[u, x1] - u*D[v, x1])/(D[u, x1]*D[v, x2] - > D[u, x2]*D[v, x1]); > If[i == 1, x2 = xl2, x2 = c]; > x1 = xl1; > c = x2new[x1, x2]; > ea = Abs[(c - x2)/c 100]; > Clear[x1, x2, x2new];)]; > Print["The value of x1 is ", b]; > Print["The value of x2 is ", c];] > > Is this function a good one? Is there a way to make this function simpler? > > _________________________________________________________________ > Get MSN Messenger emoticons and display pictures here! > http://ilovemessenger.msn.com/?mkt=en-sg