Math 104C Homework #2 ∗ Instructor: Xu Yang
General Instructions: Please write your homework papers neatly. You need to turn in both your codes and descriptions on the appropriate runs you made by following Grader’s instructions. Write your own code, individually. Do not copy codes!
1. Consider the second-order Runge-Kutta method:
where
Un+1 = Un + k (F1 + F2) 2
F1 =f(tn,Un)
F2 =f(tn +k,Un +kF1)
Show the local truncation error of the method is O(k2). 2. Consider the initial value problem
u′(t)=1+u, 1≤t≤2, t
u(1) = 2
(a) Solve the exact solution to this initial value problem.
(b) Write a code for the classical Fourth-order Runge-Kutta method and use it to solve the problem using k = 0.2, 0.1, 0.05, 0.025. Your output should be a table like the following
where ek = max |u(tk)−Uk| and N = 1.
0≤k≤N k
(c) Repeat the same process as in (b) using the second-order Runge-Kutta method given in Problem 1.
∗All course materials (class lectures and discussions, handouts, homework assignments, examinations, web ma- terials) and the intellectual content of the course itself are protected by United States Federal Copyright Law, the California Civil Code. The UC Policy 102.23 expressly prohibits students (and all other persons) from recording lectures or discussions and from distributing or selling lectures notes and all other course materials without the prior written permission of the instructor.
k
ek
0.2
0.1
0.05
0.0025
1
Use the short-hand notation fn = f(tn,Un) for Problems 3–5.
3. Consider the following two-step method:
Un+2 − 3Un+1 + 1Un = k(5fn+1 − 3fn) 2244
Show the local truncation error is of O(k2).
4. Consider another two-step method:
Un+2 − 3Un+1 + 2Un = k(1fn+1 − 3fn) 22
Show the local truncation error is of O(k2).
5. Consider the initial value problem
u′(t) = u(t), u(0) = 1.
The exact solution is u(t) = et.
(a). Write a code for solving the model problem using the method in Problem 3 with U0 = 1 and U1 = eh. Here k = 0.01 is the time step size. Graph the numerical solution and exact solution in the same plot.
(b). Repeat the same procedure using the method in Problem 4.
(c). Compare the graph obtained in part (a) and (b). Show the difference that observed. Can you explain it using zero-stability.
6. Consider the following two-step method:
Un+2 = Un + 2hfn+1.
Show it is zero-stable.
2
t ∈ [0,1]