I am trying to self-learn SciPy and evaluate the following quadruple integral using scipy.integrate.nquad
:
$$\int_{0}^{1} \int_{0}^{1} \int_{0}^{1} \int_{0}^{1-x} (w+y) \:dz \:dy \:dx \:dw $$
I wrote the following code:
from scipy import integrate
def f(z, y, x, w):
return w + y
def bounds(z):
return [0, 1-z]
I = integrate.nquad(f, [bounds, [0,1], [0,1], [0,1]])
print(I)
However, it gives the following error:
bounds() takes 1 positional argument but 3 were given
Any help to solve this quadruple integral is much appreciated.