二分法算法思想:首先确定有根区间,将区间二等分,通过判断f(x)的符号,逐步将有根区间缩小,直至有根区间足够小,便可求出满足精度要求的近似值。 流程图: 实例: 求f(x)=x^3-x-1在【1,1.5】内的一个实根,使误差不超过0.005。 程序实现如下(c++):#include <iostream>#include<math.h>using namespace std;float Oper(float x){ return x*x*x-x-1;}int main(){ float a,b,c,x; cin>>a>>b>>c; . Read More
posted @ 2011-09-20 21:18 itbird Views(15845) Comments(0) Diggs(0) Edit