NUMERICAL METHOD LAB 3: Newton Raphson Method
Newton Raphson Method
THEORY
Newton Raphson method, also called the Newton’s method, is the fastest and simplest approach of all methods to find the real root of a nonlinear function. It is an open bracket approach, requiring only one initial guess. This method is quite often used to improve the results obtained from other iterative approaches.
The overall approach of Newton’s method is more useful in case of large values the first derivative of f(X) i.e f'(X). The iterative formula for Newton Raphson method is:
Xn+1 = Xn – f(Xn)/f'(Xn)
Features of Newton’s Method:
 Type – open bracket
 No. of initial guesses – 1
 Convergence – quadratic
 Rate of convergence – faster
 Accuracy – good
 Programming effort – easy
 Approach – Taylor’s series
Newton Raphson Method Algorithm:
 Start
 Read x, e, n, d
*x is the initial guess
e is the absolute error i.e the desired degree of accuracy
n is for operating loop
d is for checking slope*  Do for i =1 to n in step of 2
 f = f(x)
 f1 = f'(x)
 If ( [f1] < d), then display too small slope and goto 11.
*[ ] is used as modulus sign*  x1 = x – f/f1
 If ( [(x1 – x)/x1] < e ), the display the root as x1 and goto 11.
*[ ] is used as modulus sign*  x = x1 and end loop
 Display method does not converge due to oscillation.
 Stop
SOURCE CODE
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

#include<stdio.h>
#include<math.h>
float f(float x)
{
return x*log10(x) – 1.2;
}
float df (float x)
{
return log10(x) + 0.43429;
}
void main()
{
int itr, maxmitr;
float h, x0, x1, allerr;
printf(“nEnter x0, allowed error and maximum iterationsn”);
scanf(“%f %f %d”, &x0, &allerr, &maxmitr);
for (itr=1; itr<=maxmitr; itr++)
{
h=f(x0)/df(x0);
x1=x0–h;
printf(” At Iteration no. %3d, x = %9.6fn”, itr, x1);
if (fabs(h) < allerr)
{
printf(“After %3d iterations, root = %8.6fn”, itr, x1);
return 0;
}
x0=x1;
}
printf(” The required solution does not converge or iterations are insufficientn”);
return 1;
}
