Untitled
unknown
plain_text
a year ago
632 B
7
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; while(fabs(fa-fb)>= 0.0001) { float c= (fa+fb)/2; float fx= eqn(c); cout<<"The iterative value is "<<fx<<"\n"; if(fx>0) { fb=c; } else if(fx<0) { fa=c; } } return fx; } 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