Math 104C Homework #3 ∗
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 initial value problem
(cid:40)
(cid:126)x(cid:48)(t) = A(cid:126)x(t), t ∈ [0,3]
(cid:126)x(0) =(cid:126)x ;
0
where
(cid:32) (cid:33) (cid:32) (cid:33)
−33.4 66.6 3
A = , (cid:126)x = .
0
33.3 −66.7 0
The exact solution is
(cid:40)
e−100t+2e−t/10
(cid:126)x(t) =
−e−100t+e−t/10
(a). Graph the two components of the exact solution in the same picture.
(b). Write and test a code to numerical solve the linear system using the forward Euler
method with h = 1 . Graph the two component of the numerical solution in the same
10
picture.
(c). Repeat the same procedure with h = 1 .
20
(d). Repeat the same procedure with h = 1 .
40
(e). Repeat the same procedure with h = 1 .
80
(f). Repeat the same procedure with h = 1 .
160
(g). Compare the graphs obtained in parts (a) - (f) and write what you observed. Explain
this by computing the eigenvalues of A (Hint: think about how the eigenvalues are
related to the stability of numerical methods).
∗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
lecturesordiscussionsandfromdistributingorsellinglecturesnotesandallothercoursematerialswithouttheprior
written permission of the instructor.
1
2. Consider the boundary value problem of the heat equation
u (t,x)−u (t,x) = 0,
t xx
u(0,x) = e−100x2,
u(t,−1) = u(t,1) = 0.
(a) Write and test a code to solve the boundary value problem of the above heat equa-
tion using discretization of central difference in space and forward Euler/Backward Eu-
ler/Trapzoidal Rule (Crank-Nicolson) in time. Take the time step k = 0.1 and mesh size
h = 0.02, and plot u(1,x).
(b) Repeat the same procedure with k = 0.01 and h = 0.02.
(c) Repeat the same procedure with k = 0.001 and h = 0.02.
(d) Repeat the same procedure with k = 0.0001 and h = 0.02.
(e) Compare the graphs obtained in parts (a) - (d) and explain what you observe by ana-
lyzing the stability and local truncation error of each method.
2