求e^(x)在x=1.15,这个点的导数,我的步长是要从0.1,0.09,0.08……0.01这样变。谁能帮我改一下计算物理作业,或者重新编写一下。可以有报酬。微信:351737029
#include<stdio.h>
#include<math.h>
double cf(x, h, f)
double x, h, (*f)(double);
{
double dy;
for (h = 0.1; h <= 0.1; h = h - 0.01)
{
dy =((*f)(x + h) -(*f)(x- h)) / (2 * h);
}
}
main()
{
double x, h, dy, error,f(double);
x = 1.15;
h = 0.1;
dy = cf(x, h, f);
printf("dy=%lf\n", dy);
error = dy - exp(1.15);
printf("error=%lf\n", error);
}
double f(double x)
{
double y;
y = exp(x);
return(y);
}
#include<stdio.h>
#include<math.h>
double cf(x, h, f)
double x, h, (*f)(double);
{
double dy;
for (h = 0.1; h <= 0.1; h = h - 0.01)
{
dy =((*f)(x + h) -(*f)(x- h)) / (2 * h);
}
}
main()
{
double x, h, dy, error,f(double);
x = 1.15;
h = 0.1;
dy = cf(x, h, f);
printf("dy=%lf\n", dy);
error = dy - exp(1.15);
printf("error=%lf\n", error);
}
double f(double x)
{
double y;
y = exp(x);
return(y);
}