The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
(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 }
01▸LBL "RAB25"
02 STO 02
03 R↓
04 STO 03
05 FIX 05
06▸LBL 05
07 RCL 02
08 ENTER
09 ENTER
10 RCL 03
11 RCL 00
12 ×
13 ×
14 STO 04
15 X<>Y
16 -
17 RCL 01
18 ×
19 +
20 X<0?
21 0
22 STO 02
23 RCL 03
24 2
25 ×
26 RCL 04
27 -
28 RCL 01
29 ×
30 RCL 03
31 +
32 X<0?
33 0
34 STO 03
35 IP
36 RCL 02
37 IP
38 1ᴇ5
39 ÷
40 +
41 STOP
42 GTO 05
43 .END.

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
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


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)