Ideas

Do this chapter in conjunction with system dynamics models? Two sessions. Then do Schelling with exercises?

Assignment

Read chapter. Write up responses to example problems on page 49.

Rhetorical Tasks

  1. Simple examples.
  2. Notation
  3. The Math
  4. Equilibrium
  5. Stocks and Flows

Concepts and Vocabulary

Notation, 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,

Lecture

  1. Consider the following sequence of numbers

1 1 2 3 5 8 …

  1. Three dots = ellipsis = "and so on"
  2. Let's refer to each of these as an "sequence member."
  3. And so let's call the first one "sequence member 1" and so on

Sequence Member 11

Sequence Member 21

Sequence Member 32

  1. But I tire of writing out "sequence member" so I'm going to abbreviate it "s"

s43

s55

s68

  1. But 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.

s713

s821

s934

  1. Obviously, 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":

, i= 1,2,3,…

  1. 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.
  2. In particular, if I wanted to say that one element was equal to the one before it times 2, I could write
  1. Let'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?
  1. or
  1. and

=

Examples

4.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. Then

4.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. Then

4.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.

4.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. Then

In year 2 we have

And then, in year I,

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 Equations

Prefatory Notes

Generic Equation for a Straight Line

The "45 Degree Line"

Step 1 : General form of a difference equation

Pn=aPn-1 + b

The 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 step

This 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)).

This 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.

What 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.

Now 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.

Now

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 this

This can be solved for pe:

And, the equation can be written out in our usual terms, it looks like this

But 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).

Any time the system is at equilibrium it will be somewhere on this line – since, by definition, equilibrium is when pn=pn+1

Thus, 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.


/


/

What 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

Consider 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 diagrams

Practice

  1. Consider the difference equation

/ a)What are the first five values if p0=2?
b)Plot pn+1 vs. pn
  1. Assume that this chart represents the difference equation

/ a)What are the first four values if p0=3 and p1=5?
a)?
b)?
c)?
d)
  1. Assume that this chart represents the difference equation

/ c)What are the first five values if p0=2?
d)What are the first five values if p0=3?
e)What are the first five values if p0=1?
f)What are the first five values if p0=4?
g)Use this equation (p60) to calculate the equilibrium value

h)Use the above information to draw in the "step diagram" for the results of parts a and b above.
  1. Assume that this chart represents the difference equation

/ b)What are the first four values if p0=150?
e)What are the first fourvalues if p0=240?
f)What are the first fourvalues if p0=300?
g)What are the first fourvalues if p0=350?
h)Use this equation (p60) to calculate the equilibrium value

i)Use the above information to draw in the "step diagram" for the results of parts b and c above.
  1. 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 sections

  1. Use the "step" method to figure out how this system behaves for each of the three labeled initial points in the diagram below.

  1. Consider the curve below.

/ a)Think about the fundraising example used in the book (pp64ff). Describe the donation incentives that would give rise to this curve.
b)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.
  1. Consider the curve below.

/ a)What are the first four values if p0=4?
b)What are the first four values if p0=0.5?
c)What are the first four values if p0=7?
d)What are the first four values if p0=9?
  1. Notation
  2. Use mnemonics whenever possible
  3. Subscripts represent instances of repeated observations or measurements of "same" thing
  4. Three dots
  5. Review subscript and variable conventions. ABC, XYZ, ijk.
  6. i, j, k subscripts
  7. x,y,z generic variables
  8. n, m, k as the number of elements in a collection subscripted by i, j, k
  9. Bold upper case for vectors
  10. With two variables x, y, y is usually the one plotted vertically and the one expressed in terms of the other: y=mx+b
  11. Order of operations and parentheses
  12. Exponentiation, Multiplication, Addition, Negation; work from the inside out
  1. Do examples using just S0 and S1.
  2. Generalize the idea of using subscriptsn and n-1. Explain each piece of this equation.
  1. Review examples on page 52 and define what "nonlinear" means.
  2. Solving difference equations
  3. Find the general solution for Sn.
  4. Using EXCEL
  5. Avoiding "off by one" errors by being careful about which end of period things happen in.
  6. Equilibrium
  7. Examples of equilibrium
  8. Bicycle 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 road
  9. Total lack of normative content!
  10. 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.

21.4.Several generic possibilities.

21.4.1.Constant

21.4.2.Linear growth or decline

21.4.3.Asymptotic growth or decline

21.4.4.Exponential growth or decline

21.4.5.Oscillation

21.5.Practice

21.6.Multiple Variable Difference Equations

21.7.From difference equations to stock and flow models

21.8.

4.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. Then

And

Multiple

Difference Equation Lab

Part I Excel Tools

Excel Skills Introduced/Reviewed

S&ZCh4-Difference-Equations.docx111 February 2009

Absolute/relative cell references

Autofill for formulas

Number formatting

XY Scatterplots

Tweaking graph layout

Renaming worksheets

Adding a new worksheet

Adding spin button control to a worksheet

S&ZCh4-Difference-Equations.docx111 February 2009

Step by Step Instructions

  1. Open a new spreadsheet and name the worksheets "Ex 1" "Ex 2" "Ex 3" "Ex 4"and "Ex 5"(sic[1]). 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.
  2. Open Stokey & Zeckhauser p 49. Go to worksheet "Ex 1".
  3. Set up your worksheet as shown here (extend the years out to 20 using autofill):

A / B / C / D / E / F
1 / Death Rate / .05
2 / Birth Rate / .03
3 / Initial Pop / 100
4
5 / Year / Population
6 / 0
7 / 1
8 / 2
  1. Highlight cells B1 and B2 and click on the % button up in the number panel in the ribbon.
  2. In cell B6 type the formula

=B$3

And in the cell B7 type the formula[2]

=B6-B1*B6+B2*B6

Hit 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*B6

  1. We 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.
  2. Since 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."
  3. Make the selections as shown and click OK.
  1. Now highlight the cell range A5 to B26 and select "Insert" on the menu bar. The ribbon will show you some chart options:
  2. Stop and Think. Do you know the difference between column, bar, and scatter charts?
  3. 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.
  4. Here are our scatterplot choices:
  1. These 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.
  2. Select the chart if it is not already selected. Some context menu options will appear up on the menu bar:
  1. Select layout. We will futz with the axis labels and chart title and legend.
  1. 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.
  2. 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.
  1. 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."
  2. 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.
  3. Your result should now look something like this
  1. To 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.
  1. 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%.
  1. Enter the correct formula in cell B7 and use autofill to populate the rest of the cells.
  2. Go back to the first worksheet and select the chart and click copy (or control-c).
  3. Return to Ex 2 and off to the side of the data click and paste.
  4. 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.