资源描述:
《数值分析课程设计汇本李谚》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、数值分析课程设计姓名:李谚专业:电子专业学号:12254080052011年6月数值分析程序物理学院电子专业1225408005李谚一、利用用改进欧拉法求解改进欧拉法编写程序如下:(1)r=15步长h=0.001r=15;b=-8/3;q=10;z0=14;x0=6.110;y0=6.110;h=0.001;>>fort=-2:h:1fx=-q*(x0-y0);fy=-x0*z0+r*x0-y0;fz=x0*y0-b*z0;x1=x0+h*fx;y1=y0+h*fy;z1=z0+h*fz;fx1=-q*(x1-y1);fy1=-x1*z1+r*x1-y1
2、;fz1=x1*y1-b*z1;x0=x0+0.5*h*(fx+fx1);y0=y0+0.5*h*(fy+fy1);z0=z0+0.5*h*(fz+fz1);plot(x0,t,'red');holdon;[t,x0,y0,z0]endR=15区间t(-2,1)步长h=0.001欧拉改进法x-t曲线(1)r=28步长h=0.001r=15;b=-8/3;q=10;z0=14;x0=6.110;y0=6.110;h=0.001;>>fort=-2:h:1fx=-q*(x0-y0);fy=-x0*z0+r*x0-y0;fz=x0*y0-b*z0;x1=x0+
3、h*fx;y1=y0+h*fy;z1=z0+h*fz;fx1=-q*(x1-y1);fy1=-x1*z1+r*x1-y1;fz1=x1*y1-b*z1;x0=x0+0.5*h*(fx+fx1);y0=y0+0.5*h*(fy+fy1);z0=z0+0.5*h*(fz+fz1);plot(x0,t,'blue');holdon;[t,x0,y0,z0]endr=28区间t(-2,1)步长h=0.001欧拉改进法x-t曲线二、利用龙格库塔法求解用MATLAB实现龙格库塔法编写程序如下:(1)r=15步长h=0.001r=15;b=-8/3;q=10;z0=1
4、4;x0=6.110;y0=6.110;h=0.001;fort=-2:h:1k10=-q*(x0-y0);k20=-q*(x0+h*k10/2)+q*(y0+h/2);k30=-q*(x0+h*k20/2)+q*(y0+h/2);k40=-q*(x0+h*k30)+q*(y0+h);x1=x0+h*(k10+2*k20+2*k30+k40)/6;k11=-x0*z0+r*x0-y0;k21=-(x0+h/2)*(z0+h/2)+r*(x0+h/2)-(y0+h*k11/2);k31=-(x0+h/2)*(z0+h/2)+r*(x0+h/2)-(y0+h
5、*k21/2);k41=-(x0+h)*(z0+h)+r*(x0+h)-(y0+h*k31);y1=y0+h*(k11+2*k21+2*k31+k41)/6;k12=x0*y0-b*z0;k22=(x0+h/2)*(y0+h/2)-b*(z0+h*k12/2);k32=(x0+h/2)*(y0+h/2)-b*(z0+h*k22/2);k42=(x0+h)*(y0+h)-b*(z0+h*k32);z1=y0+h*(k12+2*k22+2*k32+k42)/6;fx1=-q*(x1-y1);fy1=-x1*z1+r*x1-y1;fz1=x1*y1-b*z1;
6、x0=x0+0.5*h*(k10+fx1);y0=y0+0.5*h*(k11+fy1);z0=z0+0.5*h*(k12+fz1);plot(y0,t,'red');holdon;[t,x0,y0,z0]endR=15区间t(-2,1)步长h=0.001龙格库塔法x-t曲线(2)r=28步长h=0.001r=28;b=-8/3;q=10;z0=27;x0=8.4852;y0=8.4852;h=0.001;fort=-2:h:1k10=-q*(x0-y0);k20=-q*(x0+h*k10/2)+q*(y0+h/2);k30=-q*(x0+h*k20/2)
7、+q*(y0+h/2);k40=-q*(x0+h*k30)+q*(y0+h);x1=x0+h*(k10+2*k20+2*k30+k40)/6;k11=-x0*z0+r*x0-y0;k21=-(x0+h/2)*(z0+h/2)+r*(x0+h/2)-(y0+h*k11/2);k31=-(x0+h/2)*(z0+h/2)+r*(x0+h/2)-(y0+h*k21/2);k41=-(x0+h)*(z0+h)+r*(x0+h)-(y0+h*k31);y1=y0+h*(k11+2*k21+2*k31+k41)/6;k12=x0*y0-b*z0;k22=(x0+h/
8、2)*(y0+h/2)-b*(z0+h*k12/2);k32=(x0+h/2)*