I'm using scipy to solve a system of ordinary differential equations. For simplicity, take my code to be:
import scipy as sp
import numpy as np
from scipy.integrate import odeint
from numpy import array
def deriv(y,t): # return derivatives of the array y
a = -2.0
b = -0.1
return array([ y[1], a*y[0]+b*y[1] ])
time = np.linspace(0.0,10.0,100)
yinit = array([0.0005,0.2]) # initial values
y = odeint(deriv,yinit,time)
But now I want to solve this system for several values of the constant "a". So instead of having just a = -2.0 for example, I'd like to have:
a = array([[-2.0,-1.5,-1.,-0.5]])
and solve the system for each value of a. Is there a way to do this without having to loop over each element of the array? Can I do it all at once?