Jupyter Snippet CB2nd 07_lotka
Jupyter Snippet CB2nd 07_lotka
15.7. Analyzing a nonlinear differential system — Lotka-Volterra (predator-prey) equations
from sympy import *
init_printing(pretty_print=True)
var('x y')
var('a b c d', positive=True)
f = x * (a - b * y)
g = -y * (c - d * x)
solve([f, g], (x, y))
(x0, y0), (x1, y1) = _
M = Matrix((f, g))
M
J = M.jacobian((x, y))
J
M0 = J.subs(x, x0).subs(y, y0)
M0
M0.eigenvals()
M1 = J.subs(x, x1).subs(y, y1)
M1
M1.eigenvals()