RUPAK SEARCH ENGINE

Custom Search

find root in numerical method

#include
#include
#include
#define f(x) pow(x,3)-4*pow(x,2)+3*x+5
#define df(x) 3*pow(x,2)-8*x+3
void main()
{
clrscr();
int k=0;
float x,p,q,a,error=0.0000001;
printf("Input your approxmate root x=");
scanf("%f",&x);
label1: k=k+1;
p=f(x);
q=df(x);
a=x-p/q;
printf("%d root=%f f(x)%f\n",k,x,p);
if(fabs(a-x)<(error)) { goto label2;} else {x=a; goto label1;} label2: printf("root is %f\n",x); getch(); } #include
#include
#include
#define f(x) 5*sin
#define df(x) 25*pow(x,4)+56*pow(x,3)-21*pow(x,2)+8*x-10
void main()
{
clrscr();
int k=0;
float x,p,q,a,error=0.0001;
printf("Input your approxmate root x=");
scanf("%f",&x);
label1: k=k+1;
p=f(x);
q=df(x);
a=x-p/q;
printf("%d root=%f f(x)%f\n",k,x,p);
if(fabs(a-x)<(error))
{ goto label2;}
else
{x=a; goto label1;}
label2: printf("root is %f\n",x);
getch();
}

No comments:

Post a Comment