Você está na página 1de 3

MH2401

Algorithms & Computing III Lab 5: Topics from Calculus

AY 2013/14 S1

5.1. Aim. The aim of this lab is to explore applications of calculus in trac systems and population dynamics. 5.2. Objectives. At the end of this lab, students should be able to: (a) Understand how derivatives and dierential equations can be used to model the dynamics of some natural phenomena, such as road trac, and population of competing species. (b) Explain how these dynamical systems behave in the long run. 5.3. Tasks. 1. Complete as many tasks as possible. 2. Please put in a serious eort to complete each task on your own before consulting your friends. 3. If you need help, you are encouraged to ask the lab tutors. 4. If you wish to, you may submit a report on either topic by publishing the .m le, and printing the published HTML to a PDF le. All submissions before 12 noon on Monday, 16th September will be reviewed and commented by an instructor. 5. Answers will only be provided after the last class ends on Friday. Topic 1: Road trac system. We consider the model of a trac system in a long road. We assume that the road can have a very large number of cars in queue. Let the number of cars on the road at any time t be denoted by the variable x x(t). Thus, x(t) denotes the queue length at any time t. Suppose that cars start arriving at the road at a rate of cars/min, and they are able to exit the road at the rate of cars/min. Then, the rate of change in the number of cars that are present on the road is given by the dierence between the rate at which the cars arrive and the rate at which they depart. Hence, we get 1 dx (1) = , x 0. dt We consider a model where the rate of arrival is constant. This might be the case at certain time periods in the day. The rate of departure of the cars depends on the number of cars already present on the road and is given by the expression x (2) (x) = c , x+1
the number of cars is a discrete quantity, assuming it to be a continuous function of time simplies the modeling signicantly.
1Although

where the constant c is the maximum rate of departure that is possible. We can numerically determine how the number of cars in the road evolve over time by considering an approximation of the dierential equation by the dierence equation x(t + t) x(t) (3) = (x(t)). (t + t) t We will study the solution of the ordinary dierential equation (1) by approximating it with the dierence equation (3). In the problems below x c = 25. Task 1.1. Create a plot of the queue length x against time t, for the following initial values of the queue length and the arrival rates . (i) x(0) = 0, = 20, (iii) x(0) = 35, = 20, (ii) x(0) = 0, = 24, (iv) x(0) = 35, = 24. For each of the above initial values, what can you infer about the behavior of the queue length in the long run, i.e., for large t? [Hint: You may want to use a small step size for the time, say t = 0.001, to study the dynamics.] Task 1.2. We say that the queue length x is at a steady state if it does not change over time, i.e., x(t) = xs for some constant xs . Mathematically derive the expression for the steady state queue length as a function of and c. [Hint: Since the steady state queue length is a constant, what is its derivative with respect to time?] Task 1.3. Create a plot of xs against /c, for 0 /c 1. For what values of arrival rate does the steady state queue length remain less than 24. Task 1.4. In this part we will study the behavior of how the queue length changes as we change the arrival rate. The specic scenario we are trying to simulate is the case of a rush hour trac. This also shows how much time it takes for the trac to regain a normal steady state after the rush hour is over. Suppose that we start the numerical simulation at time 7 am. Thus, t = 0 corresponds to 7 am. Assume that x(0) = 3, i.e., there are three cars on the road at t = 0. Now, consider the following scenario. (i) Till time t < 4, the arrival rate is 12 cars/min. (ii) At time t = 4, which corresponds to 7:04 am, the arrival rate changes to 20 cars/min, and remains so till time t < 10. (iii) At time t = 10, the arrival rate changes to 40 cars/min, and remains so till time t < 60. (iv) At t = 60, the arrival rate changes back to 20 cars/min. What is the maximum queue length before it starts decreasing? How much time does it take for the queue length to reach steady state, from the time t = 60? (You can round your answers to the nearest integer.)

Topic 2: Population dynamics. In this question, we investigate a coupled system of dierential equations that models the population dynamics of two competing species. Suppose that x x(t) denotes the population (in hundreds) of a prey species, say deer, over time. Also, suppose that y y (t) denotes the population (in hundreds) of a predator species, say lion, over time. We will investigate how the two species evolve over time where the change is determine by the following pair of coupled dierential equations, dx x y = 2x 1 , dt 5 5 (4) dy x y = 3y 1 . dt 4 6 We can view x and y as parametric functions of t and numerically solve the system t)x(t) t)y (t) by replacing dx with x(t+ , and dy with y(t+ . This gives the corresponding dt t dt t system of dierence equations x(t + t) x(t) x(t) y (t) = 2x(t) 1 , t 5 5

y (t + t) y (t) x(t) y (t) = 3y (t) 1 . t 4 6 In this topic, we will study the population dynamics by using an xy -plot to study the change in population of both the competing species simultaneously. Task 2.1. For each of the following initial conditions, use the above system of dierence equations (5) to numerically solve the coupled system of dierential equations over 0 t 4, and plot all solutions in the same xy -plane. (i) x(0) = 1, y (0) = 3, (iii) x(0) = 2, y (0) = 5, (ii) x(0) = 2, y (0) = 1, (iv) x(0) = 3, y (0) = 3. [Hint: You may want to use a small step size for the time, say t = 0.001, to study the dynamics.] Task 2.2. A pair (xs , ys ) is called a stationary point of the coupled system if both derivaand dy are zero at (xs , ys ). tives dx dt dt Mathematically determine all the stationary points (xs , ys ) of the coupled system. [Hints: 1) You will need to solve a 2-by-2 system of linear equations. 2) There are exactly four stationary points.] Task 2.3. For each of the stationary points (xs , ys ) of the coupled system, use MATLABs quiver function to produce a velocity plot of the above dierential equation over a unit square region in the xy -plane centered at the stationary point (xs , ys ), i.e., over the region xs 0.5 x xs +0.5, and ys 0.5 y ys +0.5. For each of the velocity plots, how would you expect the solution of the coupled system to behave around the stationary point? In other words, how does the population of the two species (deer and lion) change over time? Support your answer with a few plots of the solutions originating from suitably chosen points in the same plot.

(5)

Você também pode gostar