Ask Your Question

Ryan Hinton's profile - activity

2019-08-30 17:57:42 +0200 received badge  Famous Question (source)
2015-10-11 22:55:53 +0200 received badge  Notable Question (source)
2012-07-02 10:06:05 +0200 received badge  Popular Question (source)
2011-03-30 12:53:13 +0200 received badge  Student (source)
2011-03-12 19:42:10 +0200 received badge  Supporter (source)
2011-03-12 19:39:56 +0200 asked a question How can I speed up symbolic function evaluation?

I have a few hundred lines of code that calculate a system of ODEs. The resulting system of several hundred to several thousand equations take a long time to integrate. (I'm using SciPy's integrate interface; testing on a small case suggested it's several times faster than GSL's ode_solver for my problem.)

Of course, most of the time is spent in evaluating my equations. I'm already using fast_callable to speed up the calculations. It made a wonderful difference. But it's still taking hours or even days for the larger systems. I want to put this integration inside an optimizer, so any speed gain is great.

Stealing the example from the reference manual (http://www.sagemath.org/doc/numerical...), I'm currently doing something like the following.

import scipy
from scipy import integrate
var('x, y')
mu = 10.0
dy = (y, -x + mu*y*(1-x**2))
dy_fc = tuple(fast_callable(expr, domain=float, vars=(x,y)) for expr in dy)
def f_1(y,t):
    return [f(*y) for f in dy_fc]

xx=scipy.arange(0,100,.1)
yy=integrate.odeint(f_1,[1,0],xx)

I don't think I can speed up the integrate routine. Can I do anything to speed up f_1?

Thanks!