- 340 名前:デフォルトの名無しさん mailto:sage [2009/01/07(水) 17:01:19 ]
- >>337
#include <stdio.h> #include <math.h> #define YPSILON 1e-6 #define DELTA 1e-10 double f(double x) { return x*x*x - 10*x*x + 10*x + 50; } int main(void) { double x0, x1, d; x0 = 0.0; d = (f(x0+DELTA)-f(x0))/DELTA; x1 = x0 - f(x0)/d; while (fabs(x0 - x1) > YPSILON) { x0 = x1; d = (f(x0+DELTA)-f(x0))/DELTA; x1 = x0 - f(x0)/d; } printf("x = %.5f\n", x1); return 0; }
|

|