**fd_predator_prey_test**,
a C code which
calls fd_predator_prey() to
apply the finite difference method to estimate solutions of a
pair of ordinary differential equations that model the behavior of
a pair of predator and prey populations.

The computer code and data files described and made available on this web page are distributed under the MIT license

fd_predator_prey, a C code which applies the finite difference method (FDM) to a predator-prey system with time dependence and no spatial variation.

- fd_predator_prey_test.sh, runs all the tests.
- fd_predator_prey_test.txt, the output file.

The program writes out a file of the solution data. The data can be plotted by MATLAB, for instance, using commands like this:

trf = load ( 'trf_10000.txt' ); plot ( trf(:,1), trf(:,2), 'g-', trf(:,1), trf(:,3), 'r-' ) title ( 'A Predator Prey System' ); xlabel ( 'Time' ); ylabel ( 'Population' );

**TRF_100** uses 100 timesteps, which are not enough.

- trf_100.txt, the data.
- trf_100.png, a plot.

**TRF_1000** uses 1000 timesteps; the solution does not explode,
and seems to show periodicity, except that it is clearly growing.

- trf_1000.txt, a table of the prey and predator values using 1000 steps.
- trf_1000.png, a plot.

**TRF_10000** uses 10000 timesteps. The cyclic nature of
the solution is clear.

- trf_10000.txt, a table of the prey and predator values using 10000 steps.
- trf_10000.png, a plot.