I have a function which looks like this:
def test(x,q0):
q = q0/(1+x**2)
h_func = lambda t: 1/sp.cosh(t)**2
fun = lambda t: sp.log(1+q*h_func(t))
return spi.quad(fun,-sp.inf,sp.inf)[0]
How do I make it vectorized so that it can accept x
as an array? Right now, it shows
TypeError: only length-1 arrays can be converted to Python scalars
I can achieve this in Matlab using
integral(fun,-Inf,Inf,'ArrayValued',true)
,
but is there a Python equivalent of the 'ArrayValued',true
in Matlab?