desolve_odeint

## Description

We can compute a numerical solution for a system of first-order ordinary differential equations using odeint from scipy.integrate module. The following Sage commands can be used to find a numerical solution to the Lotka-Volterra predator-prey equations:

(1)
\begin{align} \frac{dx}{dt} & = x - xy \\ \frac{dy}{dt} & = -y + xy \\ x(0) & = 0.5 \\ y(0) & = 2, \end{align}

where $0 \leq t \leq 10$ with a step size of $h = 0.1$. odeint implements LSODA, and it automatically selects between nonstiff (Adams) and stiff (BDF) methods. It uses the nonstiff method initially, and dynamically monitors data in order to decide which method to use. More information about the scipy.integrate module can be found at https://docs.scipy.org/doc/scipy/reference/integrate.html#module-scipy.integrate.

## Sage Cell

#### Code

x,y=var('x,y')
f=[x*(1-y),-y*(1-x)]
sol=desolve_odeint(f,[0.5,2],srange(0,10,0.1),[x,y])
p=line(zip(sol[:,0],sol[:,1]))
p.show()


None

## Tags

Primary Tags: differential equations

Secondary Tags: numerical methods

A list of possible tags can be found at The WeBWorK Open Problem Library. For linear algebra tags see the Curated Courses Project.