#include #include int main(void) { int i, n=1000; float f0, f1, f2, f3, g0, g1, g2, h0, h1, c; float t,u, dt; float x0 = 2, x1 = 11, x2 = 397, x3 = 431; /* (2,5), (11,320), (397,200), (431,326) */ dt = 1.0/n; f0 = 2; t = dt; u = 1-t; f1 = x0*u*u*u + 3*x1*u*u*t + 3*x2*u*t*t + x3*t*t*t; t = 2*dt; u = 1-t; f2 = x0*u*u*u + 3*x1*u*u*t + 3*x2*u*t*t + x3*t*t*t; t = 3*dt; u = 1-t; f3 = x0*u*u*u + 3*x1*u*u*t + 3*x2*u*t*t + x3*t*t*t; g0 = f1-f0; g1=f2-f1; g2=f3-f2; h0=g1-g0; h1=g2-g1; c=h1-h0; for(i=4; i<=n; i++){ h1 += c; g2 += h1; f3 += g2; } printf("x(1) = %lf\n",f3); }