help me with this program :
#include <iostream>
using namespace std;
#include <math.h>
double F(double x){
double res = pow(x, 9) - pow(x, 7) + 2 * pow(x, 2) -1;
return res;
}
void print_roots(){
double low = 0, high = 1;
for(int i = 0; i < 1000 ; ++i){
double mid = (float)(low + high)/2;
double val = F(mid);
cout << mid << ":" << val << endl;
if(val < 0.00001 && val > -0.00001){
cout << "Root is " << mid << endl;
return;
}
else if (val < 0 )
low = mid;
else
high = mid;
}
}
int main(int argc, char **argv){
print_roots();
system("pause");
return 0;
}
can it be made to add induction of different interval or different task.
i mean to assign a task and interval and the program to give resolution.
example : i start the program and it ask me to enter the task(bisection method) after entering it to ask me the intervals and when we do this to show the answer.
thank you in advance.i hope you understand me.sorry for bad english