MATH 1180: Calculus for Biologists II (Spring 2011)

advertisement
MATH 1180: Calculus for Biologists II (Spring 2011)
Lab Meets: January 12, 2011
Report due date: January 19, 2011
Section 002: Wednesday 9:40−10:30am
Section 003: Wednesday 10:45−11:35am
Lab location − LCB 115
Lab instructor − Erica Graham, [email protected]
Lab webpage − www.math.utah.edu/~graham/Math1180.html
Lab office hours − Monday, 9:00 − 10:30 a.m., LCB 115
Lab 01
General Lab Instructions
In−class Exploration
Review: At the end of last semester, we drew comparisons between the ideas of Riemann sums and definite
integrals.
Background: Today, we will see how Riemann sums relate to Euler’s Method for solving differential
equations. We will also explore some useful applications of the definite integral. The examples in this lab
are based on a simplistic view of the immune system. When your body is fighting a virus, immune cells are
recruited to multiply and kill the virus particles before there are too many of them to do anything.
Depending on the virus, the so−called "effector" cells are extremely efficient at eliminating such a threat.
restart;
Let’s consider a population of virus particles, hereafter referred to as "the bad guys" (denoted B(t)), that lead
to an infection. We’ll call the population of immune cells recruited to take care them "the good guys"
(denoted G(t)).
Some definitions:
G0 = G(0) −− the number of good guys on day t = 0
B0 = B(0) −− the number of bad guys on day t = 0
rg −− the net growth rate of G(t) per day
rb −− the net growth rate of P(t) per day, independent of the immune system
k −− the number of bad guys killed per day
G0:=1:
B0:=200:
rg:=1:
rb:=1.5:
k:=5:
Suppose we already know what G(t) is. (Recall how we define functions in Maple.)
G:=t−>G0*exp(rg*t);
rg t
G := t G0 e
(2.1)
Our omniscience allows us to know that the bad guys change according to the differential equation dB/dt =
f(t), with B(0) = B0 and the following function f(t):
f:=unapply(rb*exp(rb*t)*(B0+k*G0*(1−exp(rg*t))/rg)−k*G0*exp(rg*t),
t);
(2.2)
f := t 1.5 e1.5 t 205 5 et
5 et
(2.2)
We used unapply( ) in the previous command so that Maple knows to plug in all the numbers we defined
above, which makes things look way less complicated.
Now that we have a model in place, suppose we wish to determine how many bad guys are left after day
4. There are two ways we can approximate the answer.
Method 1: Euler’s Method for solving differential equations numerically.
Refer to Lab 12 from Fall 2010 for more details about Euler’s Method. Here, we’ll just use the algorithm to
determine B(4), from which we’ll simply subtract B0. To get started, we need to define a starting point B
[0] = B0, the time step dt and the number of iterations N we wish to complete based on the time step.
B[0]:=B0:
dt:=1/100: ## small−ish, but probably not small enough
N:=4/dt:
for j from 0 to (N−1) do
B[j+1]:=evalf(B[j]+f(0+j*dt)*dt):
end do:
To determine the number of bad guys remaining, we just need to find B(4)−B0 = B[N]−B[0].
euler_soln:=B[N]−B[0];
euler_soln := 16360.17830
(2.3)
Method 2: Riemann sums
Now, we’ll see how Riemann sums relate to the quantity we just found. Recall that Riemann sums are
based on the notion of splitting a given interval into n equal subintervals and creating rectangles whose
heights correspond to an appropriate place on the curve of interest. In our case, this curve is f(t). Then, we
can add up the areas of each rectangle to approximate the total area "under" the curve. If we were to draw
infinitely many rectangles, we could find an exact value for the area. We will use the sum( ) command to
do this.
n 1
Recall that the left Riemann sum for f(t) is given by Il =
The increment t =
tmax
tmin
, and each ti = tmin
f ti
t.
i=0
i t = tmin
i
tmax
tmin
.
n
n
The sum( ) command has the form sum(expression, index = start..end).
We’ll choose a step size delta_t to be equal to the time steps dt we used for Euler’s Method.
delta_t:=dt:
n:=4/delta_t: ## step size
riemann_soln:=evalf(sum(f(0+i*delta_t)*delta_t,i=0..n−1)); ## left
Riemann sum for n=400 rectangles
riemann_soln := 16360.17838
(2.4)
Notice that the two solutions are identical to three decimal places, which is mostly likely an artifact of
Maple’s round−off error. This shows that Euler’s Method and the left−hand Riemann sums are comparable
methods for finding the solution of a differential equation numerically. In both cases, a small enough step
size would eventually yield the true answer, which we can compute using the int( ) command:
true_soln:=int(f(t),t=0..4); ## the definite integral from t=0 to
t=4 of f(t)
(2.5)
true_soln := 16153.51453
It seems like there are an awful lot of virus particles left after 4 days. Let’s see exactly how much longer it
would take for all of the bad guys to disappear for good. We will solve for the unknown upper bound of
integration L that would make the integral from t=0 to t=L equal to zero. An omniscient guess would be
that L is somewhere between 4 and 4.5.
fsolve(int(f(t),t=0..L)=0,L=4..4.5);
4.219716085
(2.6)
This tells us that roughly 5 hours and 15 minutes into the fifth day all of the bad guys would have been
killed. Now that’s what I call efficiency. To compare the behavior of the good guy and bad guy
populations, we can plot both B(t) and G(t).
B:=unapply(int(f(t),t)+3,t); ## our all−knowing ability tells us
this is right
plot([B(t),G(t)],t=0..4.2197,legend=["bad guys","good guys"],
color=["DarkCyan","LimeGreen"],thickness=2);
1.500000000 t
2.500000000 t
t
B := t 205. e
3. e
5. e 3
20000
15000
10000
5000
0
0
1
2
3
4
t
bad guys
good guys
It’s hard to see G(t) on the above graph because the scales are so different between the two curves. It’s
evident that there are significantly fewer immune cells around, yet within less than a 24−hour period, they
are able to completely reverse the population of virus particles in the body.
Please copy the entire section below into a new worksheet, and save it as something you’ll
remember.
Lab 01 Homework Problems
Your Full Name:
Your (registered) Lab Section:
Useful Tip #1: Read each problem carefully, and be sure to follow the directions specified for each
question!
Useful Tip #2: Don’t be afraid to troubleshoot! Does your answer make sense to you? If not, explore why.
If you’re still unsure, ask me.
Useful Tip #3: When in doubt, restart!
Useful Tip #4: Re−read the in−class exercises to familiarize yourself with some of the new and old
commands we used today.
Paper−saving tip: Make the size of your output graphs smaller to save paper when you print them. Please
ask me if you’re unsure of how to do this. (You can see how much paper you’d use beforehand by going to
File
Print Preview.)
(0) Read the useful tips listed above, especially the last one.
This assignment is based on the immune/virus model introduced in class: dB/dt = f(t), B(0) = B0.
(1) Re−define the initial values, parameters and the function f(t) that we used in class. You should define a
total of 6 things. (Copy and paste is perfectly acceptable, by the way.)
## feel free to use this space
## feel free to use this space
## feel free to use this space
## feel free to use this space
## feel free to use this space
## feel free to use this space
(2)(a) Using the formula for the average value, compute the average rate at which the bad guys change.
Save the result as the number w.
## find w
(b) Plot w and f(t) from t=0 to t=4 on the same set of axes.
## plot here
(3)(a) Compute the area of the rectangle created between w and the x−axis along the interval specified.
## feel free to use this space
(b) Compute the definite integral of f(t) between 0 and 2, and add this to the same integral evaluated from
2 to 4. (You should only need one line of code to do this.)
## feel free to use this space
(c) How do your answers to the previous two parts compare to the "true_soln" we found in class? Explain
why this is the case.
(4) When is the good guys’ job halfway done? The following problems will take you through the steps of
solving this problem.
(a) Solve for the time at which dB/dt = 0, and save the result as t1.
## find t1
(b) Compute the integral of f(t) from t=0 to t=t1 and divide it by 2. Save the result as c1.
## find c1
(c) Determine the time (i.e. the upper bound of integration) at which the absolute value of the integral of f
(t), starting from t=t1, equals c1. Save the result as t2.
Note: In Maple speak, abs(2) is equivalent to |2| on paper.
## find t2
(d) Why did you need to use the absolute value in the previous part?
(e) How can c1 be interpreted?
(5)(a) How many hours did it take the good guys to reduce the population of virus particles by half? Use
a couple of your previous answers and your intuition to answer this question.
## feel free to use this space
(b) Determine how many hours it took the bad guys to grow to c1 prior to day t1. Save this result to t3.
## find t3
(c) Who wins based on these results?
(6)(a) What change(s) to the model might reverse who ends up in the winner spot? Explain.
(b) Prove it. Run your own Maple experiment by implementing at least one of the changes you just
mentioned, and provide useful results. Feel free to restart if necessary.
Note: If you need more command lines, press Ctrl+j. To add a paragraph, click the blue T in the toolbar.
Delete any unused lines.
## feel free to use this space
## feel free to use this space
## feel free to use this space
##
##
##
##
feel
feel
feel
feel
free
free
free
free
to
to
to
to
use
use
use
use
this
this
this
this
space
space
space
space
## feel free to use this space
(c) Summarize your results by explaining what you did, why you did it, and what you found in the end.
(7) List and describe (using more than two words!)
[1] any new commands you used in either homework or class, and
[2] any old ones you had forgotten about.
Remember that Maple commands do not include functions (or parameters) that we define and are normally
followed by things within a set of parentheses.
Did you remember to save paper?
Download