来人呀!
看得懂二分,看不懂牛顿...
找资料ING...
#include<stdio.h> double F(int ); double dichotomy(double, double, double); int main() { printf("x1=%lf",dichotomy(-10,10,1e-6)); return 0; } double F(double x)//函数表达式 { return 2*x*x*x-4*x*x+3*x-6; } double dichotomy(double low, double high, double precision) // 二分法计算 { double mid = (low+high)/2; if (F(mid) == 0) return mid; while ((high-low)>=precision) { mid = (low+high)/2; if (F(mid) == 0) return mid; if (F(low)*F(mid) < 0) high = mid; else low = mid; } return low; }