(42S) Rabbits vs. Foxes
|
02-08-2020, 02:25 PM
Post: #1
|
|||
|
|||
(42S) Rabbits vs. Foxes
Introduction
The program presented today is based on the Rabbits vs. Foxes program for the HP 25 (see source below). The program determines the population of rabbits and foxes over time as modeled by the differential equations: Change in Rabbits: dr/dt = 2 * r - α * r * f Change of Foxes: df/dt = -f + α * r * f where: r = population of rabbits f = population of foxes α = probability of a rabbit encounters a fox h = step This is approximated by Euler's method. The HP Prime program RABBIT25 displays a print screen of results of the desired amount of iterations. The HP 42S program RAB25 displays the results one step at time in the format rrrrr.fffff (rabbits.foxes), like the original HP 25 program. HP 42S/Free42/DM42 Program RAB25 Code: 00 { 58-Byte Prgm } Note: You can replace STOP with PSE, as many as you like, if you don't want to press R/S after each step. Instructions: Store α in R00, store h in R01, enter initial rabbit population Example Initial Populations: Rabbits: r = 300 Fixes: f = 150 α = 0.01 h = 0.02 Iter: Rabbits.Foxes (rrrrr.ffff) 0: 300.00150 1: 303.00156 2: 305.00162 3: 307.00169 4: 309.00176 5: 311.00183 6: 312.00191 7: 312.00199 8: 312.00207 9: 312.00216 10: 311.00225 11: 309.00235 12: 307.00245 13: 304.00255 14: 301.00265 15: 297.00276 Source: Randall B. Neff and Lynn Tilman "An Example of HP-25 Programming" Hewlett-Packard Journal: November 1975. pg. 6 Blog post: http://edspi31415.blogspot.com/2020/02/h...foxes.html |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
(42S) Rabbits vs. Foxes - Eddie W. Shore - 02-08-2020 02:25 PM
RE: (42S) Rabbits vs. Foxes - SlideRule - 02-08-2020, 04:02 PM
RE: (42S) Rabbits vs. Foxes - PedroLeiva - 02-08-2020, 05:23 PM
|
User(s) browsing this thread: 1 Guest(s)