I would like to lower the time Scipy\'s odeint takes for solving a differential equation.
To practice, I used the example covered in Python in scientific computat
The easiest change to make (which will probably gain you a lot) is to use the C math library sin and cos for operations on single numbers instead of number. The call to numpy and the time spent working out that it isn't an array is fairly costly.
from libc.math cimport sin, cos
# later
-omega/Q + sin(theta) + d*cos(Omega*t)
I'd be tempted to assign a type to the input d (none of the other inputs are easily typed without changing the interface):
def f(y, double t, params):
I think I'd also just return a list like you do in your Python version. I don't think you gain a lot by using a C array.