population.ode 608 B

1234567891011121314151617181920212223242526272829303132
  1. # This is an example from population biology (the predator-prey
  2. # equations of Lotka and Volterra). You may run it by doing:
  3. #
  4. # ode < population.ode | graph -T X -C
  5. #
  6. # or alternatively, to get a real-time plot,
  7. #
  8. # ode < population.ode | graph -T X -C -x 0 10 -y 0 3
  9. #
  10. # The plot shows the population of the prey as a function of time.
  11. # The curve oscillates, because as the prey die out, the predators
  12. # starve.
  13. # The differential equations are:
  14. # x' = (A - By) x
  15. # y' = (Cx - D) y
  16. # A,B,C,D > 0
  17. x' = (A - B*y) * x
  18. y' = (C*x - D) * y
  19. A = 1
  20. B = 1
  21. C = 1
  22. D = 1
  23. x = 3
  24. y = 1
  25. print t, x
  26. step 0, 10