大家解决一下
怎样用c语言来编写积分公式,我在编牛顿 科特斯积分公式时积分公式时不知道怎样用c语言写积分!大家帮忙下!
#include<stdio.h>
#include<math.h>
#define N 10
double f(double a,double b)
{double c;
c=b-2*a/b;
return c;}
void main()
{double k1,k2,k3,k4,y[N],x[N],h;
int i;
printf("please input h:");
scanf("%f",&h);
printf("\n");
printf("please input x[0]:");
scanf("%f",&x[0]);
printf("\n");
printf("please input y[0]:");
scanf("%f",&y[0]);
for(i=0;i<=N;i++)
{k1=f(x[i],y[i]);
k2=f(x[i]+h/2,y[i]+h*k1/2);
k3=f(x[i]+h/2,y[i]+h*k2/2);
k4=f(x[i]+h,y[i]+h*k3);
y[i+1]=y[i]+h*(k1+2*k2+2*k3+k4)/6;
printf("the result is y[%d]=:%f\n",i+1,y[i+1]);
}
}