Untitled
unknown
plain_text
a year ago
656 B
4
Indexable
#include<iostream> #include<cmath> using namespace std; float eqn(float x) { return ((x*x*x)-x-4); } float bisect(float a, float b) { float fa=a; float fb =b; float fx; float root; while(fabs(fa-fb)>= 0.001) { float c= (fa+fb)/2; fx= eqn(c); cout<<"The iterative value is "<<fx<<"\n"; if(fx>0) { fb=c; } else { fa=c; } root=c; } return root; } int main() { float a=1; float b= 2; float val= bisect(a,b); cout<<"the root value ="<<val; return 0; }
Editor is loading...
Leave a Comment