Ask Your Question

Revision history [back]

Most of Sage's numerics is done via Numpy/Scipy which is included in Sage and usable from the Sage Notebook. To solve an ODE using Scipy first reduce your problem to a system of 1st degree ODEs: $u'(x,y,t) = f(t,x,y,u)$. Then, follow the instructions on the relevant Scipy documentation: Ordinary differential equations (odeint). The key components to solving the numerical ODE is (1) writing a Python function for the right-hand side, $f$, (2) writing a function for its Jacobian, $J_f$, (3) and calling the scipy.integrate.odeint function.

Consult the scipy.integrate.odeint documentation for more information on its use. You can read this documentation by entering

sage: from scipy.integrate import odeint
sage: odeint?

Finally, I providing the Jacobian for your problem is an optional argument but it helps with convergence.