1、宋玉霞 2008050216 统数 信科 0802实验一_2:Adams 方法一、实验题目:01.)(2yx取步长 h二、实验要求:用 Adams 公式 ,求此微分方程在0,10上的)3(211nnfhy数值解,并与精确解进行比较。三、程序运行结果结果:y =Columns 1 through 110 0.0100 0.0400 0.0900 0.1600 0.2500 0.3600 0.4900 0.6400 0.8100 1.0000Columns 12 through 221.2100 1.4400 1.6900 1.9600 2.2500 2.5600 2.8900 3.2400 3.
2、6100 4.0000 4.4100Columns 23 through 334.8400 5.2900 5.7600 6.2500 6.7600 7.2900 7.8400 8.4100 9.0000 9.6100 10.2400Columns 34 through 4410.8900 11.5600 12.2500 12.9600 13.6900 14.4400 15.2100 16.0000 16.8100 17.6400 18.4900Columns 45 through 5519.3600 20.2500 21.1600 22.0900 23.0400 24.0100 25.0000
3、 26.0100 27.0400 28.0900 29.1600Columns 56 through 6630.2500 31.3600 32.4900 33.6400 34.8100 36.0000 37.2100 38.4400 39.6900 40.9600 42.2500Columns 67 through 7743.5600 44.8900 46.2400 47.6100 49.0000 50.4100 51.8400 53.2900 54.7600 56.2500 57.7600Columns 78 through 8859.2900 60.8400 62.4100 64.0000
4、 65.6100 67.2400 68.8900 70.5600 72.2500 73.9600 75.6900Columns 89 through 9977.4400 79.2100 81.0000 82.8100 84.6400 86.4900 88.3600 90.2500 92.1600 94.0900 96.0400Columns 100 through 10198.0100 100.0000yy =Columns 1 through 110 0 0.0400 0.0900 0.1600 0.2500 0.3600 0.4900 0.6400 0.8100 1.0000Columns
5、 12 through 221.2100 1.4400 1.6900 1.9600 2.2500 2.5600 2.8900 3.2400 3.6100 4.0000 4.4100Columns 23 through 334.8400 5.2900 5.7600 6.2500 6.7600 7.2900 7.8400 8.4100 9.0000 9.6100 10.2400Columns 34 through 4410.8900 11.5600 12.2500 12.9600 13.6900 14.4400 15.2100 16.0000 16.8100 17.6400 18.4900mns
6、45 through 5519.3600 20.2500 21.1600 22.0900 23.0400 24.0100 25.0000 26.0100 27.0400 28.0900 29.1600Columns 56 through 6630.2500 31.3600 32.4900 33.6400 34.8100 36.0000 37.2100 38.4400 39.6900 40.9600 42.2500Columns 67 through 7743.5600 44.8900 46.2400 47.6100 49.0000 50.4100 51.8400 53.2900 54.7600
7、 56.2500 57.7600Columns 78 through 8859.2900 60.8400 62.4100 64.0000 65.6100 67.2400 68.8900 70.5600 72.2500 73.9600 75.6900Columns 89 through 9977.4400 79.2100 81.0000 82.8100 84.6400 86.4900 88.3600 90.2500 92.1600 94.0900 96.0400Columns 100 through 10198.0100 100.0000ee =1.0e-012 *Columns 1 throu
8、gh 110 0 0 0 0 -0.0001 -0.0001 -0.0002 -0.0002 -0.0003 -0.0004Columns 12 through 22-0.0004 -0.0002 0 0.0002 0.0009 0.0009 0.0013 0.0013 0.0018 0.0018 0.0018Columns 23 through 330.0027 0.0036 0.0044 0.0044 0.0053 0.0053 0.0062 0.0071 0.0089 0.0089 0.0089Columns 34 through 440.0107 0.0107 0.0124 0.012
9、4 0.0124 0.0142 0.0160 0.0142 0.0142 0.0071 0.0036Columns 45 through 550 -0.0036 -0.0071 -0.0107 -0.0142 -0.0142 -0.0178 -0.0213 -0.0249 -0.0284 -0.0355Columns 56 through 66-0.0391 -0.0426 -0.0497 -0.0568 -0.0639 -0.0639 -0.0711 -0.0711 -0.0782 -0.0782 -0.0853Columns 67 through 77-0.0853 -0.0924 -0.
10、0995 -0.0995 -0.1066 -0.1137 -0.1208 -0.1208 -0.1279 -0.1279 -0.1350Columns 78 through 88-0.1492 -0.1492 -0.1563 -0.1634 -0.1705 -0.1705 -0.1705 -0.1847 -0.1847 -0.1847 -0.1990Columns 89 through 99-0.2132 -0.2132 -0.2132 -0.2274 -0.2416 -0.2416 -0.2416 -0.2558 -0.2558 -0.2558 -0.2700Columns 100 thro
11、ugh 101-0.2842 -0.2842四、程序附录:1. function f=fun2(x,y)%右端函数f=2*x;2. function x,y,yy,ee =adams2(x0,y0,xfinal,h)%用Adams 求解n=(xfinal-x0)/h; hh=h/2;x(1)=x0;y(1)=y0;x(2)=x0+h;y(2)=0.01;%for i=2:n y(i+1)=y(i)+hh*(3*fun2(x(i),y(i)-fun2(x(i-1),y(i-1);x(i+1)=x(i)+h;yy(i+1)=x(i+1)2;ee(i+1)=yy(i+1)-y(i+1);end3. x0=0;%主函数h=0.1;xfinal=10;y0=0;x,y,yy,ee =adams2(x0,y0,xfinal,h);yyyee