I want to do something similar to this question.
Nm, Mm = np.meshgrid(range(3), range(2))
y = lambda x: x*Nm + x*Mm
Then, y
returns a 3x2 matrix. I want to integrate y from a to b, for instance we can choose a=0 and b=1. This means that the i, j component of the integrated matrix should be int from 0 to 1 of (x * i + x * j) dx. If I take into account one of the answers:
>>> a = [sin, cos]
>>> vectorize(quad)(a, 0, pi)
Clearly a
is a list of functions, but what I have is a function that returns an array, which is different. I get:
res = np.vectorize(integrate.quad)(y, 0, 1)
error: Supplied function does not return a valid float.
How can I fix this? Thanks for your help
Edit:
The desired result is
res = np.empty((3,2))
for i in range(3):
for j in range(2):
res[i, j] = quad(lambda x: x*i + x*j, 0, 1)[0]