Report9 2011, Feb 05 #include <stdio.h> #include <math.h></p> double h[7]={0.5,0.1,0.01,0.001,0.0001,0.00001,0.000001}; double function(double x); double function_plus(double x,double h); double function_minus(double x,double h); int main() { double x= 3.5; double derivative1 = 0; double derivative2 = 0; printf(" h f(x)' f(x)''\n"); for(int i=0;i<7;i++) { derivative1=(function_plus(x,h[i])-function_minus(x,h[i]))/(2*h[i]); derivative2=(function_plus(x,h[i])-(2*function(x))+function_minus(x,h[i]))/(pow(h[i],2)); printf("%lf %lf %lf\n",h[i],derivative1,derivative2); } return 0; } double function(double x) { return 1/x; } double function_plus(double x,double h) { return 1/(x+h); } double function_minus(double x,double h) { return 1/(x-h); } </textarea> </div> Please enable JavaScript to view the comments powered by Disqus.