1
SI214C-Applied Numerical Computing, 2023 Fall
Homework Set #2
Requirements:
1) Deadline: 11pm, 8 November 2023.
2) About your codes:
a) Make sure that your codes can run and are consistent with your results.
b) Attach a Readme.txt file to clearly identify the function of each file.
3) Put the results of your program into PDF and submit your PDF report to Blackboard.
4) You need to compress three files code (Only accept MATLAB language), readme, and PDF into one file,
name this file as student ID + your name upload it to the Blackboard.
0
Problem 1. (50 points)
Consider the heat equation
ut = uxx + uyy ,
on the unit square 0 < x < 1, 0 < y < 1, with the homogeneous Dirichlet boundary condition u = 0 on the
boundary of the unit square. The initial condition is u(x, y, 0) = f (x, y), where f (x, y) = 1 within the region
Ω = {0.4 ≤ x ≤ 0.6, 0.4 ≤ y ≤ 0.6} and f (x, y) = 0 in the rest of the square. Solve this problem using the
∆t
∆t
θ-method, where θ, µx = ∆x
2 and µy = ∆y 2 should be selected properly such that the corresponding θ-method is
stable. Plot the numerical solutions at t = 0.001, 0.004, 0.01. In addition, the values of θ, ∆x, ∆y and ∆t should
be clearly stated in the report.
2
Problem 2. (50 points)
Consider the following problem
− d [C(x) du ] = 1 , 0 < x < 1,
dx
dx
(1)
u(0) = u(1) = 0,
where
C(x) =
1 , 0 < x < 0.5,
(2)
1 , 0.5 ≤ x < 1.
2
Derive the exact solution u(x) of (1), and program the linear finite element method (FEM) to solve (1). For the
finite element method, the elements are equally sized, and the size of each element is denoted by h. Plot the finite
element solutions with h = 0.2, h = 0.1 and h = 0.05, and the exact solution.