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 initial-value problem
(
u
0
(t) + 3tu + u
2 = 0,
u(1) = 0.5.
Let h = 0.1, 0.05 and 0.025, and solve the differential equation respectively to determine u(2)
using
(a) Forward Euler Method.
(b) Backward Euler Method.
(c) Trapzoidal Method.
(d) Leapfrog Method (use forward Euler Method to compute U
1
).
Denote the corresponding solutions as u
0.1
(2), u
0.05(2) and u
0.025(2) respectively, and compute
the following ratio for the above four methods
r =
u
0.1
(2) − u
0.05(2)
u
0.05(2) − u
0.025(2).
2. Consider the following problem
(
u
0
(t) = −e
−tu(t)
x(0) = 1
(a) Compute the exact solution for the above initial value problem.
(b) Use your codes of Forward Euler, Backward Euler, Trapzoidal Method and Leapfrog
Method developed for Problem 1 to compute u(1) using h = 0.1, 0.05 and 0.025, and
denote numerical solutions as u
0.1
(1), u
0.05(1) and u
0.025(1).
∗All course materials (class lectures and discussions, handouts, homework assignments, examinations, web materials) 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.
1
(c) Compute the following ratio and explain how they are connected to the ratio obtained
in Problem 1.
r1 =
u
0.1
(1) − u(1)
u
0.05(1) − u(1), r2 =
u
0.05(1) − u(1)
u
0.025(1) − u(1).
2