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 
Rabbit vs. Foxes
02-08-2020, 02:26 PM
Post: #1
Rabbit vs. Foxes
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 Prime Program RABBIT25
Code:

EXPORT RABBIT25()
BEGIN
// 2020-01-20 EWS
// Based on the Rabbits vs
// Foxes HP 25 program
LOCAL α,h,r,f,k,n,a;

// initialize and input
INPUT({α,h,r,f,n},
"Rabbits vs Foxes",
{"α: ","h: ","r0:","f0:","n: "},
{"α","h","inital # rabbits",
"initial # foxes",
"# iterations"});
L0:={r}; L1:={f};


// compute data
MSGBOX("L0 = rabbit population,
L1 = fox population;
(0,1,2,...,n), size n+1");
HFormat:=0;
PRINT();
PRINT("Rabbits vs Foxes");
FOR k FROM 0 TO n DO
IF k≠0 THEN
a:=α*r*f;
r:=r+h*(2*r-a);
f:=f+h*(−f+a);
END;
PRINT(k+" R: "+IP(r)+" F: "+
IP(f));
END;


// end of program
END;

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
Rabbit vs. Foxes - Eddie W. Shore - 02-08-2020 02:26 PM
RE: Rabbit vs. Foxes - Mark Power - 02-08-2020, 07:52 PM



User(s) browsing this thread: 1 Guest(s)