Book Image

IPython Interactive Computing and Visualization Cookbook

By : Cyrille Rossant
Book Image

IPython Interactive Computing and Visualization Cookbook

By: Cyrille Rossant

Overview of this book

Table of Contents (22 chapters)
IPython Interactive Computing and Visualization Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Analyzing a nonlinear differential system – Lotka-Volterra (predator-prey) equations


Here, we will conduct a brief analytical study of a famous nonlinear differential system: the Lotka-Volterra equations, also known as predator-prey equations. These equations are first-order differential equations that describe the evolution of two interacting populations (for example, sharks and sardines), where the predators eat the prey. This example illustrates how to obtain exact expressions and results about fixed points and their stability with SymPy.

Getting ready

For this recipe, knowing the basics of linear and nonlinear systems of differential equations is recommended.

How to do it...

  1. Let's create some symbols:

    In [1]: from sympy import *
            init_printing() 
    In [2]: var('x y')
            var('a b c d', positive=True)
    Out[2]: (a, b, c, d)
  2. The variables x and y represent the populations of the prey and predators, respectively. The parameters a, b, c, and d are strictly positive parameters (described...