Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

AM 147: Computational Methods and Applications: Winter 2023

Homework #9

Due: March 15, 2023

NOTE: Please submit your Homework as a single zip le named YourlastnameYourfirstnameHW9.zip via CANVAS. For example, HalderAbhishekHW9.zip.   Please strictly follow the capital and small letters in the filename of the zip le you submit. You may not receive full credit if you do not follow the le-naming conventions. Your zip le should contain all .m les (MATLAB scripts) for the questions below.

Your zip le must be uploaded to CANVAS by 11:59 PM Pacific Time on the due date.   The uploads in CANVAS are time-stamped, so please don’t wait till last moment. Late homework will not be accepted.

Problem 1

Model of Virus Spread                         (25 + 25 = 50 points)

A well-known way to model the spread of virus over time t is the so-called SIRD model. Suppose the total residential population of a county is N that remains constant over t ∈ [0, 100]. At time t, the number of susceptible individuals is S(t), the number of infected individuals is I(t), the number of recovered individuals (after being infected) is R(t), the number of deceased individuals is D(t). The SIRD model is given by the nonlinear ODE

dS β

dt         N

dI β

dt      N

= γI ,

dt

= µI ,

dt

where the parameters β , γ , µ > 0 denote rates of infection, recovery, and mortality, respectively.

Notice that the above ODE satisfies      (S(t) + I(t) + R(t) + D(t)) = 0 as it should, since

d

dt

S(t) + I(t) + R(t) + D(t) = N constant.

(a) [10 + 10 + 5 = 25 points]

Write a MATLAB function SIRD dynamics .m that specifies the above dynamics of virus spread for infection rate β = 0.45, recovery rate γ = 0.04, mortality rate µ = 0.01, and total population N = 1000.

Then write another file YourlastnameYourfirstnameHW9p1 .m that calls your MATLAB func- tion SIRD dynamics .m to solve the above ODE using ode45 over time t ∈ [0, 100] with initial conditions S(0) = 995, I(0) = 5, R(0) = 0, D(0) = 0.

Your file YourlastnameYourfirstnameHW9p1 .m should then plot the time series for the vari- ables S(t), I(t), R(t), D(t) as solid lineplots all in the same gure window. Use different linecolors for different variables’ solid lineplots: blue for S(t), red for I(t), green for R(t), black for D(t).

(b) [10 + 10 + 5 = 25 points]

Write a MATLAB function FixedStepRK4 .m that implements the xed step-size fourth order Runge-Kutta method (RK4) for any vector ODE

dy

Call this MATLAB function in the le YourlastnameYourfirstnameHW9p1 .m that you wrote in part (a) to solve for the variables S(t), I(t), R(t), D(t) with the same parameters and initial conditions as in part (a) for the same time horizon [0, 100].   Use step-size t = 0.5.   Inside YourlastnameYourfirstnameHW9p1 .m, you need to pass the function SIRD dynamics as argu- ment to the function FixedStepRK4.

Plot these time-series computed using RK4 on the same gure window generated in part (a). To avoid visual clutter, plot the RK4 results using circular markers but no lines, with the same color scheme as in part (a). For example, to plot S(t) from RK4, use plot( . . . , . . . , ’bo’). To plot I(t) from RK4, use plot( . . . , . . . , ’ro’) etc.

Submit all your codes/scripts from parts (a)-(b) within YourlastnameYourfirstnameHW9.zip.