MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: 2 dimension Newton Raphson

  • To: mathgroup at smc.vnet.net
  • Subject: [mg71236] Re: 2 dimension Newton Raphson
  • From: "Ray Koopman" <koopman at sfu.ca>
  • Date: Sat, 11 Nov 2006 03:38:39 -0500 (EST)
  • References: <ej1q7l$e2l$1@smc.vnet.net>

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?

In[1]:=
Solve[{x^2 + y^2 == 16, (x-4)^2 + (y-4)^2 == 5}, {x,y}]
N@%
Show[Graphics[{Circle[{0,0},4], Circle[{4,4},Sqrt[5]], PointSize[.02],
     Point/@Map[Last,%,{2}]}], AspectRatio->Automatic, Axes->True]

Out[1]=
{{x -> (1/16)*(43 - Sqrt[199]), y -> (1/16)*(43 + Sqrt[199])},
 {x -> (1/16)*(43 + Sqrt[199]), y -> (1/16)*(43 - Sqrt[199])}}

Out[2]=
{{x -> 1.80583,y -> 3.56917},{x -> 3.56917,y -> 1.80583}}

Out[3]=
-Graphics-


  • Prev by Date: Re: Singularity-handling transformation employed by NIntegrate
  • Next by Date: Re: Typo in DedekindEta function definition?
  • Previous by thread: 2 dimension Newton Raphson
  • Next by thread: Re: 2 dimension Newton Raphson