Starting from:

$25

AMATH301-Homework 2 Solved

AMATH 301 

Homework #2


1.    Consider the function

f(x) = x5 − 2x4 + 3x3 − 2x2 + x − cos(30x).

Calculate f(0) and f(1.2) and save their product as A1.dat. Does this tell you if f has a zero on the interval [0,1.2]? Does it tell you how many zeros f has on the

interval [0,1.2]?

Use the bisection method to find a zero of f between x = 0 and x = 1.2. Your final answer should be a number x such that |f(x)| < 10−10 (i.e. use a tolerance of 10−10). Save the resulting x in A2.dat. Save the number of steps this process took in A3.dat. (Each time you calculate a midpoint counts as one step.)

2.    We will now continue to investigate the logistic map that we first encountered in the previous homework:
 ,

where P(t) represents the population at year t as a proportion of the maximum population. Throughout this problem, we will assume that P(0) = 0.3 (note that this is not the same as in the previous homework).

For r = 2.5, create a row vector containing the populations for years 0 through

 

If you plot these populations, you should see that the population approaches a single value and stays there. (If you call the vector x, you could use the command plot(x) to visualize the data. Make sure you remove all plots before submitting to Scorelator.) The final value is called an equilibrium or steady state of the logistic map.

Repeat this process for r = 3.2 and r = 3.5. You should see different behavior in your plot. In particular, these densities should not approach an equiibrium.

Make a matrix



P2.5(98)



A = P3.2(98)





P3.5(98)
P2.5(99)

P3.2(99)

P3.5(99)


P2.5(100)



P3.2(100),



P3.5(100)
where Pr(t) is the population P at time t using the parameter r. For example, the first row of this matrix should be the last three entries of the vector you obtained when r = 2.5. Save this matrix as A4.dat.

We would like to determine which values of r lead to an equilibrium. As a somewhat crude method, we can check if the population densities stop changing (or at least do not change very much) after a long enough wait. We will say that Pr reaches an equilibrium for some value of r if Pr(501)−Pr(500) is sufficiently small. In particular, we will say that Pr reaches an equilibrium if |Pr(501)−Pr(500)| < 10−8 and we say that the equilibrium value is P(501).

For each value of r between 2 and 3.4 in steps of 0.1 (i.e. for every r in r = 2:.01:3.4), decide if the population reaches an equilibrium. If it does, find the equilibrium value. Create a 1×15 vector called is_equilibrium whose entries are either one or zero. The kth entry of is_equilibrium should be one if Pr reaches an equilibrium and zero if it does not for the kth value of r (i.e. r(k) if you defined r = 2:0.1:3.4). Save is_equilibrium in the file A5.dat.

In addition, create a 1 × 15 vector equilibrium_value whose entries are the equilibrium value of Pr if such a value exists and zero otherwise. Save this vector in the file A6.dat.

As an example, if r = 2.1 reaches an equilibrium value of 0.8, then is_equilibrium(2) should equal 1 and equilibrium_value(2) should equal 0.8.

Things to think about (not required): For some values of r, the population appears to oscillate between two values. Can you test for those values? Can you find oscillations between three values? Four? Can you find a better method to test for equilibria? In particular, do you think there is an equilibrium when r = 3?

3. Proteins are long chains of amino acids that can fold into different configurations (shapes). The configuration of the protein determines (at least in large part) how the protein works. Suppose that we have a particular protein which can be folded into four different configurations: c1, c2, c3, and c4, but that it only has a useful function when it is in configuration c1. We can select a protein in the correct configuration, but because of random molecular motion we cannot guarantee that it will stay in this configuration forever. This means that we can only find the probability that the protein will be in any given configuration at any given time.

Define the vector

  p1(t)

                                              

p2(t),

                     p(t) =           

p3(t)



  p4(t)

where pi(t) is the probability that the protein will be in configuration ci after t hours. If we choose a protein that we know is in configuration c1 at time t = 0, determine p(0) and save it in the file A7.dat. (Remember that probabilities are between 0 and 1 and the total probability of all four configurations must add up to

1.)

We can summarize the dynamics of this protein with something called a transition matrix T. In our case,



0.99



0.00



T = 

0.01





0.00
0.00

0.56

0.25

0.19
0.10

0.22

0.38

0.30


0.00



0.36





0.15





0.49
The entry Tij (i.e. the number in the ith row and jth column) gives the probability that the protein will switch to configuration ci in the next hour if it is already in configuration cj. For example, if the protein is already in configuration c3 then there is a 22% chance that it will switch to c2 after one more hour because T23 = 0.22. This matrix allows us to calculate future probability distributions very easily using

p(t + 1) = Tp(t).

We will say that the protein is ineffective once it has less than an 80% chance of being in configuration c1. How many hours will it take until the protein is ineffective? (That is, find the first time that p1(t) drops below 0.80. Remember that we started at time 0.) Save this time in A8.dat and save the corresponding vector p(t) in A9.dat.

If you calculate p(t) for sufficiently large times, you should see that it approaches a constant vector. Just as in the previous problem, this vector is called the equilibrium value of p. Find this equilibrium value and save it in the file A10.dat.

More to think about (for fun): Probabilities have to add up to 1. In particular, this means that at any time, p1(t) + p2(t) + p3(t) + p4(t) = 1. You need to enforce this for t = 0, but for all later times we didn’t check this. Does it appear to be true for all t? What does this have to do with the matrix T? (There is a fairly simple property of T that forces this to be true.) Does the equilibrium value depend on your initial condition? That is, can you come up with a different p(0) that results in a different equilibrium value? Does the equilibrium value depend on the matrix T? Can you come up with a matrix so that the equilibrium value does depend on the initial condition? (Remember to keep whatever condition you found so that the sum of the probabilities is always one.)

More products