微分方程数值解实验报告.doc
文本预览下载声明
湖南工程学院 微分方程数值解法实验报告
专业班级 姓名 学号 同组实验人员 信息与计算科学1101 王珍 09
实验日期 2014年5 月6日 第 1次实验 指导老师 杨继明 评分 实验名称 用欧拉方法解常微分方程的初值问题 实验目的 熟悉掌握常微分方程的初值问题的数值格式并程序实现 考虑下列常微分方程的初值问题:
采用欧拉方法求解初值问题
采用Matlab程序设计语言编程实现该问题的数值求解。
在Matlab命令窗口中输入命令:
E=euler(0,1,1,20)
运行程序得到实验结果为:
E =
0 1.00000000000000
0.05000000000000 0.75000000000000
0.10000000000000 0.56250000000000
0.15000000000000 0.42187500000000
0.20000000000000 0.31640625000000
0.25000000000000 0.23730468750000
0.30000000000000 0.17797851562500
0.35000000000000 0.13348388671875
0.40000000000000 0.10011291503906
0.45000000000000 0.07508468627930
0.50000000000000 0.05631351470947
0.55000000000000 0.04223513603210
附Matlab程序代码:
function E=euler(a,b,ya,M)
%Input - y=f is the function
% - a and b are the left and right endpoints
% - ya is the initial condition y(a)
% - M is the number of steps
%Output - E=[T Y] where T is the vector of abscissas and
% - Y is the vector of ordinates
%If f is defined as an M-file function use the @ notation
% call E=euler(@f,a,b,ya,M).
%If f is defined as an anonymous function use the
% call E=euler(f,a,b,ya,M).
h=(b-a)/M;
T=zeros(1,M+1);
Y=zeros(1,M+1);
T=a:h:b;
Y(1)=ya;
for j=1:M
Y(j+1)=Y(j)+h*f(T(j),Y(j));
end
E=[T Y];
function f=f(t,y)
f=-5*y;
指导教师评语:
签字:
年 月 日
实验日期 2014年5 月6日 第 2次实验 指导老师 杨继明 评分 实验名称 利用peYF格式计算近似解 实验目的 熟悉掌握常微分方程的初值问题的数值格式并程序实现 考虑下列常微分方程的初值问题:
其精确解为
采用Matlab程序设计语言编程实现该问题的数值求解。
在Matlab命令窗口中输入命令:
u = peYF(-2,0.02,11,0,1,5)
运行程序得到实验结果为:
u =
Columns 1 through 4
1.74530439815628 1.75031196341828 1.46872586082017 1.00810241079480
Columns 5 through 8
0.54438411523664 0.25469560184372 0.24968803658172 0.53127413917983
Columns 9 through 11
0.99189758920520 1.45561588476336
显示全部