Newton Raphson Method

Spread the love

Newton Raphson Method using C programming

Newton Raphson Method 

 Also known as successive substitution method.

Algorithm
1.      Assign an initial value to x say x0.
2.      Evaluate f (x0) and f’(x0)
3.      Compute x1 =x0 –f(x0)/f(x0)
4.      If f(x1) =0 then x1, is the required root & stop the process.
5.      If f(x1) +0 then replace x0 by x1 & repeat the process till the root is found to the desired degree of accuracy.
 
            Let xo be the first approximation to the root of the equation f(x)=0. Let x1=x0 + h be the better approximation which approximately satisfy the equation f(x) = 0
Therefore,
            f(x0+h)= 0 approximately
            f(x0)+h f(x0)+h2/2! f”(x0)+h/3! f’”(x0) +….. =0
Assumption since h is very small, neglecting its square and higher power, we get,
f(x0) +h f’(x0)=0
 h= – f(x0)/ f’(x0)
 
Therefore ,
x1=x0-f(x0)/f’(x0)
 
 
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define e 0.0001
float f(float x){
      return (x*x*x-6*x+4);
}
float f1(float x){
      return (3*x*x-6);
}
void main(){
float x0,x1;
clrscr();
printf(“enter initial value:”);
scanf(“%f”,&x0);
do{
x1=x0-(f(x0)/f1(x0));
if(f(x1)==0)
 break;
else
 x0=x1;
}while(fabs((x1-x0)/x1)>e);
printf(“the reqd. root is:%f”,x1);
getch();
}
 
 
 
 
 

 

False position method


Spread the love

Santosh Adhikari

Hello, it's me Santosh Adhikari, from Kathmandu, Nepal. I'm a student of Science and Technology. I love new challenges and want to explore more on Software Quality Assurance. I want to be a professional SQA. I'm also interested in Blogging, SEO activities.
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments