S&Z Ch 4: Difference Equations



IdeasDo this chapter in conjunction with system dynamics models? Two sessions. Then do Schelling with exercises?AssignmentRead chapter. Write up responses to example problems on page 49.Rhetorical TasksSimple examples.NotationThe MathEquilibriumStocks and FlowsConcepts and VocabularyNotation, subscripts, equilibrium, period, stable/unstable, first order/second order, etc., nonlinear, iteration, rule of 72, limit as n goes to infinity, 45 degree line, critical mass, LectureConsider the following sequence of numbers1 1 2 3 5 8 …Three dots = ellipsis = "and so on"Let's refer to each of these as an "sequence member."And so let's call the first one "sequence member 1" and so onSequence Member 11Sequence Member 21Sequence Member 32But I tire of writing out "sequence member" so I'm going to abbreviate it "s"s43s55s68But now I want to offer some typographical signal that the "s" is an abbreviation and the digit is a part of a numbering system. And so I write the digits as a subscript.s713s821s934Obviously, the index can be any number, but I don't want to have to write out millions of terms of the sequence. So, by convention, I write the subscript generically as "I":si , i = 1,2,3,…We will frequently use "I" in this style to stand for "any old element of the sequence" while we use the subscript "n" to refer to a particular element.In particular, if I wanted to say that one element was equal to the one before it times 2, I could writesn+1=2 × snLet's talk about your bank account. Suppose you are getting 2% interest each year. Let's say your initial deposit is p0 (p stands for principal). How much will we have in the bank after the first year?p0=p0+0.2×p0orp1=1.02 ×p0andp2=1.02 ×p1=1.02 ×1.02×p0=1.022×p0Examples4.1A totalitarian country that prohibits migration has a birth rate b and a death rate d. How does the population change from one year to the next?Let Pi be the population in year i. ThenPi+1=(1+b-d)Pi4.2There are no births in a Shaker community, only R recruits per year. The death rate is d. What is the difference equation that describes this situation?Let Pi be the population in year i. ThenPi+1=1-dPi+R4.3The Eastville School Committee is agrees to an annual $200 per year salary increase for each Eastville teacher. Express this as a difference equation.We assume that this means this increase will occur every year. Let Si be the teacher salary in year i.Si+1=Si+2004.4The Westtown School committee is more generous. It agrees to a 5.5% cost-of-living increase per year, plus a one time only $200 adjustment for past sins of omission. Express this as a difference equation.Let S0 be the starting salary. Let's assume that the "adjustment" is added after last year's salary is increased for cost of living. ThenS1=(1+0.055)S0+200In year 2 we haveS2=(1+0.055)S1=(1+0.055)(1+0.055)S0+(1+0.055)200And then, in year I,Si=(1+0.055)i-1((1+0.055)S0+200)Extra credit: how much would it be worth to teachers if the one time adjustment were made before the first COLA rather than after.Equilibria and Difference EquationsPrefatory NotesGeneric Equation for a Straight Line y=mx+by-axisx-axisriserunm is the "slope"b is the "y intercept"slope = rise / runThe "45 Degree Line"y-axisx-axisriserunrise equals run so slope is 145Step 1 : General form of a difference equation Pn=aPn-1 + bThe next value equals something times the previous value plus some increment.In our compound interest example, a was 1 plus the interest rate and b was zero. In our population models, a was 1 plus the birth rate minus the death rate and b was the recruitment or immigration per time period. In our weasel examples a was 1 plus the reproduction rate and b was the number killed each year by hunters.Step 2. Plot the change from step to steppn+1=apn+bThis looks a lot like the equation for a line (if we think of pn+1 as y and pn as x). This makes sense since the very essence of difference equations is to express the next value as a function of the previous value (we might write next=f(previous) and this is the same as we do for a line: y=f(x)).Pn+1-axispn-axisbThe line pn+1=a pn + bThis is an odd little graph. How would we use it? Let's suppose some pn is some number C. We locate this on the horizontal axis. Then, to find pn+1 we go up to the line and across to the corresponding value on the vertical axis. Call this number D.Pn is CPn+1 is DCWhat comes next? Now D will be pn and we'll seek the next value. We locate D on the horizontal axis and repeat the process.CDCDNow we know three points – three "states" of the system in succession. If we look up at the line and imagine how we have "moved" along it, we can depict how the system has moved.CDThe system "steps along" this lineNow Step 3. Recall that at equilibrium, the system stays the same from one period to the next.Call the value at which the system settles pe "p sub e" or the equilibrium value. It is still governed by the generic difference equation but it looks like thispe=ape+bThis can be solved for pe:pe=b1-aAnd, the equation can be written out in our usual terms, it looks like thispn+1=pnBut this is just the equation for a "45 degree line" – a line with slope 1 that goes through the origin (that is, the point 0,0).Pn+1pnPn+1=pnAny time the system is at equilibrium it will be somewhere on this line – since, by definition, equilibrium is when pn=pn+1Thus, if we draw a 45 degree line on the graph we drew above, we can locate the equilibrium.Note that in the example above our line had a slope of less than 1. What happens if we have a line with a slope greater than 1?For positions both above and below the equilibrium, the tendency is for the system to move AWAY from the equilibrium.The difference we are recognizing here is between STABLE and UNSTABLE equilibria. In a stable equilibrium, a small change in the system results in a "self-correcting" move back to the equilibrium. In an unstable equilibrium, a small perturbation or bump results in a sharp and accelerating movement AWAY from the equilibrium point.Consider these real world examples. Can We Learn from the Slope of the Pn+1=f(Pn) Line?Something we've seen graphically is very interesting. When the line describing our difference equation crosses the 45 degree line with slope less than one we get a stable equilibrium. When the line crosses with a slope greater than one we get an unstable equilibrium.Let's think for a second whether there is any intuition in this. Recall that pe=b1-aConsider a point one unit away from Pe. Since the slope of the line is a the next point would be Pe+a. If a<1 then our new point is closer to Pe than Pe+1 was. If a>1 then the new point is further away.What is a is negative? If we move one unit away from equilibrium, what happens? Our next point is at Pe+a but this is on the other side of Pe since a is negative. A little thinking will get us to the fact that the point after this will again be to the right of Pe. With a negative sloping line our sequence oscillates. But does it converge or diverge. It turns out that the same rule holds as before. For absolute value greater than 1 we get divergence (an unstable equilibrium) and for absolute value less than 1 we get convergence (stable equilibrium).Let's try our step by stepping with the following two diagramsPn+1pnPn+1pnPracticeConsider the difference equation pn+1=1.1pn-10 Pn+1pnWhat are the first five values if p0=2?Plot pn+1 vs. pnAssume that this chart represents the difference equation pn+1=pn-pn-1 Pn+1pnWhat are the first four values if p0=3 and p1=5????Assume that this chart represents the difference equation pn+1=5pn-10 Pn+1pnWhat are the first five values if p0=2?What are the first five values if p0=3?What are the first five values if p0=1?What are the first five values if p0=4?Use this equation (p60) to calculate the equilibrium valuePe=b1-aUse the above information to draw in the "step diagram" for the results of parts a and b above.Assume that this chart represents the difference equation pn+1=0.9pn+25 Pn+1pnWhat are the first four values if p0=150?What are the first four values if p0=240?What are the first four values if p0=300?What are the first four values if p0=350?Use this equation (p60) to calculate the equilibrium valuePe=b1-aUse the above information to draw in the "step diagram" for the results of parts b and c above.Based on what we have learned about how the slope affects the type of equilibrium, draw arrows on the black line in this diagram to indicate where the system would go in the four labeled sectionsPn+1pnABCDUse the "step" method to figure out how this system behaves for each of the three labeled initial points in the diagram below.Pn+1pnABCConsider the curve below. Pn+1pnThink about the fundraising example used in the book (pp64ff). Describe the donation incentives that would give rise to this curve.Based on our finding that a curve crossing the 45 degree line at slope less than one represents a stable equilibrium and one that crosses at slope steeper than 1 an unstable, put arrows on the curve showing how the system would behave.Consider the curve below.Pn+1pnWhat are the first four values if p0=4?What are the first four values if p0=0.5?What are the first four values if p0=7?What are the first four values if p0=9?Type equation here.NotationUse mnemonics whenever possibleSubscripts represent instances of repeated observations or measurements of "same" thingThree dotsReview subscript and variable conventions. ABC, XYZ, ijk.i, j, k subscriptsx,y,z generic variablesn, m, k as the number of elements in a collection subscripted by i, j, kBold upper case for vectorsWith two variables x, y, y is usually the one plotted vertically and the one expressed in terms of the other: y=mx+bOrder of operations and parenthesesExponentiation, Multiplication, Addition, Negation; work from the inside outDo examples using just S0 and S1.Generalize the idea of using subscripts n and n-1. Explain each piece of this equation.Sn=1+RSn-1 for all n≥1Review examples on page 52 and define what "nonlinear" means.Solving difference equationsFind the general solution for Sn.Using EXCEL Avoiding "off by one" errors by being careful about which end of period things happen in.EquilibriumExamples of equilibriumBicycle wheel that ends up stem down, marble in bottom of bowl, "water finds it own level," piece of wood floating in a body of water, rocking boat settles down, chemical reaction balances forward and backward reaction, body of water and water vapor in the air, driving on one side of the roadTotal lack of normative content!Suppose we have a system in which the rule is that each year we add 5% and alternate the sign of our total. Thus, in year one we have 1, in year two -1.05, in year three –(1.05)(-1.05) and so on.Several generic possibilities.ConstantLinear growth or declineAsymptotic growth or declineExponential growth or declineOscillationPracticeMultiple Variable Difference EquationsFrom difference equations to stock and flow modelsstockt+1=stockt+inflowt-outflowt4.5A well-incubated staphylococcus population doubles in about 1 hour. How does the population change from one time period to the next?Let P0 b e the initial population. ThenP1=2P0AndPi=2iPi-1Multiple Difference Equation LabPart I Excel ToolsExcel Skills Introduced/ReviewedAbsolute/relative cell referencesAutofill for formulasNumber formattingXY ScatterplotsTweaking graph layoutRenaming worksheetsAdding a new worksheetAdding spin button control to a worksheetStep by Step InstructionsOpen a new spreadsheet and name the worksheets "Ex 1" "Ex 2" "Ex 3" "Ex 4"and "Ex 5"(sic). You may have to insert a new sheet. Hover over the * to the right of the last worksheet tab to see what command it implements.Open Stokey & Zeckhauser p 49. Go to worksheet "Ex 1".Set up your worksheet as shown here (extend the years out to 20 using autofill):ABCDEF1Death Rate.052Birth Rate.033Initial Pop10045YearPopulation607182Highlight cells B1 and B2 and click on the % button up in the number panel in the ribbon.In cell B6 type the formula=B$3And in the cell B7 type the formula=B6-B1*B6+B2*B6Hit Enter. Select B7 and autofill down. Examine the contents of cell B8. Is the formula correct?NOTE: When we autofill a formula, Excel updates the cell references as we move down or across. Sometimes we want this to be the case (as when our formula says "add up the two numbers to the right") but sometimes we do not (as in this case where we always want the formula to refer to cells B1 and B2). To accomplish this we create an "absolute cell reference" by putting a dollar sign in front of the row or the column or both. In this case, our formula should have been=B6-B$1*B6+B$2*B6We don't need to put a dollar sign in front of the B since we are not planning on dragging the formula across. Fix this in cell B7 and drag the formula down again.5645785-3810Since we don't like the idea of fractional people, let's get rid of the decimal places. Highlight B6 to B26 and click on "Number" up in the middle panel of the ribbon and select the item at the bottom of the drop down menu "More Number Formats."Make the selections as shown and click OK.499999078740Now highlight the cell range A5 to B26 and select "Insert" on the menu bar. The ribbon will show you some chart options:Stop and Think. Do you know the difference between column, bar, and scatter charts?Select scatter. In a scatter chart the data contains both the x and the y coordinates. In column, line, and bar charts Excel just uses only y data and numbers the x-categories 1,2,3,4,5,… (you can supply other labels for the categories, but the point is that Excel is not thinking of the horizontal (for column and line, vertical for bar) axis as numerical data. 2639060-6350Here are our scatterplot choices:5003800309880These differ in terms of whether a line connects the points, whether the line is smoothed or not and whether the points are indicated with a marker. We'll select the second option. The result may look something like this. We’ll do some tweaking. First thing, is adjust the size so it’s about 3 inches wide.477520018415Select the chart if it is not already selected. Some context menu options will appear up on the menu bar:Select layout. We will futz with the axis labels and chart title and legend.Use the Axis Titles button to put a title below the primary horizontal axis. It should say "Year". Then do the same for the primary vertical axis; it should be "Population". Single click on the chart title and change it to "Population of a Totalitarian Country". We only have one variable so the legend is not so important. Single click and delete it. Next click on the chart area and grab a handle on the right side to stretch it out to fill the space where the legend was.Our horizontal axis goes up to 30 or 40 but our data only goes to 20. Click on the Axes button and Primary Horizontal Axis and More Primary Horizontal Axis options. Change the maximum on this axis to 20.Single click on one of the data points in the chart to select the data series and then right click and select "Format Data Series."Under marker options pick a 5 pt circle and under marker fill select no fill and under line style select line weight 1.5. Click OK.Your result should now look something like thisTo prepare your results for printing, select a range of cells that contains all the work and the chart and then click on Page Setup and then on the ribbon under Page Layout select Print Area and Set Print Area. Then, under orientation, select landscape. Then click on the Print Titles button and the Header/Footer tab in the dialog box that pops up. Click on the Custom Header… button and put your name and document title on the right side of the header as shown. Click OK and and OK and then print your results.Go to worksheet "Ex 2" and set it up for the second example on page 49 – the initial values are up to you – I've used 500, 25, and 4%.Enter the correct formula in cell B7 and use autofill to populate the rest of the cells.Go back to the first worksheet and select the chart and click copy (or control-c).Return to Ex 2 and off to the side of the data click and paste.Right click the chart and "Select Data…" In this dialog box, the data on which the chart is based is highlighted. Notice that it refers back to the other worksheet and Excel jumps back to that sheet. Leaving the data range highlighted, click on the Ex 2 sheet tab. Excel should update the data range so that it now refers to the Shaker data of this example. If not, make sure the data range in the dialog box is highlighted and select the data in THIS worksheet – cells A5 to A25 and then click OK.Click on the chart title to make appropriate changes.Prepare for printing as above and print results.LATER: Repeat similar steps for examples 3, 4, and 5 on page 49.Adding Controls to Make It a “Live” SimulationGo back to Ex. 1. Look up at the top of the menu bar to see if you have the “developer tab” in your ribbon:If not go to the and click “Excel Options” at the bottom of the context menu and click “Show developer tab in ribbon”Let your mouse hover over this icon to get its name. Click it to reveal the “controls” you can insert into your worksheet. Hover over each to get its name.Select the “spin button” and draw/click one to the right of your system parameter A control allows us to build an interface for interacting with a user (you). The spin button control allows us to change the value of a cell it is connected with. We have to “format” the control, telling it what cell it controls and how it should behave. Right click on the control and select “format control” and set it as shown below.Click OK and then unselect the button by clicking anywhere else. Now that its handles are gone, the control is in active mode (rather than edit mode). Play with it to see the value of cell c1 change.Spin buttons can only run through integers so we have to do a little further bit of processing here. Let’s replace the contents of cell B1 with the formula=C1/100Now play with your spin button and notice what happens.Let’s do a few things to improve the look of our tool. First, center the contents of C1. Then increase the height of rows A, B, and C so that the spin button will fit neatly within a single row. It may expand when you do this so you’ll have to right click it to get handles and then adjust it back to a smaller size. While you are doing this, move it so that it covers the number showing in C1. Repeat this process to create a spin button for the birth rate and one for the initial population. Note that the latter is not a percentage so we can link it directly to D2. I would suggest that this spin button run from 100 to, say, 1000 with an incremental change of 100.Your final version should look like thisProblem Set ExercisesImplement the Endowment Fund example (p 64) in Excel. Create a data table with a spin button that let’s you control the return on investment, the level of withdrawal, and contributions. Chart Endowment vs. Time.Use Excel to do the two practice problems on p 66.Use Excel to implement the workers/children example on pp66ff. Use controls to let you play with the survival rates and fertility variables.Use Excel to explore the army manpower example on p69ffWhat to Turn InSingle sheet printout from each of examples 1-3.Single sheet printout from each problem above. On these printouts, handwrite any comments/explanations about what the model tells you about the behavior of the system.Describe in words – in terms of how interest gets added to your account – why you would prefer %5 interest compounded daily rather than %5 interest compounded weekly.Per 51.9, describe 5 situations in a field of personal interest in which difference equation logic would be applicable.Two sample problems on page 66 (only do as much as we are currently equipped to do).Every year 10 percent of the public housing units in a particular city deteriorate to the point where they are uninhabitable and must be demolished. Current plans and budget constraints call for the construction of 800 new units per year. Is there an equilibrium number of public housing units, and if so, is it stable?With what we have learned so far we can write the following.Let the current number of housing units be h0. Thenh1=0.9×h0+800And, in fact, that's the general equation for hn too:hn=0.9×hn-1+800Since we haven't worked through calculating an equilibrium, we'll leave it at that for the momentA well-incubated staph population doubles in one hour, but now we introduce white blood cells, each of which can destroy 100 staph germs per hour. Is there an equilibrium, and if so, is it stable?Again, we can only at this point set things up. Let Pn be the number of staph cells at time n.Pn=2×Pn-1-100WCompute the next five terms of each of the following sequences from the given information.x0 = 10, xn+1 = xn + 4 x1=14, x2=18, x3=22, x4=26, x5=30 y0 = ?1, yn+1 =1/yny1=-1, y2=-1, y3=-1, y4=-1, y5=-1x0 = 40, xn+1 = 2xn ? 20 x1=60, x2=100, x3=180, x4=340, x5=660 z0 = 2, zn+1 = zn2 - zn2, 2, 2, 2, 2x0 = 2, x1 = 3, xn+2 = xn+1 + xn 2, 3, 5, 8, 13, 21x0=15, xn =13xn-1+215, 7, 4.333333, 3.444444, 3.148148, 3.049383A population of weasels is growing at rate of 3% per year. Let wn be the number of weasels n years from now and suppose that there are currently 350 weasels.Write a difference equation which describes how the population changes from year to year.wn=1.03n×350Solve the difference equation of part (a). If the population growth continues at the rate of 3%, how many weasels will there be 15 years from now?w15=1.0315×350=1.558×350=545Plot wn versus n for n = 0, 1, 2, . . . , 100.How many years will it take for the population to double?We can look at the chart but we don't get enough detail. Thus, we can use our equation, inserting 700 for wn and solving for n:700=1.03n×350700350=1.03n2=1.03nlog2=nlog1.03log2log1.03=n≈23.5 yearsWe used this logarithm identity:logab=blogaFind limn→∞wn. What does this say about the long-term size of the population? Will this really happen?As time goes to infinity the population grows without bound. Of course, in reality this will not occur. At some point there will be competition for weasel resources and our equation will have to have a negative term of some sort (think of it as the "crowding effect").If the rate of growth of the weasel population in Problem 5 was 5% instead of 3%, how many years would it take for the population to double?log2log1.05=n≈14.2 yearsSuppose that the weasel population of Problem 5 would grow at a rate of 3% a year if left to itself, but poachers kill 6 weasels every year for their fur.Write a difference equation which describes how the population changes from year to year.w1=1.03w0-6w2=1.03w1-6=1.031.03w0-6-6=1.032w0-1.032×6-1.03×6w3=1.03w2-6=1.031.032w0-1.032×6-1.03×6-6This gets messy…. The general expression is easy, though:wn=1.03wn-1-6We notice that this is basically the same problem as the Shaker community example except that the rate term is growth instead of death and the constant change term is death (poaching) instead of recruitment.Solve the difference equation of part (a). How many weasels will there be in 15 years?Yearwn=1.03n×350wn=1.03wn-1-603503501360.5354.322371.315358.76963382.4545363.35274393.9281368.07335405.7459372.93556417.9183377.94357430.4559383.10188443.3695388.41499456.6706393.887310470.3707399.52411484.4819405.329712499.0163411.309613513.9868417.468914529.4064423.812915545.2886430.3473Find limn→∞wn. What does this say about the long-term size of the population?Again, the population increases without bounds.Will the population eventually double? If so, how long will this take?42 yearsPlot ωn versus n for n = 0, 1, 2, . . . , 100.Suppose that the weasel population of Problem 5 would grow at a rate of 3% a year if left to itself, but poachers kill 15 weasels every year for their fur.Write a difference equation which describes how the population changes from year to year.wn=1.03wn-1-15Solve the difference equation of part (a). How many weasels will there be in 15 years?Find limn→∞wn. What does this say about the long-term size of the population?0Will the population eventually double? If so, how long will this takeNeverWill the population eventually die out? If so, how long will this take?39 yearsPlot wn versus n for n = 0, 1, 2, . . . , 100. ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download