Chapter:

newton-raphson-method

1. NEWTON-RAPHSON METHOD LAB REPORT

TITLE: 

TO FIND THE ROOTS OF NON-LINEAR EQUATION USING NEWTON-RAPHSON METHOD

 OBJECTIVES:

  • To be able to follow the algorithm of Newton-Raphson method of solving non linear equation.

  • To use the Newton Raphson method to solve examples of finding roots of a non linear equation.

  • To build some programming concepts by solving practical problems.

 TOOLS REQUIRED:

  • Computer workstation

  • Program software (as necessary)

 THEORY:

The Newton-Raphson method in mathematics, named after issac Newton and joseph Raphson, is an open bracket root finding approach requiring only one initial guess which produces successively the better approximations to the roots of a real valued function.

In general,

`X_(n+1)=X_n-(f (X_n))/(f'(X_n))`, n=0,1,2â?¦.

This is known as the Newton-Raphson formula or Newtons iteration formula.

The Newton-Raphson method is said to have quadratic convergence.

This method will,however, fail in the gollowing situations:

  1. Division by zero may occur if `f'(x)` is zero or very close to zero.

  2. If the initial guess is too far away from the required roots, the process may converge to some other roots.

  3. A particular value in the iteration sequence may repeat resulting in an infinite loop. 

 ALGORITHM:

  1. Start

  2. Assign an initial value to x say `x_0`.

  3. Evaluate `f (x_0)` and `f'(x_0)`.

  4. Check for the accuracy of the latest estimate. 

  5. Compare the relative error to a predefined 3d value E.

    1. If `abs( (x_1-x_0)/x_1)<=E` stop.

    2. Otherwise continue.

  6. Replace `x_0` by `x_1` and repeat steps 4, 5 and 6.

 C-PROGRAM:   

//Newton Raphson method
#include
#include
#include
#define f(x) 3*x - cos(x) -1
#define g(x) 3 + sin(x)
void main()
{
	 float x0, x1, f0, f1, g0, e;
	 int step = 1, N;
	 clrscr();
         fflush (stdout);
	 printf("\nEnter initial guess:\n");
	 scanf("%f", &x0);
	 printf("Enter tolerable error:\n");
	 scanf("%f", &e);
	 printf("Enter maximum iteration:\n");
	 scanf("%d", &N);
	 printf("\nStep\t\tx0\t\tf(x0)\t\tx1\t\tf(x1)\n");
	 do
	 {
		  g0 = g(x0);
		  f0 = f(x0);
		  if(g0 == 0.0)
		  {
			   printf("Mathematical Error.");
			   exit(0);
		  }
		  x1 = x0 - f0/g0;
		  printf("%d\t\t%f\t%f\t%f\t%f\n",step,x0,f0,x1,f1);
		  x0 = x1;
		  step = step+1;
		  if(step > N)
		  {
			   printf("Not Convergent.");
			   exit(0);
		  }
		  f1 = f(x1);
	 }while(fabs(f1)>e);
	 printf("\nRoot is: %f", x1);
	 getch();

CONCLUSION:

Thus the roots of the given non linear equation was found  out using Newton Raphson method.

Show More