您好,欢迎访问三七文档
《常微分方程数值解》实验报告实验序号:1实验项目名称:欧拉方法学号201141210230姓名谢冬冬专业、班11级信计二班实验地点K7-405指导教师汪玉霞时间2014-3-11一、实验目的及要求(1)熟悉运用显式计算格式向前Euler方法:10000(,),,(),()/nnnnnfyyhfxyxxnhyyxhxxN中点公式:11221211211(0,00),(,0),22[01]nnnnnnkfxhyhkhkkfxhyhkhkyyhkk改进Euler方法:0000111(,),,(),()/[(,)(,)]2nnnnfnnnnnnnyyhfxyxxnhyyxhxxNhyyfxyfthy或112212112(0,00),(1,10),11[]22nnnnnnkfxhyhkhkkfxhyhkhkyyhkk求解常微分方程和方程组的初值问题000(,),[,]()fyfxyxxxyxy的过程。(2)熟悉运用隐式计算格式向后Euler方法:111000(,),,()nnnnnyyhfxyxxnhyyx求解一阶线性常微分方程初值问题000(,),[,]()fyfxyaxbyxxxyxy,并将计算结果与上两种方法的结果对照。(3)对李普希兹常数巨大的微分方程,用向前Euler方法在不同步长下计算,对方法的数值稳定性进行分析,得出向前Euler方法的绝对稳定区间的有限性。二、实验设备要求与实验原理1、支持IntelPentiumⅢ及其以上CPU,内存256MB以上、硬盘1GB以上容量的微机;软件配有Windows98/2000/XP操作系统及MATLAB软件;2、实验过程中,务必将实验所得数据列表,分析数据,得出实验结论。(建议同时网上提交电子版实验报告:780668212@qq.com)三、实验内容与步骤1.分别用向前Euler、向后Euler、改进Euler方法求解1,[0,1],(0)1yyxxy并与精确解()xyxxe在各节点处的值对照,计算绝对误差,分析各算法的性能。2.分别用向前Euler方法、向后Euler方法求解2001,[0,1],(0)1yyxxy.步长分别为0.01,0.05,0.10,0.20hhhh,计算1x处的数值解,并与函数值比较。四、实验程序、结果与数据处理(一)题目一向前Euler方法:function[x,y]=xiedongdong1(a,b,h,y0)%qianoulern=(b-a)/h;x=zeros(1,n+1);y=zeros(1,n+1);x(1)=a;y(1)=y0;fori=1:nx(i+1)=x(i)+h;y(i+1)=y(i)+h*youxianf(x(i),y(i));enddsolve('Dy=x-y+1','y(0)=1','x')ans=x+exp(-x)jqz=1+exp(-1)jqz=1.3679formatlongjqz=1+exp(-1)jqz=1.367879441171442[x,y]=xiedongdong1(0,1,0.1,1)Columns8through111.1782969000000001.2304672100000001.2874204890000001.348678440100000wucha=jqz-y(11)wucha=0.019201001071443[x,y]=xiedongdong1(0,1,0.01,1)Columns97through1011.3410471181045501.3472366469235051.3534642804542701.3597296376497271.366032341273230wucha2=jqz-y(101)wucha2=0.001847099898213[x,y]=xiedongdong1(0,1,1/1000,1)Columns997through10011.3651698907910961.3658007209003051.3664319201794041.3670634882592251.367695424770966wucha3=jqz-y(1001)wucha3=1.840164004764944e-004列表比较不同步长所得结果步长数值解精确解误差(取绝对值)0.11.3486784401000001.3678794411714420.0192010010714430.051.3584859224085421.3678794411714420.0093935187629000.011.3660323412732301.3678794411714420.001847099898213改进Euler方法:function[x,y]=xiedongdong2(a,b,h,y0)n=(b-a)/h;x=zeros(1,n+1);y=zeros(1,n+1);x(1)=a;y(1)=y0;fori=1:nx(i+1)=x(i)+h;k1=youxianf(x(i),y(i));k2=youxianf(x(i+1),y(i)+h*k1);y(i+1)=y(i)+h*(k1+k2)/2;end[x,y]=xiedongdong2(0,1,0.1,1)Columns7through111.1494035676106401.1972102286876301.2499752569623051.3072276075508861.368540984833552wuxchagai1=jqz-y(11)wuxchagai1=-6.615436621091320e-004[x,y]=xiedongdong2(0,1,0.01,1)Columns97through1011.3428990584419671.3490892128104701.3553172751430051.3615828682553321.367885618716192wuchagai2=jqz-y(101)wuchagai2=-6.177544749519370e-006列表比较不同步长所得结果步长数值解精确解误差(取绝对值)0.11.3685409848335521.3678794411714426.615436621091320e-0040.091.3621084076610291.3678794411714420.0057710335104130.011.3678856187161921.3678794411714426.177544749519370e-006求解右边非线性函数:)1/(xy],1,0[,2)1/(1222'xxyxy精确解为(二)题目二向前Euler方法:function[x,y]=xiedongdong3(a,b,h,y0)n=(b-a)/h;x=zeros(1,n+1);y=zeros(1,n+1);x(1)=a;y(1)=y0;fori=1:nx(i+1)=x(i)+h;y(i+1)=y(i)+h*yfxf(x(i),y(i));end[x,y]=xiedongdong3(0,1,0.1,0)Columns7through110.4655662405135200.4957452674170470.5137066873434990.5219033849753100.522675375110103wuchaf1=0.5-y(11)wuchaf1=-0.022675375110103[x,y]=xiedongdong3(0,1,0.01,0)Columns97through1010.5018792993744230.5020456394210540.5021568918964890.5022146608108660.502220519487573wuchaf2=0.5-y(101)wuchaf2=-0.002220519487573类似的得不同步长得解(算法同上)步长数值解精确解误差(取绝对值)0.10.5226753751101030.5000000000000000.0226753751101030.010.5022205194875730.5000000000000000.0022205194875730.0010.5002216210655220.5000000000000002.216210655223705e-0042.改进Euler方法function[x,y]=gaioulaxiedongdong2(a,b,h,y0)n=(b-a)/h;x=zeros(1,n+1);y=zeros(1,n+1);x(1)=a;y(1)=y0;fori=1:nx(i+1)=x(i)+h;k1=yfxf(x(i),y(i));k2=yfxf(x(i+1),y(i)+h*k1);y(i+1)=y(i)+h*(k1+k2)/2;end列表比较不同步长所得结果(算法同上)步长数值解精确值误差(取绝对值)0.10.4981253477930410.5000000000000000.0018746522069590.010.4999837173258130.5000000000000001.628267418668505e-0050.0010.4999998393614910.5000000000000001.606385093277929e-0071)0(],1,0[,1200'yxxyy求解,精确解为199/40000+1/200*1+39801/40000*exp(-200*1)向前Euler方法:function[x,y]=xiedongdong4(a,b,h,y0)n=(b-a)/h;x=zeros(1,n+1);y=zeros(1,n+1);x(1)=a;y(1)=y0;fori=1:nx(i+1)=x(i)+h;y(i+1)=y(i)+h*yxf3(x(i),y(i));endfunctionf=yxf3(x,y)f=x-200*y+1;dsolve('Dy=x-200*y+1','y(0)=1','x')ans=199/40000+1/200*x+39801/40000*exp(-200*x)jpz3=199/40000+1/200*1+39801/40000*exp(-200*1)jpz3=0.009975000000000[x,y]=xiedongdong4(0,1,0.1,1)Columns7through110.000046811827750-0.0008894247270900.016899069814880-0.3210823264825406.100564203168456wuchax1=jpz3-y(11)wuchax1=-6.100564203168446e+012[x,y]=xiedongdong4(0,1,1/100,1)Columns97through1011.004800000000006-0.9852000000000051.004900000000006-0.9851000000000061.005000000000006wuchax2=jpz3-y(101)wuchax2=-0.995025000000006列表比较不同步长所得结果(算法同上)步长数值解精确解误差(取绝对值)0.011.0050000000000060.0099750000000000.9950250000000060.0090.0099699999825890.0099750000000005.000017410950949e-0060.0010.
本文标题:数值分析报告
链接地址:https://www.777doc.com/doc-2424397 .html