|
#include
#include
#include
#include
using namespace ::std;
int main()
{
double x,n,r,f,fprime,error,a,b;
int d,iteration;
cout<<"input n: ";
cin>>n;
cout<<"input x: ";
cin>>x;
cout<<"input an initial guess at root, -1 if unsure: ";
cin>>r;
cout<<"input amount of decimal values: ";
cin>>d;
do{
if(r!=-1)
{
r=r;
}
else if(r==-1)
{
srand(r);
}
f=pow(r,n)-x;
fprime=n*pow(r,n-1);
a=x-(f/fprime);
b=a;
}while(a!=.01);
for(b=a;b=.01;b--)
for(iteration=1;iteration<=15;iteration++)
cout<
cout<
<
return 0;
}
this is all the code I have produced...I am having major trouble in the do loop....that is what is messing me up....I need to produce when the user inputs all the values newton's method........as it does over and over in the do loop the program should print the iteration #,current estimate of the solution, and error(absolute of last estimate - current estimate) when it hits 0...this is due tomorrow please help!!
___________________
ATB -Let u go
Iio - Rapture(riva edit)
Dj Encore - I see right through you
Lasgo - something
The best vocal tunes on LI RIP(2001-2002)
|