Search:

Submit Article

# N-R METHOD

Posted By: Adalwolfa Fischer     Category: C Programming     Views: 4099

## Code for N-R METHOD in C Programming

```#include<stdio.h>
#include<conio.h>
#include<math.h>
#define ESP 0.00001
#define F1(x) (x)*(x)*(x) - 5*(x) + 3
#define F2(x) 3*(x)*(x) - 5
void main()
{
float x1,x2,f1,f2;
clrscr();
do
{
printf("\nEnter the value of x1: ");
scanf("%f",&x1);
}while(F1(x1) > 0);
printf("\n______________________________________________\n");
printf("\n    x1\t       f(x)\t f'(x)\t   x2");
printf("\n______________________________________________\n");
do
{
f1=F1(x1);
f2=F2(x1);
x2=x1-(f1/f2);
printf("\n%f   %f   %f   %f ",x1,f1,f2,x2);
x1=x2;
getch();
}while(F1(x2)>ESP);
printf("\n______________________________________________\n");
printf("\n\nApp.root = %f",x2);
getch();
}

/* OUT PUT---------Enter the value of x1: 1______________________________________________    x1        f(x)       f'(x)       x2______________________________________________1.000000   -1.000000   -2.000000   0.5000000.500000    0.625000   -4.250000   0.6470590.647059    0.035620   -3.743945   0.6565730.656573    0.000176   -3.706736   0.656620______________________________________________App.root = 0.656620*/```
Share:

Didn't find what you were looking for? Find more on N-R METHOD Or get search suggestion and latest updates.

 Adalwolfa Fischer author of N-R METHOD is from Frankfurt, Germany. View All Articles

 Please enter your CommentComment should be atleast 30 Characters.Please put code inside [Code] your code [/Code]. No Comment Found, Be the First to post comment!