I am receiving a ValueError
when using integration, but I cannot understand why. Here is my simplified code:
import numpy as np
import scipy.integrate as integrate
pbar = 1
p = np.arange(0,pbar,pbar/1000)
h = lambda p: p**2/2+p*(1-p)
Kl = lambda p: h(p) +0.02
K = Kl(p)
R = 0.5*h(p) + 0.5*h(pbar)
Vl = lambda p: np.minimum.reduce([p, K, R])
integrate.quad(Vl, 0, pbar)[0]
Vl
is the element-wise minimum of the three arrays. The last line gives the exception:
ValueError: setting an array element with a sequence.
Can someone please explain the error and propose an alternative way of doing this integration?
See Question&Answers more detail:os