Hello ..
You have made a way to resolve code half-life, but missing something I want to help it ..
Fuvction which solving the equation of the third degree in how to enter transactions have, I mean how can I insert s q v g
Please help
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
double f( double,double,double,double,double);
int main ( int argc, char *argv[])
{
double a,b,d=1,eps,s,q,v,g;
while (d==1){
cout <<" Input s q f g\n ";
cin>> s >> q >> v>> g;
cout <<" Input a,b, eps\n ";
cin>> a >> b >> eps;
cout << " The input data are\n";
cout << "a= "<< a << " b= "<< b;
cout << " eps= "<< eps << endl;
cout<< " The results are\n";
cout<< "k a b x f(x) t \n";
int k=1;
double x=0.5*(a+b );
double t=(fabs(b-a));
while ((fabs(t)>=eps))
{
cout << setw(2)<< k << setprecision(5)<< fixed<< setw(8)<< a<< setw(12)<< b << setprecision(6) <<setw(12)<<x<< setw(12)<<f(x,s,q,v,g)<<setprecision(7)<< fixed <<setw(12)<<t<<endl;
if (f(x,s,q,v,g) <0)
a=x;
else
b=x;
x= 0.5*(a+b);
t=(fabs(b-a));
k++;
}
cout << setw(2)<< k << setprecision(5)<< fixed<< setw(8)<< a<< setw(12)<< b << setprecision(6) <<setw(12)<<x<< setw(12)<<f(x,s,q,v,g)<<setprecision(7)<< fixed <<setw(12)<<t<<endl;
if( ( fabs(t)) <= eps )
cout << " \nThe root = "<< x<< endl;
cout << " \nThe number of iteration = "<< k << endl;
cout << " \npress 1 to try again OR 0 to exit = " << endl;
cin>>d;
}
return 0;
}
double f(double x,double s,double q ,double v,double g){
return (s*pow(x,3)q*pow(x,2)v*xg);
}