Лабораторная работа: Исследование точности численного интегрирования
for(i=0;i<=(int(pow(2,j-1))*n);i++)
{
x=a+i*h;
if(i==0||i==n)
t=1;
else
{
if(i%2==0)
t=2;
else
t=4;
}
y=t*(h/3)*(sin(2*x));
Sum[j]=Sum[j]+y;
}
if (j>1)
{
coa=(Sum[j]-Sum[j-1])/Sum[j-1];
printf("Criterion of accuracy=%.5f Number of iteration=%d\n",coa,j);
fprintf(fp,"%.7f\t",coa);
fprintf(fp,"%d\t\n",j);
}
}
printf("The sum by a Simpson's method= %.7f\n",Sum[1]);
fprintf(fp,"The sum by a Simpson's method=%.7f\n",Sum[1]);
scanf("%d",&b);
}