下载
加入VIP
  • 专属下载特权
  • 现金文档折扣购买
  • VIP免费专区
  • 千万文档免费下载

上传资料

关闭

关闭

关闭

封号提示

内容

首页 偏微分方程数值解法题解

偏微分方程数值解法题解.doc

偏微分方程数值解法题解

李飞雨
2017-09-18 0人阅读 举报 0 0 暂无简介

简介:本文档为《偏微分方程数值解法题解doc》,可适用于活动策划领域

偏微分方程数值解法题解偏微分方程数值解法(带程序),,,uu,(,),xt,,,,t,,x,,,,(,xx,,,例求解初边值问题要求采用树脂格式,,ux(,),,,,(),,)xx,,,,,,ututt(,)(,),,,,t,nnnnn完成下列计算:uuuuu,,,(),,jjjjj,()x,()取分别计算时刻的数值解。,,,x,,,t,,,,()取分别计算时刻的数值解。,,,x,,,t,,,,()取分别计算时刻的数值解。,,,x,,,t,,,,,n,()nt,,并与解析解进行比较。u,(,)sin()sin()xtnxe,,n,n,解:程序functionA=zhongxinchafen(x,y,la)U=zeros(length(x),length(y))fori=:size(x,)ifx(i)>x(i)<=U(i,)=*x(i)elseifx(i)>x(i)<U(i,)=*(x(i))endendforj=:length(y)fori=:length(x)U(i,j)=U(i,j)la*(U(i,j)*U(i,j)U(i,j))endendA=U(:,size(U,))functionu=jiexijie(x,t)fori=:size(x,)k=a=((^)*sin(*pi)*sin(*pi*x(i))*exp(^*pi^*t))a=a((^)*sin(*pi)*sin(*pi*x(i))*exp(^*pi^*t))whileabs(aa)>a=aa=a((k^)*sin(k*pi)*sin(k*pi*x(i))*exp(k^*pi^*t))k=kendu(i)=(pi^)*aendclc第题第问cleart=t=t=x=::y=::ty=::ty=::tla=subplot()A=zhongxinchafen(x,y,la)u=jiexijie(x,t)line(x,A,'color','r','linestyle',':','linewidth',)holdonline(x,u,'color','b','linewidth',)A=zhongxinchafen(x,y,la)u=jiexijie(x,t)line(x,A,'color','r','linestyle',':','linewidth',)line(x,u,'color','b','lineon格式完成例的所有任务。CrankNicolson,格式解:nnuu,ajjnnnnnn()(),,,,uuuuuujjjjjj,,,hn将第层和第层放到等式两端得naaaaaannnnnn,,,,uuuuuu()()jjjjjj,,,,hhhhhh,,lah,,,,*h(在程序中用表示)为时间步长为空间步长(在,,h程序中用来表示)dtdx,a,化简:左右两边同时乘以得:nnnnnn,a,uauauauauau,,,()(),,,,,jjjjjj,,程序:functionA=granknicolson(x,y,la,a)U=zeros(size(x,),size(y,))fori=:size(x,)ifx(i)>x(i)<=U(i,)=*x(i)elseifx(i)>x(i)<U(i,)=*(x(i))endendx=::V=zeros(size(x,))V=zeros(size(x,))fori=:size(x,)forj=:size(x,)ifi==jV(i,j)=*a*laV(i,j)=*a*laelseifi==j|j==iV(i,j)=a*laV(i,j)=a*laendendendforj=:size(y,)U(:size(x,),j)=inv(V)*V*U(:size(x,),j)endA=U(:,size(U,))functionu=jiexijie(x,t)fori=:size(x,)k=a=((^)*sin(*pi)*sin(*pi*x(i))*exp(^*pi^*t))a=a((^)*sin(*pi)*sin(*pi*x(i))*exp(^*pi^*t))whileabs(aa)>a=aa=a((k^)*sin(k*pi)*sin(k*pi*x(i))*exp(k^*pi^*t))k=kendu(i)=(pi^)*aendclc第题第问cleart=t=t=x=::y=::ty=::ty=::tla=a=subplot()A=granknicolson(x,y,la,a)u=jiexijie(x,t)line(x,A,'color','r','linestyle',':','linewidth',)holdonline(x,u,'color','b','linewidth',)A=granknicolson(x,y,la,a)u=jiexijie(x,t)line(x,A,'color','r','linestyle',':','linewidth',)line(x,u,'color','b','linewidth',)A=granknicolson(x,y,la,a)u=jiexijie(x,t)line(x,A,'color','r','linestyle',':','linewidth',)line(x,u,'color','b','linewidth',)title('例()')subplot()line(x,u,'color','b','linewidth',)line(x,u,'color','b','linewidth',)line(x,u,'color','b','linewidth',)title('解析解')subplot()line(x,A,'color','r','linestyle',':','linewidth',)line(x,A,'color','r','linestyle',':','linewidth',)line(x,A,'color','r','linestyle',':','linewidth',)title('数值解')clc第题第问cleart=t=t=x=::y=::ty=::ty=::tla=a=subplot()A=granknicolson(x,y,la,a)u=jiexijie(x,t)line(x,A,'color','r','linestyle',':','linewidth',)holdonline(x,u,'color','b','linewidth',)A=granknicolson(x,y,la,a)u=jiexijie(x,t)line(x,A,'color','r','linestyle',':','linewidth',)line(x,u,'color','b','linewidth',)A=granknicolson(x,y,la,a)u=jiexijie(x,t)line(x,A,'color','r','linestyle',':','linewidth',)line(x,u,'color','b','linewidth',)title('例()')subplot()line(x,u,'color','b','linewidth',)line(x,u,'color','b','linewidth',)line(x,u,'color','b','linewidth',)title('解析解')subplot()line(x,A,'color','r','linestyle',':','linewidth',)line(x,A,'color','r','linestyle',':','linewidth',)line(x,A,'color','r','linestyle',':','linewidth',)title('数值解')clc第题第问cleart=t=t=x=::y=::ty=::ty=::tla=a=subplot()A=granknicolson(x,y,la,a)u=jiexijie(x,t)line(x,A,'color','r','linestyle',':','linewidth',)holdonline(x,u,'color','b','linewidth',)A=granknicolson(x,y,la,a)u=jiexijie(x,t)line(x,A,'color','r','linestyle',':','linewidth',)line(x,u,'color','b','linewidth',)A=granknicolson(x,y,la,a)u=jiexijie(x,t)line(x,A,'color','r','linestyle',':','linewidth',)line(x,u,'color','b','linewidth',)title('例()')subplot()line(x,u,'color','b','linewidth',)line(x,u,'color','b','linewidth',)line(x,u,'color','b','linewidth',)title('解析解')subplot()line(x,A,'color','r','linestyle',':','linewidth',)line(x,A,'color','r','linestyle',':','linewidth',)line(x,A,'color','r','linestyle',':','linewidth',)title('数值解')运行结果:表:取时刻的解析解与CrankNicolson格式数值解,,,x,,,t,,,,时间(t)解析解数值解时间(t)解析解数值解时间(t)解析解数值解t,t,t,表:取时刻的解析解与CrankNicolson格式数值解,,,x,,,t,,,,时间(t)解析解数值解时间(t)解析解数值解时间(t)解析解数值解t,t,t,表:取时刻的解析解与CrankNicolson格式数值解,,,x,,,t,,,,时间(t)解析解数值解时间(t)解析解数值解时间(t)解析解数值解t,t,t,,,,x,,,t,,,,图:取时刻的解析解与CrankNicolson格式数值解图:取时刻的解析解与CrankNicolson格式数值解,,,x,,,t,,,,图:取时刻的解析解与CrankNicolson格式数值解,,,x,,,t,,,,uuxt,,,,(,),,txx,uxx(,),(,),,,,,u,,ut,例数值求解初边值问题,x,,xx,,,,u,,,ut,,x,,xx,,要求边界条件离散采用()向前(后)一阶差商代替微商。()中心差商(二阶)代替微商。t,nnnnn数值格式仍采用uuuuu,,,(),,jjjjj,()x,这里取计算,,,x,,,t,,,,,,,,,,,,sec,,,tnn注:本例的解析解为uxtexx(,)cos(()),(,),,,,,,,n,n,n,,其中是,,,的正根。tan,n解:程序:functionA=yijiechashang(x,y,la)U=zeros(length(x),length(y))fori=:length(x)U(i,)=endU(,)=U(,)U(length(x),)=U(length(x),)forj=:length(y)fori=:length(x)U(i,j)=U(i,j)la*(U(i,j)*U(i,j)U(i,j))U(,j)=U(,j)U(length(x),j)=U(length(x),j)endendA=U(:,size(U,))functionu=jiexijie(x,t,d)r=zhenggen(d)fori=:length(x)k=a=exp(*r()^*t)*cos(*r()*(x(i)))((*r()^)*cos(r()))a=aexp(*r()^*t)*cos(*r()*(x(i)))((*r()^)*cos(r()))whileabs(aa)>a=aa=aexp(*r(k)^*t)*cos(*r(k)*(x(i)))((*r(k)^)*cos(r(k)))k=kendu(i)=*aendclc第题第问cleart=t=t=t=t=t=t=t=t=la=x=::y=::ty=::ty=::ty=::ty=::ty=::ty=::ty=::ty=::td=::A=yijiechashang(x,y,la)u=jiexijie(x,t,d)A=yijiechashang(x,y,la)u=jiexijie(x,t,d)A=yijiechashang(x,y,la)u=jiexijie(x,t,d)A=yijiechashang(x,y,la)u=jiexijie(x,t,d)A=yijiechashang(x,y,la)u=jiexijie(x,t,d)A=yijiechashang(x,y,la)u=jiexijie(x,t,d)A=yijiechashang(x,y,la)u=jiexijie(x,t,d)A=yijiechashang(x,y,la)u=jiexijie(x,t,d)A=yijiechashang(x,y,la)u=jiexijie(x,t,d)subplot()line(x,A,'color','r','linestyle',':','linewidth',)holdonline(x,u,'color','b','linewidth',)line(x,A,'color','r','linestyle',':','linewidth',)line(x,u,'color','b','linewidth',)line(x,A,'color','r','linestyle',':','linewidth',)line(x,u,'color','b','linewidth',)line(x,A,'color','r','linestyle',':','linewidth',)line(x,u,'color','b','linewidth',)title('例()')legend('数值解','解析解')subplot()line(x,A,'color','r','linestyle',':','linewidth',)line(x,u,'color','b','linewidth',)line(x,A,'color','r','linestyle',':','linewidth',)line(x,u,'color','b','linewidth',)line(x,A,'color','r','linestyle',':','linewidth',)line(x,u,'color','b','linewidth',)line(x,A,'color','r','linestyle',':','linewidth',)line(x,u,'color','b','linewidth',)line(x,A,'color','r','linestyle',':','linewidth',)line(x,u,'color','b','linewidth',)legend('数值解','解析解')clc第题第问cleart=t=t=t=t=t=t=t=t=la=x=::y=::ty=::ty=::ty=::ty=::ty=::ty=::ty=::ty=::td=::A=zhongxinchafen(x,y,la)u=jiexijie(x,t,d)A=zhongxinchafen(x,y,la)u=jiexijie(x,t,d)A=zhongxinchafen(x,y,la)u=jiexijie(x,t,d)A=zhongxinchafen(x,y,la)u=jiexijie(x,t,d)A=zhongxinchafen(x,y,la)u=jiexijie(x,t,d)A=zhongxinchafen(x,y,la)u=jiexijie(x,t,d)A=zhongxinchafen(x,y,la)u=jiexijie(x,t,d)A=zhongxinchafen(x,y,la)u=jiexijie(x,t,d)A=zhongxinchafen(x,y,la)u=jiexijie(x,t,d)subplot()line(x,A,'color','r','linestyle',':','linewidth',)holdonline(x,u,'color','b','linewidth',)line(x,A,'color','r','linestyle',':','linewidth',)line(x,u,'color','b','linewidth',)line(x,A,'color','r','linestyle',':','linewidth',)line(x,u,'color','b','linewidth',)line(x,A,'color','r','linestyle',':','linewidth',)line(x,u,'color','b','linewidth',)title('例()')legend('数值解','解析解')subplot()line(x,A,'color','r','linestyle',':','linewidth',)line(x,u,'color','b','linewidth',)line(x,A,'color','r','linestyle',':','linewidth',)line(x,u,'color','b','linewidth',)line(x,A,'color','r','linestyle',':','linewidth',)line(x,u,'color','b','linewidth',)line(x,A,'color','r','linestyle',':','linewidth',)line(x,u,'color','b','linewidth',)line(x,A,'color','r','linestyle',':','linewidth',)line(x,u,'color','b','linewidth',)legend('数值解','解析解')运行结果:表:取用向前(后)一阶差商代替微商计算,,,x,,,时刻的解析解与数值解t,,,,,,,,,时间(t)解析解数值解时间解析解数值解时间(t)解析解数值解表:取用中心差商(二阶)代替微商计算,,,x,,,时刻的解析解与数值解t,,,,,,,,,时间(t)解析解数值解时间(t)解析解数值解时间(t)解析解数值解图:取用向前(后)一阶差商代替微商计算,,,x,,,t,,,,,,,,,时刻的解析解与数值解图:取用中心差商(二阶)代替微商计算,,,x,,,时刻的解析解与数值解t,,,,,,,,,例数值求解边值问题uaxtuxt,,,,,,,tx,当,,x,,ux(,),,,其它,,,u(,t)=,t,,x其中axtxt(,),,,,,xtxx要求采用下列方法计算:()迎风格式分别取时刻的数值解。,,,xt,,,,LaxFriedrichs,()格式完成()的计算。LaxWendroff,()格式完成()的计算。注:该初边值问题的解析解为tuxtux(,)(,),,x解:程序functionA=yingfenggeshi(x,y,la)fori=:length(x)forj=:length(y)a(i,j)=(x(i)^)(*x(i)*y(j)*x(i)^x(i)^)endendU=zeros(length(x),length(y))fori=:length(x)ifx(i)>=x(i)<=U(i,)=elseU(i,)=endendforj=:length(y)fori=:length(x)U(i,j)=(a(i,j)*la)*U(i,j)a(i,j)*la*U(i,j)endendA=U(:,size(U,))functionA=laxfriedrichs(x,y,la)fori=:length(x)forj=:length(y)a(i,j)=(x(i)^)(*x(i)*y(j)*x(i)^x(i)^)endendU=zeros(length(x),length(y))fori=:length(x)ifx(i)>=x(i)<=U(i,)=elseU(i,)=endendforj=:length(y)fori=:length(x)U(i,j)=(a(i,j)*la)*U(i,j)(a(i,j)*la)*U(i,j)endendA=U(:,size(U,))functionA=laxwendroff(x,y,la)fori=:length(x)forj=:length(y)a(i,j)=(x(i)^)(*x(i)*y(j)*x(i)^x(i)^)endendU=zeros(length(x),length(y))fori=:length(x)ifx(i)>=x(i)<=U(i,)=elseU(i,)=endendforj=:length(y)fori=:length(x)U(i,j)=U(i,j)a(i,j)*la*(U(i,j)U(i,j))a(i,j)^*la^*(U(i,j)*U(i,j)U(i,j))endendA=U(:,size(U,))functionu=jiexijie(x,t)fori=:length(x)ifx(i)t(x(i)^)>=x(i)t(x(i)^)<=u(i)=elseu(i)=endenduclc第题第问clearla=dx=dx=t=t=t=x=:dx:x=:dx:y=:dx*la:ty=:dx*la:ty=:dx*la:ty=:dx*la:ty=:dx*la:ty=:dx*la:tA=yingfenggeshi(x,y,la)u=jiexijie(x,t)A=yingfenggeshi(x,y,la)u=jiexijie(x,t)A=yingfenggeshi(x,y,la)u=jiexijie(x,t)A=yingfenggeshi(x,y,la)u=jiexijie(x,t)A=yingfenggeshi(x,y,la)u=jiexijie(x,t)A=yingfenggeshi(x,y,la)u=jiexijie(x,t)subplot()line(x,A,'color','r','linestyle',':','linewidth',)holdonline(x,A,'color','r','linestyle',':','linewidth',)line(x,A,'color','r','linestyle',':','linewidth',)line(x,u,'color','b','linewidth',)line(x,u,'color','b','linewidth',)line(x,u,'color','b','linewidth',)title('例yingfenggeshi')subplot()line(x,A,'color','r','linestyle',':','linewidth',)line(x,A,'color','r','linestyle',':','linewidth',)line(x,A,'color','r','linestyle',':','linewidth',)line(x,u,'color','b','linewidth',)line(x,u,'color','b','linewidth',)line(x,u,'color','b','linewidth',)title('例yingfenggeshi')clc第题第问clearla=dx=dx=t=t=t=X=:dx:X=:dx:y=:dx*la:ty=:dx*la:ty=:dx*la:ty=:dx*la:ty=:dx*la:ty=:dx*la:tx=:dx:(length(X)length(y))*dxx=:dx:(length(X)length(y))*dxx=:dx:(length(X)length(y))*dxx=:dx:(length(X)length(y))*dxx=:dx:(length(X)length(y))*dxx=:dx:(length(X)length(y))*dxA=laxfriedrichs(x,y,la)u=jiexijie(X,t)A=laxfriedrichs(x,y,la)u=jiexijie(X,t)A=laxfriedrichs(x,y,la)u=jiexijie(X,t)A=laxfriedrichs(x,y,la)u=jiexijie(X,t)A=laxfriedrichs(x,y,la)u=jiexijie(X,t)A=laxfriedrichs(x,y,la)u=jiexijie(X,t)subplot()line(X,A(:length(X)),'color','r','linestyle',':','linewidth',)holdonline(X,A(:length(X)),'color','r','linestyle',':','linewidth',)line(X,A(:length(X)),'color','r','linestyle',':','linewidth',)line(X,u(:length(X)),'color','b','linewidth',)line(X,u(:length(X)),'color','b','linewidth',)line(X,u(:length(X)),'color','b','linewidth',)title('例laxfriedrichs')subplot()line(X,A(:length(X)),'color','r','linestyle',':','linewidth',)line(X,A(:length(X)),'color','r','linestyle',':','linewidth',)line(X,A(:length(X)),'color','r','linestyle',':','linewidth',)line(X,u(:length(X)),'color','b','linewidth',)line(X,u(:length(X)),'color','b','linewidth',)line(X,u(:length(X)),'color','b','linewidth',)title('例laxfriedrichs')clc第题第问clearla=dx=dx=t=t=t=X=:dx:X=:dx:y=:dx*la:ty=:dx*la:ty=:dx*la:ty=:dx*la:ty=:dx*la:ty=:dx*la:tx=:dx:(length(X)length(y))*dxx=:dx:(length(X)length(y))*dxx=:dx:(length(X)length(y))*dxx=:dx:(length(X)length(y))*dxx=:dx:(length(X)length(y))*dxx=:dx:(length(X)length(y))*dxA=laxwendroff(x,y,la)u=jiexijie(X,t)A=laxwendroff(x,y,la)u=jiexijie(X,t)A=laxwendroff(x,y,la)u=jiexijie(X,t)A=laxwendroff(x,y,la)u=jiexijie(X,t)A=laxwendroff(x,y,la)u=jiexijie(X,t)A=laxwendroff(x,y,la)u=jiexijie(X,t)subplot()line(X,A(:length(X)),'color','r','linestyle',':','linewidth',)holdonline(X,A(:length(X)),'color','r','linestyle',':','linewidth',)line(X,A(:length(X)),'color','r','linestyle',':','linewidth',)line(X,u(:length(X)),'color','b','linewidth',)line(X,u(:length(X)),'color','b','linewidth',)line(X,u(:length(X)),'color','b','linewidth',)title('例laxwendroff')subplot()line(X,A(:length(X)),'color','r','linestyle',':','linewidth',)line(X,A(:length(X)),'color','r','linestyle',':','linewidth',)line(X,A(:length(X)),'color','r','linestyle',':','linewidth',)line(X,u(:length(X)),'color','b','linewidth',)line(X,u(:length(X)),'color','b','linewidth',)line(X,u(:length(X)),'color','b','linewidth',)title('例laxwendroff')运行结果:图:取时刻的解析解与yingfenggeshi数值解,,,x,,,t,,,,图:取时刻的解析解与yingfenggeshi数值解,,,x,,,t,,,,图:取时刻的解析解与laxfriedrichs数值解,,,x,,,t,,,,图:取时刻的解析解与laxfriedrichs数值解,,,x,,,t,,,,图:取时刻的解析解与laxwendroff数值解,,,x,,,t,,,,图:取时刻的解析解与laxwendroff数值解,,,x,,,t,,,,例数值求解边值问题uaxtuxt,,,,,,,tx,uxx(,)exp(()),,,,,u(,t)=,t,,xaxtxt(,),,,,,其中xtxx要求采用下列方法计算:,,,xt,,,,()迎风格式分别取时刻的数值解。LaxFriedrichs,()格式完成()的计算。LaxWendroff,()格式完成()的计算。注:该初边值问题的解析解为tuxtux(,)(,),,x解:程序:functionA=yingfenggeshi(x,y,la)fori=:length(x)forj=:length(y)a(i,j)=(x(i)^)(*x(i)*y(j)*x(i)^x(i)^)endendU=zeros(length(x),length(y))fori=:length(x)U(i,)=exp(*(*x(i)^)^)endforj=:length(y)fori=:length(x)U(i,j)=(a(i,j)*la)*U(i,j)a(i,j)*la*U(i,j)endendA=U(:,size(U,))functionA=laxfriedrichs(x,y,la)fori=:length(x)forj=:length(y)a(i,j)=(x(i)^)(*x(i)*y(j)*x(i)^x(i)^)endendU=zeros(length(x),length(y))fori=:length(x)U(i,)=exp(*(*x(i)^)^)endforj=:length(y)fori=:length(x)U(i,j)=(a(i,j)*la)*U(i,j)(a(i,j)*la)*U(i,j)endendA=U(:,size(U,))functionA=laxwendroff(x,y,la)fori=:length(x)forj=:length(y)a(i,j)=(x(i)^)(*x(i)*y(j)*x(i)^x(i)^)endendU=zeros(length(x),length(y))fori=:length(x)U(i,)=exp(*(*x(i)^)^)endforj=:length(y)fori=:length(x)U(i,j)=U(i,j)a(i,j)*la*(U(i,j)U(i,j))a(i,j)^*la^*(U(i,j)*U(i,j)U(i,j))endendA=U(:,size(U,))clc第题第问clearla=dx=dx=t=t=t=x=:dx:x=:dx:y=:dx*la:ty=:dx*la:ty=:dx*la:ty=:dx*la:ty=:dx*la:ty=:dx*la:tA=yingfenggeshi(x,y,la)u=jiexijie(x,t)A=yingfenggeshi(x,y,la)u=jiexijie(x,t)A=yingfenggeshi(x,y,la)u=jiexijie(x,t)A=yingfenggeshi(x,y,la)u=jiexijie(x,t)A=yingfenggeshi(x,y,la)u=jiexijie(x,t)A=yingfenggeshi(x,y,la)u=jiexijie(x,t)subplot()line(x,A,'color','r','linestyle',':','linewidth',)holdonline(x,A,'color','r','linestyle',':','linewidth',)line(x,A,'color','r','linestyle',':','linewidth',)line(x,u,'color','b','linewidth',)line(x,u,'color','b','linewidth',)line(x,u,'color','b','linewidth',)title('例yingfenggeshi')subplot()line(x,A,'color','r','linestyle',':','linewidth',)line(x,A,'color','r','linestyle',':','linewidth',)line(x,A,'color','r','linestyle',':','linewidth',)line(x,u,'color','b','linewidth',)line(x,u,'color','b','linewidth',)line(x,u,'color','b','linewidth',)title('例yingfenggeshi')clc第题第问clearla=dx=dx=t=t=t=X=:dx:X=:dx:y=:dx*la:ty=:dx*la:ty=:dx*la:ty=:dx*la:ty=:dx*la:ty=:dx*la:tx=:dx:(length(X)length(y))*dxx=:dx:(length(X)length(y))*dxx=:dx:(length(X)length(y))*dxx=:dx:(length(X)length(y))*dxx=:dx:(length(X)length(y))*dxx=:dx:(length(X)length(y))*dxA=laxfriedrichs(x,y,la)u=jiexijie(X,t)A=laxfriedrichs(x,y,la)u=jiexijie(X,t)A=laxfriedrichs(x,y,la)u=jiexijie(X,t)A=laxfriedrichs(x,y,la)u=jiexijie(X,t)A=laxfriedrichs(x,y,la)u=jiexijie(X,t)A=laxfriedrichs(x,y,la)u=jiexijie(X,t)subplot()line(X,A(:length(X)),'color','r','linestyle',':','linewidth',)holdonline(X,A(:length(X)),'color','r','linestyle',':','linewidth',)line(X,A(:length(X)),'color','r','linestyle',':','linewidth',)line(X,u(:length(X)),'color','b','linewidth',)line(X,u(:length(X)),'color','b','linewidth',)line(X,u(:length(X)),'color','b','linewidth',)title('例laxfriedrichs')subplot()line(X,A(:length(X)),'color','r','linestyle',':','linewidth',)line(X,A(:length(X)),'color','r','linestyle',':','linewidth',)line(X,A(:length(X)),'color','r','linestyle',':','linewidth',)line(X,u(:length(X)),'color','b','linewidth',)line(X,u(:length(X)),'color','b','linewidth',)line(X,u(:length(X)),'color','b','linewidth',)title('例laxfriedrichs')clc第题第问clearla=dx=dx=t=t=t=X=:dx:X=:dx:y=:dx*la:ty=:dx*la:ty=:dx*la:ty=:dx*la:ty=:dx*la:ty=:dx*la:tx=:dx:(length(X)length(y))*dxx=:dx:(length(X)length(y))*dxx=:dx:(length(X)length(y))*dxx=:dx:(length(X)length(y))*dxx=:dx:(length(X)length(y))*dxx=:dx:(length(X)length(y))*dxA=laxwendroff(x,y,la)u=jiexijie(X,t)A=laxwendroff(x,y,la)u=jiexijie(X,t)A=laxwendroff(x,y,la)u=jiexijie(X,t)A=laxwendroff(x,y,la)u=jiexijie(X,t)A=laxwendroff(x,y,la)u=jiexijie(X,t)A=laxwendroff(x,y,la)u=jiexijie(X,t)subplot()line(X,A(:length(X)),'color','r','linestyle',':','linewidth',)holdonline(X,A(:length(X)),'color','r','linestyle',':','linewidth',)line(X,A(:length(X)),'color','r','linestyle',':','linewidth',)line(X,u(:length(X)),'color','b','linewidth',)line(X,u(:length(X)),'color','b','linewidth',)line(X,u(:length(X)),'color','b','linewidth',)title('例laxwendroff')subplot()line(X,A(:length(X)),'color','r','linestyle',':','linewidth',)line(X,A(:length(X)),'color','r','linestyle',':','linewidth',)line(X,A(:length(X)),'color','r','linestyle',':','linewidth',)line(X,u(:length(X)),'color','b','linewidth',)line(X,u(:length(X)),'color','b','linewidth',)line(X,u(:length(X)),'color','b','linewidth',)title('例laxwendroff')、运行结果:图:取,,,x,,,,t,,,,时刻的解析解与yingfenggesh数值解图:取时刻的解析解与laxfriedrichs数值解,,,x,,,,t,,,,图:取时刻的解析解与laxwendroff数值解,,,x,,,,t,,,,,uuxRt,,,(),,,tx例问题,,uxxxR,,,,(,)exp(()),,LaxFriedrichs,LaxWendroff,试用迎风格式格式格式计算该问题在t,,时刻的数值解。uxtuxtuxt(,)((,)),,注:解析解为解:程序:functionA=yingfenggeshi(x,y,la)U=zeros(length(x),length(y))fori=:length(x)U(i,)=exp(*(*x(i)^)^)endforj=:length(y)fori=:length(x)U(i,j)=U(i,j)la*(U(i,j)^U(i,j)^)endendA=U(:,size(U,))functionA=laxfriedrichs(x,y,la)U=zeros(length(x),length(y))fori=:length(x)U(i,)=exp(*(*x(i)^)^)endforj=:length(y)fori=:length(x)U(i,j)=(U(i,j)U(i,j))la*(U(i,j)^U(i,j)^)endendA=U(:,size(U,))functionA=laxwendroff(x,y,la)fori=:length(x)U(i,)=exp(*(*x(i)^)^)endforj=:length(y)fori=:length(x)U(i,j)=U(i,j)la*(U(i,j)^U(i,j)^)la^*(U(i,j)U(i,j))*(U(i,j)^U(i,j)^)la^*(U(i,j)U(i,j))*(U(i,j)^U(i,j)^)endendA=U(:,size(U,))functionu=jiexijie(x,t)u()=fori=:length(x)u(i)=exp(*(*(x(i)t*u(i))^)^)endclc第题第问clearla=t=t=x=::x=::y=:*la:ty=:*la:ty=:*la:ty=:*la:tA=yingfenggeshi(x,y,la)u=jiexijie(x,t)A=yingfenggeshi(x,y,la)u=jiexijie(x,t)A=yingfenggeshi(x,y,la)u=jiexijie(x,t)A=yingfenggeshi(x,y,la)u=jiexijie(x,t)subplot()title('dx=,t=')line(x,A,'color','r','linestyle',':','linewidth',)holdonline(x,u,'color','b','linewidth',)subplot()line(x,A,'color','r','linestyle',':','linewidth',)line(x,u,'color','b','linewidth',)title('dx=,t=')figuresubplot()title('dx=,t=')line(x,A,'color','r','linestyle',':','linewidth',)line(x,u,'color','b','linewidth',)subplot()line(x,A,'color','r','linestyle',':','linewidth',)line(x,u,'color','b','linewidth',)title('dx=,t=')clc第题第问clearla=t=t=x=::x=::y=:*la:ty=:*la:ty=:*la:ty=:*la:tA=laxfriedrichs(x,y,la)A=laxfriedrichs(x,y,la)A=laxfriedrichs(x,y,la)A=laxfriedrichs(x,y,la)u=jiexijie(x,t)u=jiexijie(x,t)u=jiexijie(x,t)u=jiexijie(x,t)subplot()title('dx=,t=')line(x,A,'color','r','linestyle',':','linewidth',)holdonline(x,u,'color','b','linewidth',)subplot()line(x,A,'color','r','linestyle',':','linewidth',)line(x,u,'color','b','linewidth',)title('dx=,t=')figuresubplot()title('dx=,t=')line(x,A,'color','r','linestyle',':','linewidth',)line(x,u,'color','b','linewidth',)subplot()line(x,A,'color','r','linestyle',':','linewidth',)line(x,u,'color','b','linewidth',)title('dx=,t=')clc第题第问clearla=t=t=x=::x=::y=:*la:ty=:*la:ty=:*la:ty=:*la:tA=laxwendroff(x,y,la)A=laxwendroff(x,y,la)A=laxwendroff(x,y,la)A=laxwendroff(x,y,la)u=jiexijie(x,t)u=jiexijie(x,t)u=jiexijie(x,t)u=jiexijie(x,t)subplot()title('dx=,t=')line(x,A,'color','r','linestyle',':','linewidth',)holdonline(x,u,'color','b','linewidth',)subplot()line(x,A,'color','r','linestyle',':','linewidth',)line(x,u,'color','b','linewidth',)title('dx=,t=')figuresubplot()title('dx=,t=')line(x,A,'color','r','linestyle',':','linewidth',)line(x,u,'color','b','linewidth',)subplot()line(x,A,'color','r','linestyle',':','linewidth',)line(x,u,'color','b','linewidth',)title('dx=,t=')运行结果:图:取时刻的解析解与yingfenggesh数值解,,,x,,t,,图:取时刻的解析解与yingfenggesh数值解,,,x,,t,,图:取时刻的解析解与laxfriedrichs数值解,,,x,,t,,图:取时刻的解析解与laxfriedrichs数值解,,,x,,t,,图:取时刻的解析解与laxwendroff数值解,,,x,,t,,图:取时刻的解析解与laxwendroff数值解,,,x,,t,,全部程序完

用户评价(0)

关闭

新课改视野下建构高中语文教学实验成果报告(32KB)

抱歉,积分不足下载失败,请稍后再试!

提示

试读已结束,如需要继续阅读或者下载,敬请购买!

文档小程序码

使用微信“扫一扫”扫码寻找文档

1

打开微信

2

扫描小程序码

3

发布寻找信息

4

等待寻找结果

我知道了
评分:

/52

偏微分方程数值解法题解

VIP

在线
客服

免费
邮箱

爱问共享资料服务号

扫描关注领取更多福利