首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
讲解MATH0033编程、辅导Matlab程序语言、Matlab程序设计调试 调试C/C++编程|解析Haskell程序
项目预算:
开发周期:
发布时间:
要求地区:
MATH0033 Numerical Methods, 2020-2021, David Hewett
Computational homework 3
Differential equations
Exercises 1 and 2(a)-(e) (marked *) to be handed in and assessed
Deadline: 2200 GMT Sunday 10th January.
Please submit your solutions using the link on the course Moodle page.
You should submit a single pdf file, created using the Matlab publish
command, formatted as per the template provided on the Moodle page.
EXERCISE 1* Consider the initial value problem,
the exact solution of which is y(t) = tanh t = (e2t − 1)/(e2t + 1).
(a) Compute numerical solutions to the initial value problem using the forward Euler method
with equally spaced points tn = n
20
N
, n = 0, . . . , N, for N = 19, 21, 40, 80 and 160.
Produce a plot comparing the numerical solutions with the exact solution.
For each choice of N compute the error maxn=0,...,N |un − y(tn)| and store these errors in
an array efe. Also, compute and store the error |uN − y(20)| at the end of the interval.
(b) Same as a) but using Heun’s method, to compute errors eheun.
(c) Produce a loglog plot of efe and eheun against the relevant N values and use your results
to read off the approximate convergence orders for the two methods. How do these
compare to the theory from lectures? (Hint: follow the approach we used in computational
homework 2)
(d) The exact solution y(t) has a horizontal asymptote y(t) → 1 as t → ∞. Does every approximation
obtained using the methods above reproduce the same asymptotic behaviour?
How well is the value of y(20) approximated?
Guided by the theory from lectures, but considering only the maximum value of |fy| on
the solution trajectory (rather than over all (t, y) ∈ R+ ×R), we might expect the critical
value of h below which the methods are stable to be h = 1. Is this what you observe in
your numerical results?
How does the lack of stability for N = 19 (h = 20/19 > 1) manifest itself for the two
different methods (forward Euler and Heun)?
1
EXERCISE 2 In this exercise we bring together some of the techniques we have studied in
the course to solve an initial boundary value problem (IBVP) involving a parabolic partial
differential equation, the heat equation.
The problem is: given T > 0 find u : [0, 1] × [0, T] 7→ R such that
∂u
∂t (x, t) −
∂
2u
∂x2
(x, t) = 1 in [0, 1] × [0, T], (1)
with u(0, t) = u(1, t) = 0 for all t ∈ [0, T] and u(x, 0) = sin(πx) + 1
2
x(1 − x). This problem is
a simple model for the evolution of the temperature distribution u in a metal bar undergoing
uniform heating, starting from an initial temperature distribution u(x, 0), where the bar is
held at constant (zero) temperature at its endpoints. For reference, the exact solution to this
problem is given by
u(x) = e
−π
2
t
sin(πx) + 1
2
x(1 − x).
To solve the IBVP numerically we will use the so-called method of lines. This involves
discretizing the spatial differential operator ∂
2u/∂x2
in the same way for all times t, so that
the IBVP becomes a finite-dimensional system of ordinary differential equations in t, which
can then be solved using a time-stepping scheme such as forward Euler, backward Euler
or Crank-Nicolson. For the spatial discretization we shall use a standard finite difference
approximation. Given N > 0, define equally spaced nodes 0 = x0 < x1 < . . . < xN = 1 on
the interval [0, 1] by xn = nh, n = 0, . . . , N, where h = 1/N. For a function u(x, t) we denote
the approximation of u(xn, t) by un(t), and we replace the second derivative ∂
2u/∂x2
(x, t) by
the finite difference formula (cf. theoretical exercise sheet 1)
D2un(t) := un+1(t) − 2un(t) + un−1(t)
h
2
.
This approximation turns the IBVP into an IVP involving a system of ordinary differential
equations satisfied by the functions un(t), n = 1, . . . , N − 1. Explicitly, we obtain the system
du
dt (t) = f(t, u(t)) = −Au + b, t ∈ [0, T], (2)
where u = (u1, . . . , uN−1)
T
, and, for a given N > 0, the matrix A and vector b can be
obtained in Matlab using the commands
>> h = 1./N;
>> A= (2/h^2)*diag(ones(N-1,1)) - (1/h^2)*diag(ones(N-2,1),1)...
- (1/h^2)*diag(ones(N-2,1),-1);
>> b = ones((N-1),1);
(a)* Consider the temporal discretization of the IVP system (2) using the forward Euler
method, the backward Euler method and Crank-Nicolson method, on a time mesh 0 =
t0 < t1 < . . . < tM = T, where M is the number of subintervals and tm = mk, m =
0, . . . , M, where k = T /M is the (uniform) temporal step size. (Note that I am using
k as the temporal step size and h as the spatial step size - don’t confuse the two!)
is the numerical approximation to u(xn, tm).
For each of the three methods write down the recurrence relation (in terms of the matrix
A) that has to be solved at each timestep to determine u
m+1 from u
m.
2
(b)* Now write a Matlab code which implements the three methods.
Hint: For the two implicit methods you need to solve a linear system at each timestep. For
simplicity I suggest you use Matlab’s backslash command, which calls a general-purpose
direct method. But you should be aware that in large-scale simulations one would use
either a special direct solver like the Thomas algorithm, or an iterative solver.
Note: I am suggesting that you implement the recurrence relations directly in your code,
rather than using the function files feuler.m etc. that I supplied. If you want to use the
latter, be warned that these codes only work for scalar problems, so you would need to
modify them appropriately to work for systems.
Run your code with the parameter choices N = 40 (giving a spatial step length h = 1/40),
k = h, and T = 0.2. Produce three plots (one for each method) showing the initial solution
and the solution at all of the time steps up to and including the final time T = 0.2 (on
the same axes, using the hold on command). Produce a further plot showing snapshots
of the exact solution at the same time steps.
What can be said qualitatively about the performance of the three methods, just by
studying your plots?
Hint: For forward Euler I suggest using the ylim command to adjust the vertical scale as
you see fit. The “vertical zoom” feature of the Matlab plot window is also helpful.
represent approximations to the exact solution u(x, t) on the INTERIOR spatial grid
points x1, . . . , xN−1.
N = 0 to each end of these vectors so you can plot on the whole spatial
interval [0, 1].
(c)* For each of the three methods, and for each N ∈ {10, 20, 40, 80, 160}, compute the rootmean-squared
error of the numerical approximation at the final time T = 0.2 using the
formula
E =
vuuth
N
X−1
n=1
(uMn − u(xn, T))2,
where, as above, u
m
n denotes the approximation at time step m and in space node n, and
u(x, t) is the exact solution stated at the start of the question. As in part (b), use a time
step k equal to h.
Visualize your results on a loglog plot and, for the methods that converge, determine
the approximate order of convergence p for which E ≈ Chp
for some C > 0. (Hint: follow
the approach we used in computational homework 2)
(Bonus unassessed theoretical question: why do we include the scaling factor h inside the
square root in the definition of E?)
(d)*Now remove the assumption that h = k and, by varying h and k appropriately, investigate
the convergence order of the two implicit methods (backward Euler and Crank-Nicolson)
in the joint limit h → 0 and k → 0. That is, for each method determine constants p and
q for which the root-mean-squared error at T = 0.2 satisfies, for some C > 0, the bound
E ≤ C(h
p + k
q
).
Hint: to determine p, fix k and vary h, with k very small compared to all your values of h,
so that h
p dominates the bound. For instance, you could try M = 6400 and N = 10, 20, 40.
To determine q you would do the opposite: fix h very small compared to k (e.g. N = 640
and M = 8, 16, 32), so that k
q dominates the bound.
3
(e)* Now return to the forward Euler method. In lectures we proved that the matrix A is
symmetric positive definite, so that all its eigenvalues are real and positive. For N =
[10, 20, 40, 80, 160, 320] compute the eigenvalues of A using the eig command, and make
a precise conjecture about the behaviour of the maximum and minimum eigenvalues λmin
and λmax as the spatial step size h tends to zero.
Using your results, determine a condition on the temporal step size k of the form k ≤ Chp
for some C > 0 and p ≥ 1 (which you should specify), which ensures that the forward
Euler method is stable. (You will need to consider the spectral radius of the matrix
I − kA.)
Verify that your stability criterion is correct by redoing your computations in (c) for the
forward Euler method, using your new stability criterion to choose k rather than setting
k = h. What convergence order do you observe as h → 0?
which can be approximated in Matlab using (provided N − 1 is divisible by 3)
>> u0=[zeros((N-1)/3,1);ones((N-1)/3,1);zeros((N-1)/3,1)];
Let N = 22 and solve for one timestep, taking the timestep k equal to 1/N, using the
forward and backward Euler methods and the Crank-Nicolson method. Repeat using the
timesteps 1/(10N) and 1/(50N). Plot the approximations obtained and comment on the
results.
(g) (Bonus unassessed theoretical question!) At the start of the question I gave you an
analytical solution of the IVBP. Can you prove that this solution is the only solution? That
is, that the solution of (1) is unique? Hint: Try using the following “energy argument”.
Suppose that the IBVP has two solutions u1 and u2. Show that the difference v = u1 − u2
satisfies the same IBVP, but with zero right-hand side and zero initial data. Using this
fact, along with integration by parts, show that the energy E(t) = (1/2) R 1
0
(v(t, x))2 dx
is a non-increasing function of t. Since E(0) = 0, deduce that E(t) = 0 for all t, and
conclude that v = 0, i.e. u1 = u2. You may assume that u1 and u2 are both continuous
functions of x.
4
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代做 program、代写 c++设计程...
2024-12-23
comp2012j 代写、代做 java 设...
2024-12-23
代做 data 编程、代写 python/...
2024-12-23
代做en.553.413-613 applied s...
2024-12-23
代做steady-state analvsis代做...
2024-12-23
代写photo essay of a deciduo...
2024-12-23
代写gpa analyzer调试c/c++语言
2024-12-23
代做comp 330 (fall 2024): as...
2024-12-23
代写pstat 160a fall 2024 - a...
2024-12-23
代做pstat 160a: stochastic p...
2024-12-23
代做7ssgn110 environmental d...
2024-12-23
代做compsci 4039 programming...
2024-12-23
代做lab exercise 8: dictiona...
2024-12-23
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!