生物信息技术0801徐聪U200812594#includestdio.h#includemath.hvoidf1(double*y,double*x,double*yy){y[0]=2.0;x[0]=0.0;yy[0]=2.0;for(inti=1;i=9;i++){x[i]=x[i-1]+0.2;y[i]=y[i-1]+0.2*(y[i-1]-x[i-1]);yy[i]=x[i]+1+exp(x[i]);printf(若x=%f,计算值是%f,真实值是%f,截断误差是%f\n,x[i],y[i],yy[i],y[i]-yy[i]);}};voidf2(double*y,double*x,double*yy){y[0]=1.0;x[0]=0.0;yy[0]=1.0;for(inti=1;i=9;i++){x[i]=x[i-1]+0.2;y[i]=y[i-1]+0.2*(2*y[i-1]+x[i-1]*x[i-1]);yy[i]=-0.5*(x[i]*x[i]+x[i]+0.5)+1.25*exp(2*x[i]);printf(若x=%f,计算值是%f,真实值是%f,截断误差是%f\n,x[i],y[i],yy[i],y[i]-yy[i]);}};voidf3(double*y,double*x,double*yy,double*y0){y[0]=2.0;x[0]=0.0;yy[0]=2.0;for(inti=1;i=9;i++){x[i]=x[i-1]+0.2;y0[i]=y[i-1]+0.2*(y[i-1]-x[i-1]);y[i]=y[i-1]+0.1*(y[i-1]-x[i-1]+y0[i-1]-x[i-1]);yy[i]=x[i]+1+exp(x[i]);printf(若x=%f,计算值是%f,真实值是%f,截断误差是%f\n,x[i],y[i],yy[i],y[i]-yy[i]);}};voidf4(double*y,double*x,double*yy,double*y0){y[0]=1.0;x[0]=0.0;yy[0]=1.0;for(inti=1;i=9;i++){x[i]=x[i-1]+0.2;y0[i]=y[i-1]+0.2*(2*y[i-1]+x[i-1]*x[i-1]);y[i]=y[i-1]+0.1*(2*y0[i-1]+x[i-1]*x[i-1]+2*y[i-1]+x[i-1]*x[i-1]);yy[i]=-0.5*(x[i]*x[i]+x[i]+0.5)+1.25*exp(2*x[i]);printf(若x=%f,计算值是%f,真实值是%f,截断误差是%f\n,x[i],y[i],yy[i],y[i]-yy[i]);}};voidmain(){doubley[10],x[10],yy[10],y0[10];printf(\n常微分方程组是y'=y-xandy(0)=2采用欧拉法求解得\n);f1(y,x,yy);printf(\n常微分方程组是y'=x*x+2yandy(0)=1采用欧拉法求解得\n);f2(y,x,yy);printf(\n常微分方程组是y'=y-xandy(0)=2采用欧拉改进法求解得\n);f1(y,x,yy);printf(\n常微分方程组是y'=x*x+2yandy(0)=1采用欧拉改进法求解得\n);f1(y,x,yy);}