All Programs are Written and Compiled in Dev C++. So, it may generate some error in case of other compilers and may need some modifications in program. Download Dev C++

Friday 13 February 2015

Iteration Method of Solving Transcidental Equations

#include<iostream>
#include<math.h>
#define err 0.0001
//Correction upto three Places
using namespace std;
float iterative(float x)
{
return pow((x+9),0.25); //Function G(x)=0
}
float f(float x)
{
return x*x*x*x-x-9; //Function f(x)=0
}
int main()
{
int i=1;
float x0,x1;
cout<<"Enter the first approximation ";
cin>>x0;

x1=iterative(x0);
cout<<"Iteration\t\tRoot\n";
while(fabs(x1-x0)>err)
{
cout<<"X"<<i<<"\t"<<x1<<endl;
x0=x1;
x1=iterative(x0);
i++;
}
cout<<"Root after "<<i<<" iteration="<<x1;
return 0;
}

No comments:

Post a Comment