# Introduction to Predator-Prey Models Using TI-82, MathCad and Stella

## Abstract

This project will enable the student to explore mathematical modeling through the idea of closed ecological systems. To begin the modeling process, the student will research such systems and draw diagrams of them. The purpose of this is to promote general interest in the activities by allowing students to think about models which are of particular interest to them. Since most systems are very complicated, this project will use a simple predator-prey model, foxes and rabbits, to show how mathematical models are built. The project will also expose the student to a variety of technological tools in an elementary step-by-step manner designed for the beginner. The student will experiment with the TI-82 calculator, MathCad (v3.1), and Stella II (v2.2.2) using the predator-prey model. [Earlier software versions may work also.] To conclude the project, students will write essays describing approaches they would use to model their original ecosystems.

## Sequence of Activities

PART I: 1) Groups brainstorm on types of ecosystems

2) Groups pick one system of interest to research

3) Groups list variables affecting the ecosystems

4) Groups develop a diagram to model the system

PART II: Introduce simple predator-prey model: Foxes and Rabbits

PART III: Develop and explore the foxes and rabbits model using each of the following:

1) TI-82 2) MathCad 3) Stella

PART IV: 1) Groups analyze data from explorations

2) Groups write essay on how they would model the original ecosystem

3) Extension: groups actually model their original ecosystem

## Activities - Part I (Group Research and Diagrams):

The teacher should lead a discussion of how ecosystems work in general, choosing one or two examples, generating a list of variables affecting the system, and drawing a flow chart. For example, the teacher might discuss

1) cows and hay supply,

2) protected animals such as otters and the population of sharks,

3) fish and algae,

4) whales and krill, or

5) population and disease.

Example: Cows and Hay Supply

 Variables that affect cows 1) amount of hay supply 2) number of cows eating the hay 3) minimal amount of hay needed 4) water supply 5) disease 6) natural death rate Variables that affect hay 1) number of cows grazing 2) amount eaten per cow 3) rain/water 4) provisions for winter storage 5) molds 6) insects

## Activities - Part II (Introduction to the Foxes and Rabbits Problem)

Ecosystems, like most real-life situations, are complicated. In order to model them, one must make simplifying assumptions. In this set of activities a very simple model of an ecosystem is studied. A certain territory exists in which one finds foxes (the predators) and rabbits (the prey). The growth or decline of these populations are closely interrelated. There are many factors which affect the size of each population, including the following:

• births
• deaths for various reasons
• old age
• disease and toxins in the environment
• food/water availability
• attack by other animals or people
• extreme weather conditions
• immigration from/emigration to adjacent territories

See the NCSSM Calculus textbook (Chapter 4: Numerical Solutions to Differential Equations) for a more complete discussion of this model. In that discussion, factors which influence both populations have been simplified and combined into four major parameters (a, b, c, d) which refer to the following:

Change in Rabbit Population

a: Growth Factor for Rabbits b: Kill Rate of Rabbits by Foxes

Change in Fox Population

c: Rate of Decline for Foxes d: Rate of Increase for Foxes

At the beginning of this study, there are 200 rabbits and 50 foxes (by assumption). Letting the variable u represent rabbits and v represent foxes, and letting the basic time unit (months) start at 0, yields the following starting values:

u0=200 and v0=50.

At the end of one month, the populations have changed as follows:

(Rabbits) u1=u0+a*u0-b*u0*v0 and

(Foxes) v1=v0-c*v0+d*u0*v0.

Notice that all of the factors that influence the rabbit population (given in the list at the beginning of this section) except the rate at which rabbits are killed by foxes have been combined into parameter a. The rate at which rabbits are killed by foxes is given by parameter b. The a*uo term represents the growth rate for the rabbit population, if there were no foxes present. The b*uo*vo term represents an interaction between rabbits and foxes. It is negative, since a rabbit-fox interaction frequently results in the loss of a rabbit. All of the factors influencing the fox population have been incorporated into the parameters c and d. In the absence of rabbits, the fox population declines (note the -c*vo term). Interaction between rabbits and foxes results in the growth of the fox population (note the +d*uo*vo term).

In general, the populations in any month n are determined from the populations in the preceding month, using the equations,

(Rabbits) un=un-1+a*un-1-b*un-1*vn-1 and

(Foxes) vn=vn-1-c*vn-1+d*un-1*vn-1.

When the MathCad model is created, the following equations (equivalent to those above) are used instead:

(Rabbits) un+1=un+a*un-b*un*vn and

(Foxes) vn+1=vn-c*vn+d*un*vn.

## Activities - Part III (Exploration)

This section includes 4 parts: 1. worksheets for students to use after they have read the detailed instructions included in each subsequent part; 2. using the TI-82; 3. using MathCad; and 4. using Stella.

## Worksheet

Instructions: Model the foxes and rabbits situation for each technological tool indicated. Change the values of a, b, c, and d in a systematic way. Record your results and observations of the graphs. Look for peaks and valleys. Note the behavior of the populations relative to each other. Try to find values for each rate that seem to make the system stable.

 TI-82 a b c d Observations
 MathCad a b c d Observations
 Stella a b c d Observations

## Using the TI-82 Calculator to Develop a Predator-Prey Model

It is assumed that you are familiar with a graphing calculator, and that you have worked particularly with the TI-82. A TI-82 manual might be helpful for the novice. Instructions for each step of the process are numbered and printed in bold letters. Following many instructions, detailed hints and notes are given in boxes.

To build the model using the TI-82 proceed as follows:

1. Set proper mode of operation and set up the equations:

un=un-1 + A*un-1 - B*un-1*vn-1

vn=vn-1 - C*vn-1 + D*un-1*vn-1

Press the key. Using the arrow keys to move around and thekey to select. Be certain that the following items in bold are selected:

Normal Sci Eng

Float 0123456789

Func Par Pol Seq

Connected Dot

Sequential Simul

FullScreen Split

To enter the equations, press the key. Enter formulas for un and vn as shown. To get [un-1] press key. To find [vn-1] press key. Press to return to the home screen.

2. On the Home Screen Store values for a, b, c, and d:

A=.035

B=.001

C=.03

D=.0001

At the Home Screen, press the value, then the key, then the letter (which requires use of the key), and finally press . You may want to put between each of the values stored, so that all the values are stored using one line. This makes it easier to change the values later. To do this, press rather than between values. Press only after variable D is stored.

Your screen should look like this:

.035A:.001B:.03C:.0001D

Note that these are the values you will change during your exploration.

3. Press the key, then enter the following values:

WINDOW FORMAT WINDOW FORMAT

UnStart=200 Time Web

VnStart= 50 RectGC PolarGC

nStart=0 CoordOn CoordOff

nMin=0 GridOff GridOn

nMax=400 AxesOn AxesOff

Xmin=0 LabelOff LabelOn

Xmax=400

Xscl=0

Ymin=0

Ymax=1000

Yscl=0

4. Press to see graphs of the populations over time.

Remember that you can use the key to find the coordinates of points on your graph as you explore the graphs.

If graphs do not appear when you expect them, you might try the following:

5. Create graph for rabbits vs. foxes.

The following program can be used to generate the graph. Remember that letters require use of the key. Parentheses around a word, e.g. (NEW) and (U/V), indicate that you need to use the arrow keys to move to that word on the screen in order to find the menu item you need.

PROGRAM STEPS KEY SEQUENCE TO ENTER:

PROGRAM:PREDPREY

Type : PREDPREY

:PlotsOff [STAT PLOT]

:Fn Off [Y-VARS]

:Clr Draw [DRAW]

:UnStartR R

:VnStartF F

:Pt-On (R,F) [DRAW] (POINTS) 1

Type: R,F)

:FOR (I, nMin, nMax) 4 I, 1 (U/V) 4,

1 (U/V) 5 )

:Rt+(AR-BRF)R Type: R+ (AR-BRF) R

:F +(-CF+DRF)F Type: F+ (-CF+DRF) F

:Pt-On (R,F) [DRAW] (POINTS) 1

Type: R,F)

:End 7

To get to Home Screen [QUIT]

You will also need to set values as follows:

WINDOW FORMAT

UnStart= 200

VnStart= 50

nStart= 0

nMin= 0

nMax= 400

Xmin= 0

Xmax= 600

Xscl= 200

Ymin= 0

Ymax= 100

Yscl= 50

To run press [PRGM] program#

## Using MathCad to Develop a Predator-Prey Model

You should begin with a MathCad working window. If you have not worked with MathCad previously, you might want to try the Getting Started option under the Help menu in order to become familiar with the MathCad environment. Instructions for each step of the process are numbered and printed in bold letters. Following many instructions detailed hints and notes are given in boxes.

MathCad's strengths as a versatile tool make it somewhat confusing at first. First of all, you should know that although the final product looks like a document produced by a word processor, it isn't! Rather, it is a collection of items of different types-formulas, labels, graphs, etc. Each one of these should be thought of as a block unto itself, BUT blocks become interrelated through the use of variables. For example, after variables have been given values, the variable names can be used in formulas and graphs.

To build the model in MathCad, proceed as follows:

1. Set up parameters as follows:

a:=.035

b:=.001

c:=.03

d:=.0001

Hint: Getting Started/Setting Up the Screen

If you are having trouble reading the screen, you can make things larger by using Expanded View under the Window menu.

MathCad operates in two different calculation modes (Automatic Mode or Manual Mode). These appear under the Math menu. While setting up your model, work in Manual Mode. While exploring your model, work in Automatic Mode. If you are in Manual Mode and you want MathCad to perform a calculation or draw a graph, you must press the key.

Hint: To delete something from the screen, you can use Cut under the Edit menu to remove highlighted items from the screen.

Exploration: The Difference Between = and :=

[You might want to switch to Automatic Mode for this exercise.]

When you type an expression followed by an = sign, the expression is immediately evaluated, e.g. you type 2+3= anywhere on the screen (Don't put in spaces!) and MathCad automatically evaluates to produce 5 so that what appears on the screen is 2+3=5. If you edit the 2 to make it a 7, the expression automatically becomes 7+3=10 when you press enter. (Tip: Consider the expression 2+3=5. If you want to edit the 2, put the tip of the arrow on the 2 and "click." If you want to edit 2+3, "click" on the +. If you want to edit the entire expression, "click" on the =.)

When you type a variable name, followed by :=, followed by an expression, you are giving MathCad a formula. It evaluates the expression and assigns that value to the variable. For example, type the following:

slope:=2

intercept:=5

x:=6

y:=slope*x+intercept

y=

[When you finish exploring, use Cut (under Edit menu) to get rid of these items from your screen. You might also want to switch back to Manual Mode (under Math menu).]

Hint: Placement of Items on the Screen

Sometimes when you place a new item too close to an old item, it obscures old items partially or totally. To correct this situation, use the Separate Regions option under the Edit menu. Also remember that you can move items by "clicking and dragging."

2. Set up parameters as follows:

u0:=200

v0:=50

Hint: Typing Subscripts

To get a subscript in an expression, e.g. x3, type x[3. The left bracket moves the cursor to the subscript position. To get the expression x3+1, type x[3+1. Notice the effect of the on the position of the cursor. One of the features of MathCad that can be confusing (and annoying!) at first is keeping track of your location in an expression when you are typing and editing. Play around with the arrow keys to gain familiarity with this.

3. Set up iteration as follows:

n:=0..400

Hint: To get n:=0..400, you type n:0;400. This sets up 401 iterations on the variable n, namely n=0,1,2,3, ... ,400.

4. Set up equations as follows:

Hint: To set up matrices, use Matrices under the Math Menu. These matrices are 2x1 (i.e. 2 rows and 1 column).

Why use matrices for equations?

We must enter the equations in matrices, because they are interrelated. Normally, MathCad evaluates from top to bottom of page. In this situation, calculating values in the first equation involves values from the second equation, and vice-versa. Neither formula can be iterated completely before the other; evaluation of each formula must occur for each n value before the (n+1)st value can be found!

Note: In using MathCad, one should enter equations in the given form with un+1 on left side and un on the right.

5. Set up time series graph as follows:

Note: You may want to activate Automatic Mode under the Math menu at this point.

To set up graph, use Create Graph under the Graphics menu.

"Click" on the black square, then enter an appropriate variable or number.

To draw two graphs (un and vn), first enter un, followed by comma, followed by vn.

To force MathCad to draw a graph, you must "click" outside the graph area after you have set up the graph details.

6. Set up "rabbits and foxes" graph as follows:

7. A finished MathCad model for this problem appears below.

Note that text has been added and items may be in different locations from the model you have created. You may arrange your final model in any workable way you like. Remember that variables can be defined anywhere on the page ABOVE the location in which they are used! You will probably find it easier to explore the model if all items can be viewed on the screen at one time.

## Using Stella to Develop a Predator-Prey Model

It is assumed that you have a Stella Diagram Frame on your screen and that you are familiar with Building Blocks, Tools, and Objects icons shown at the top of the window and listed below. Instructions for each step of the process are numbered and printed in bold letters. Following many instructions detailed hints and notes are given are given in boxes.

 Building Blocks Tools Objects stock hand sector flow paintbrush text converter dynamite graph connector ghost table

This model is built around the population of rabbits and foxes.

1. Begin by creating a stock box for rabbits and one for foxes.

Label each box appropriately. Remember that you can move items around as you develop your model by "dragging" them around the screen.

2. Create a flow symbol which leads into each of the stock boxes.

The population of rabbits and foxes is changed by using the flow symbol, and variables that influence the flow are introduced through the converter circles and the connector arrows.

Click on the flow icon at the top of the window. Then, "click and drag" beginning outside the stock box and moving the pointer into the box. Label the flows: "Change in rabbit population" or "Change in fox population" as appropriate.

3. Create converter circles near the rabbits diagram to represent "a Growth Factor for Rabbits" and "b Kill Rate for Foxes." Create converter circles near the foxes diagram to represent "c Rate of Decline for Foxes" and "d Rate of Increase for Foxes."

4. Connect converter circles "a" and "b" to the flow symbol for "Change in rabbit population." Connect the converter circles "c" and "d" to the flow symbols for "Change in fox population."

Click on the connector icon at the top of the window. Then, "click and drag" beginning INSIDE the appropriate converter circle and ending INSIDE the appropriate circle in the flow symbol.

5. Draw a connector arrow from the "Rabbits" stock box to the "Change in Rabbit Population" circle in the flow symbol. In a similar way, connect the corresponding symbols for Foxes.

This is done because the change in the rabbit population is significantly affected by the size of the current population.

6. Draw a connector arrow from the "Rabbits" stock box to the "Change in Fox Population" symbol. In a similar way, connect the "Foxes" to the "Change in Rabbit Population."

This is done because the rabbit and fox populations are interdependent.

Note: If you try to do something and Stella will not let you complete the task, you MAY be trying to do the wrong thing! For example, connecting the "Foxes" box to the "Rabbits" box cannot be done because the fox population affects the CHANGE in the rabbit population according to this way of modeling.

There are two modes of operation for Stella, one represented by the globe symbol on the left edge of the window and the other represented by the x2 symbol. Click either icon in order to toggle from one icon to the other. Make certain that the x2 symbol is showing.

7. Write equations:

a_Growth_Factor_for_Rabbits*Rabbits-

b_Kill_Rate_of_Rabbits_by_Foxes * Rabbits * Foxes

Set for "BIFLOW".

Hint: Do not try to type this equation directly from the keyboard! "Click" in the circle next to the word "BIFLOW."

"Change in Rabbit Population" occurs in a very specific way, according to this model. To describe it, "double click" on the flow diagram. A new window appears in which an equation can be entered to describe the flow. Recall the formula developed earlier. Enter the formula as above by "clicking" the "Required Inputs" list and the calculator keypad.

In a similar way, enter the following equation for "Change in Fox Population":

-c_Rate_of_Decline_for_Foxes*Foxes+

d_Rate_of_Increase_for_Foxes * Foxes * Rabbits

Set for "BIFLOW".

8. Enter initial populations:

initial rabbit population is 200

initial fox population is 50

Enter these values into the stock boxes for Rabbits and Foxes. Do this by "double-clicking" the Rabbits stock box and "clicking" the numbers from the keypad.

9. Enter the following starting values in the converter circles which store the parameter values:

a = .05 b = .001 c = .03 d = .0002

Notice that each of the four converter circles has a "?", indicating that these values have not yet been entered.

These are the values which you will change later as you explore the model.

10. In the Run menu, choose "Time Specs." Set "Length of Simulation" to run from 0 to 400 with DT=1. Leave the other items unchanged.

11. Create a Time Series graph of the rabbit and fox population over time.

To create the Time Series graph, "click" the graph icon at the top of the window. Then, "click" anywhere on the modeling window. The graph window will appear. "Double click" in the graph window, and an input window appears. Under Graph Type, select "Time Series." From the "Allowable" list, "click" on Foxes and then "click" on the ">>" key to select Foxes. In a similar way, select Rabbits. In the "Selected" window, "click" on Foxes, "shift-click" on Rabbits. "Click" on one of the vertical arrow symbols to the right of the box. Set the scale as follows: Min=0 Max=400 "Click" Set. Click "OK" Notice that foxes have been labeled "1" and rabbits have been labeled "2". You can expect two lines in the time series graph, each representing one of the populations. Run. After looking at the graph, close the window and rename this graph by "clicking" on "Graph 1" and editing the name.

12. Create a Scatter graph of foxes vs. rabbits.

To create the Scatter graph, "click" the graph icon at the top of the window. Then, "click" anywhere on the modeling window. The graph window will appear. "Double click" in the graph window, and an input window appears. Under Graph Type, select "Scatter." From the "Allowable" list, "click" on Foxes and then "click" on the ">>" key to select Foxes. In a similar way, select Rabbits. In the "Selected" window, "click" on Foxes, "shift-click" on Rabbits. "Click" on one of the vertical arrow symbols to the right of the box. Set the scale as follows: Min=0 Max=400. "Click" to Set. "Click" to OK. Run. Close the graph window and rename this graph as above.

13. Use the Stella model and the worksheet to explore what happens to the rabbit and fox populations as the parameters a, b, c, and d are changed. Record your results on the worksheet.

See next page for a completed diagram of the Stella Model.

## Activities - Part IV (Conclusion)

QUESTIONS AFTER EXPLORATIONS:

1) What relationships do you see between the predator and the prey?

2) What happened when you changed the value of the rates a, b, c, and d?

3) When did the population of the predator peak? How about the prey? Did one affect the other?

4) Were both cycles periodic? Did they have the same period? Did they have the same amplitude?

5) Could you predict when the peaks and valleys would occur?

6) Did you find a stable ecosystem? If so, what were the values for a, b, c, and/or d during this stability? How could you tell the system was stable?

7) Which technology best described the relationship to you? How and why?

8) Which technology was the easiest to use? Explain.

9) Which was the most difficult to use? Explain.

10) Write a short essay explaining how you would begin to model your original ecosystem. Describe the technology you would use, and the problems you would anticipate because of the complexity of your problem.

EXTENSION: Actually perform the project described in #10.

## Bibliography

Bartkovich, Kevin, John Goebel, and Julie Graves. Untitled Calculus. North Carolina School of Science and Mathematics, Durham, North Carolina.

The following may be obtained from COMAP (The Consortium for Mathematics and Its Applications)

COMAP, Inc.

Suite 210

57 Bedford Street

Lexington, MA 012173-4496

1-800-77-COMAP

Giordano, Frank R. and Stanley C. Leja. Competitive Hunter Models. UM #628. \$3.

Greenwell, Raymond N. Whales and Krill: A Mathematical Model. #UM 610. \$3.

Greenwell, Raymond N. and Ho Kuen Ng. The Ricker Salmon Model. #UM 653. \$3.

Horelick, Brindell and Sinan Koont. Epidemic. UM #73. \$3.

Woodrow Wilson Leadership Program in Mathematics lpt@www.woodrow.org
The Woodrow Wilson National Fellowship Foundation webmaster@woodrow.org
CN 5281, Princeton NJ 08543-5281 Tel:(609)452-7007 Fax:(609)452-0066