pdf

School

University of California, Santa Barbara *

*We aren’t endorsed by this school

Course

108C

Subject

Computer Science

Date

Jun 11, 2024

Type

pdf

Pages

10

Uploaded by CorporalSquirrelMaster1081

Report
Name: ______________________________ 1/11 Student’s perm #: ________________________ Student’s signature: ________________________ Grade =______________/80 pts. MCDB 108C Spring 2024 MIDTERM EXAM #1 DO NOT OPEN THE EXAM UNTIL YOU ARE INSTRUCTED TO DO SO This exam should have 11 pages. Two blank pages are collated to the exam for you to draft your answers. Please put your name on every page You are allowed to use one page of your own hand-written notes . You may not use a computer or smart phone during the exam. You can only use a basic scientific calculator, but you shouldn't need it since you can leave your answers in exact form whenever numerical values cannot be provided. Do not spend all your time answering one question, allocate your time among the questions appropriately. For the short-answer questions, you should show how you arrived at your final conclusion(s) . Each point of this exam represents 1 point of the final grade of the class (total: 500 points).
Name: ______________________________ 2/11 [ /12 points] Question A1: In the following code, your goal is to divide the elements of vector a by the elements of vector b , and to store the results in vector c . For instance, the first element of vector c should be: 4/2=2. The end of the script should display the content of vector c . Based on vectors a and b , write the missing Matlab code to achieve this goal. for i=1:length(a) c(i)=a(i)/b(i); end disp(c) [or c] More compact vectorial answer: c=a./b; disp(c)
Name: ______________________________ 3/11 [ /12 points] Question A2: Consider the script below. What will its numerical output be? Justify your answer by describing the operation of each line of the script. Hint: Think carefully about the step-by-step implementation of the for loop. At the end of the script, the numerical output of z(end) will be 3. In line 1, vector z is initialized with zero values: it is a row vector with 5 elements. Then its first two elements are defined prior to the for loop. At each iteration of the for loop, a new element of vector z with index i+2 is assigned the value of the sum of its previous two elements with indices i+1 and i. The loop is implemented 3 times, which corresponds to the length of vector z minus two elements. The values of vector z change as follows: Iteration 1: i = 1, z(3)=z(2)+z(1)=0+1=1 Iteration 2: i = 2, z(4)=z(3)+z(2)=1+1=2 Iteration 3: i = 3, z(5)=z(4)+z(3)=2+1=3 The disp(z(end)) command only shows the value of the last element of z. It doesn’t returns all values of the vector!
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Name: ______________________________ 4/11 In the next set of questions, we will revisit the dynamical system studied in coding assignment #2. Recall that the dynamics of the number of virus particles is given by the ODE: !" !# = ࠵?(࠵?) – ࠵? " ࠵?(࠵?) where ࠵?(࠵?) is a variable flux of virus and ࠵? " is the degradation rate. At time t=120 hours, an antiviral drug is applied, which fully blocks the influx of virus. In other words, ࠵?(࠵?) = 0 for ࠵? larger than 120 hours. The time course of the viral load is reported in units of hours. [ /12 points] Question B1: Two different strains of viruses are studied: strain A and strain B. One viral strain undergoes a faster turnover than the other strain. From 0 to 120 hours, the viral flux of each strain is the same: ࠵? = 300 virus/hour. The time courses of the viral load for strains A and B are reported in the figure below for each of the two viral strains. Shortly before the addition of the antiviral drug, the system can be considered at steady state for both strains of virus.
Name: ______________________________ 5/11 Please match each viral strain with the most likely value of its degradation rate constant from one of the 5 options listed below: OpWon 1: 50/hour OpWon 2: 5/hour OpWon 3: 0.5/hour OpWon 4: 0.05/hour OpWon 5: 0.005/hour Important: Please specify the option corresponding to each strain. Briefly justify each of your answers quantitatively. Shortly before the addition of the drug at t=120 hours, both strains appear to have reached a (near) steady state values (denoted as ࠵? ). For strain A, the steady state value is 6000 virus. For strain B, the steady state value is 600 virus. Before the drug addition, the value of the virus influx ࠵? is 300 virus/hour. The steady state of the ODE is obtained when ࠵? = ࠵?/࠵? " . As ࠵? = 300/࠵? " , we find that ࠵? " = 300/࠵? . Given the steady state values observed in the graphs right before t=120 hours, we conclude that: For strain A: ࠵? " = 300/6000 = 0.05/hour. For strain B: ࠵? " = 300/600 = 0.5/hour Note: Some students tried to infer the value of ࠵? " by estimating the half-life of the exponential decrease following the addition of the drug. While this approach is correct conceptually, it is less precise. Well-justified answers based on this approach were given full credit. [ /12 points] Question B2: Consider two patients infected by the same viral strain A. In patient 1, the viral load reaches a steady state value of 6,000 virus before the application of the drug. In patient 2, the viral load reaches a steady state value of 9,000 virus. The degradation rate of the viral strain A (denoted as ࠵? % ) is the same for both patients. Following the application of the drug at t=120 hours, how long will it take for the viral load of patient 2 to be equal to 3000 virus compared to patient 1? You do not need to know the exact value of ࠵? % to answer this quesWon. To simplify the math, consider that t=0 hour when the drug is applied. Modify the ODE to account for the application of the drug. Hint: Think about the definition of the half life.
Name: ______________________________ 6/11 Upon addition of the drug, the virus flux is equal to the 0. The ODE becomes: !" !# =– ࠵? " ࠵?(࠵?) The solution of the ODE is an exponential decay. For patient 1, ࠵? & (࠵?) = ࠵? &,( ࠵? – + ! # where ࠵? &,( represents the initial concentration of ࠵? & before application of the drug. Time ࠵? is defined as starting from the application of the drug. The time necessary for ࠵? &,( =6000 virus to decrease to 3000 virus is, by definition, the half life: ࠵? & (࠵? & ) = ࠵? &,( ࠵? – + ! , " = ࠵? &,( /2 yielding ࠵? & = -.(0) + ! For patient 2, the problem is the same except that ࠵? 0,( =9000.The latency (decay) time ࠵? 0 that we are looking for is: ࠵? 0 (࠵? 0 ) = ࠵? 0,( ࠵? – + ! , # = ࠵? 0,( /3 yielding ࠵? 0 = -.(2) + ! . Therefore the latency time to reach 3000 virus in patient 2 will be -.(2) -.(0) times longer than that of patient 1, which is equal to an increase of ~60%.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Name: ______________________________ 7/11 [ /20 points] Question B3: Imagine a different strain of virus that is so stable that its degradation rate can be neglected. The corresponding ODE is: ࠵?࠵? ࠵?࠵? = ࠵?(࠵?) The viral load is initially equal to 0 viral particle (i.e., ࠵?(0) = 0) . As shown in the figure above, the production rate ࠵?(࠵?) is a constant equal to 1 virus/hour between 0 and 120 hours. As before, an antiviral drug fully suppresses the viral influx at time t = 120 hours (i.e., ࠵?(࠵?) = 0 for ࠵? > 120 hours). Please explain the change in the viral load before and after application of the drug. Using the ODE and its solution, please do the following: (1) Assuming that ࠵?(0) = 0 , predict the shape of the rise in the viral by solving the ODE for ࠵?(࠵?) between 0 and 120 hours (write your answer in the text box of page 8); (2) Compute the maximum viral load reached by the system (write your answer in the text box); (3) Predict the system’s behavior after application of the drug between 120 and 240 hours (write your answer in the text box); (4) To the best of your ability, draw your prediction of the time course of the viral load ࠵?(࠵?) between 0 to 240 hours directly in the bottom panel of the figure above.
Name: ______________________________ 8/11 (1) Between 0 and 120 hours, the general solution of the ODE !" !# = ࠵? where ࠵? is a constant is: ࠵?(࠵?) = ࠵? ( + ࠵? ࠵? . In this solution ࠵? ( represents the initial concentration of ࠵? , which is equal to 0. Given that ࠵? is equal to 1 virus/hour, the solution is ࠵?(࠵?) = ࠵? for 0 < ࠵? < 120 hours. Before the application of the drug, the number of virus will rise linearly at a rate of 1 per hour. (2) Given the solution derived in point (1), the maximum viral load is reached right before the drug is applied at ࠵? = 120 hours. At that time, ࠵?(120) = 1 × 120 virus. (3) After the drug is applied, the flux of virus is abolished and the ODE becomes: !" !# = 0 since the degradation rate can be neglected. Therefore ࠵?(࠵?) = ࠵?(120) = 120 virus for all ࠵? > 120 hours. (4) See graph below
Name: ______________________________ 9/11 [ /12 points] Question B4: Your goal is to apply Euler’s integration method to numerically simulate the behavior of the ODE for the viral load !" !# = ࠵? – ࠵? " ࠵?(࠵?) using a time increment of 1/60 hour and an initial condition ࠵?(0) = 100 viral particles. The parameters of the ODE are: ࠵? is a constant equal to 300 virus/hour and ࠵? " = 5 /hour. You are given the following Matlab script, which contains three bugs. Please find at least the two of the three bugs and propose a correction for each of them so that the code runs properly. There are actually 4 bugs in the script: - Bug 1: In line 3, increment dt should be included in the definition of the time vector time_vect . - Bug 2: In line 7, x_t = zeros(L,1) . The initialization with zeros(L) produces a matrix instead of a vector. - Bug 3: After line 7, x_t(1) should initialized to be equal to 100 virus. - Bug 4: In line 10, x(i+1) must be calculated based on the value of x(i) , which is missing. Corrections of the 4 bugs:
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Name: ______________________________ 10/11