Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

2 dimension Newton Raphson

  • To: mathgroup at smc.vnet.net
  • Subject: [mg71218] 2 dimension Newton Raphson
  • From: "ms z" <ms-z- at hotmail.com>
  • Date: Fri, 10 Nov 2006 06:38:39 -0500 (EST)

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


  • Prev by Date: Re: Challenge problem
  • Next by Date: Re: animation question
  • Previous by thread: Series[] nested (bug?)
  • Next by thread: Re: 2 dimension Newton Raphson