# NEED MAJOR HELP WITH HW....Newton-Raphson method

• 04-14-2008
clezzie
NEED MAJOR HELP WITH HW....Newton-Raphson method
Code:

```Find on the next page an outline for a C program that solves two nonlinear equations f1(x,y)  =  0 f2(x,y)  =  0 for x and y using the Newton-Raphson method. Complete this program and obtain the solution to the given equations.  Your program output should resemble the format given below.  You need print the solution  and corresponding function values only at the final iteration when either the solution is obtained or the maximum number of iteration is exceeded with no solution.  Exercise the program to show these two cases. Sample program output:  (when program converges) Please enter initial approximations close to solution! For this EXAMPLE type : 2.0 0.25 2 .25 ----------------------------------------------------- The initial approximation are : 2.000000 0.250000 ------------------------------------------------------ At the iteration number …. :    x = …    y = …                                                                          The function values are : 0.000000 0.000000 ------------------------------------------------------ The solution was found with the desired tolerance ! Sample program output: (when program does not converge) Please enter initial approximations close to solution! For this EXAMPLE type : 2.0 0.25 7 1 ----------------------------------------------------- The initial approximation are : 7.000000 1.000000 ------------------------------------------------------ At the iteration number …. :  x = …    y = …      The function values are :    f1= …  f2 = … ------------------------------------------------------ The max. number of iterations was exceeded!```
Code:

```/*      PROGRAM OUTLINE:  Newton-Raphson Method in 2-Dimensions  To solve:               0 = f_1 (x,y) =  x*x  -  2.0*x    -  y    + 0.5               0 = f_2 (x,y) =  x*x  +  4.0*y*y  -  4.0  given one initial approximation  (p_0, q_0)  and using  Newton-Raphson iteration.                                */ /* User has to supply SIX functions named :   f1function:  this is the function f_1(x,y)     f2function:  this is the function f_2(x,y)   d11function:  partial derivative of f_1 wrsp to x       d12function:  partial derivative of f_1 wrsp to y   d21fnction:  partial derivative of f_2 wrsp to x     d22function:  partial derivative of f_2 wrsp to y /*  define prototype for USER-SUPPLIED functions  */     double f1function  (double x, double y);     double f2function  (double x, double y);     double d11function (double x, double y);     double d12function (double x, double y);     double d21function (double x, double y);     double d22function (double x, double y); /* -------------------------------------------------------- */     void main() { }  /* End of main program */```
Where Do I Start?????
• 04-14-2008
tabstop
You need to make sure you know what the Newton-Raphson method is, the description of which I don't see in your cut'n'paste. You should have a way to get a better approximation, f_n, based on the approximation you currently have, f_n-1. And you keep going until you're done.
• 04-14-2008
clezzie
so your telling me once i learn that my program will be a while loop??
• 04-14-2008
JDGATX
It doesn't necessarily have to be a while loop. A for loop, a while loop, whatever.
• 04-14-2008
clezzie
ok i think i understand the Newton Raphson...correct me if im wrong...so i will take an initial guess and plug it in and it will keep looping until i get to the orignal answer. my thing is how would i do this and where will i start from??
• 04-14-2008
tabstop
Quote:

Originally Posted by clezzie
my thing is how would i do this and where will i start from??

(1) There is a formula. If somehow it was omitted from your assignment, it is almost certainly then in your textbook.

(2)
Quote:

Please enter initial approximations close to solution!
• 04-14-2008
clezzie
tabstop theres no formula i never ever learned this ............i went to my ta and he said this ........ was hard
• 04-14-2008
JFonseka