没有合适的资源?快使用搜索试试~ 我知道了~
nde_lab2.pdf
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 140 浏览量
2023-06-18
13:14:51
上传
评论
收藏 113KB PDF 举报
温馨提示
试读
4页
nde_lab2.pdf
资源推荐
资源详情
资源评论
Computer Lab Assignment # 2
Writing a Library of Explicit Runge-Kutta Methods
Lab: Wednesday, 9/11 Due: 8:30 a.m., Wednesday, 9/18
Submit write up, code and any auxiliary files to Dave Witman, dw11d@my.fsu.edu
Goals: In this lab we want to write a set of explicit Runge Kutta (RK) routines which
serve as a “stand alone” library that can be accessed through a calling program. The idea
is to write and test the routines which are in a single file and then never modify them;
essentially they will be treated as “private” routines that the user does not have access to.
Before writing this library you are first asked to implement several RK methods to make
sure you know how to this. Then you will generalize your routines for any explicit RK
method.
A general s-stage explicit RK method is written as
k
1
= ∆tf(t
i
, Y
i
)
k
2
= ∆tf(t
i
+ c
2
∆t, Y
i
+ a
21
k
1
)
k
3
= ∆tf(t
i
+ c
3
∆t, Y
i
+ a
31
k
1
+ a
32
k
2
)
.
.
.
k
s
= ∆tf(t
i
+ c
s
∆t, Y
i
+ a
s1
k
1
+ a
s2
k
2
+ · · · + a
ss−1
k
s−1
Y
i+1
= Y
i
+
s
X
j=1
b
j
k
j
.
The first stage explicit RK method is the forward Euler method with b
1
= 1 and all other
coefficients zero.
1. In the notes in section 2.2 we derived the Midpoint method which is given by
k
1
= ∆tf(t
i
, Y
i
)
k
2
= ∆tf(t
i
+
∆t
2
, Y
i
+
1
2
k
1
)
Y
i+1
= Y
i
+ k
2
which is a 2-stage RK method. Note that here c
2
= 1/2, a
21
= 1/2 and b
1
= 0, b
2
= 1;
all other coefficients are zero. Write a routine to incorporate the Midpoint method. Write
the routine so that (i) you input the coefficients, store b
i
in a vector; (ii) at each time step
compute the two values k
1
and k
2
and store them in a vector
~
k ; (iii) to compute Y
i+1
take
the dot product of
~
b and
~
k; (iv) write a separate function routine for f(t, y), i.e., don’t
“hardwire” in a specific choice for f.
1
资源评论
卷积神经网络
- 粉丝: 339
- 资源: 8460
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功