I'm trying to write a code to solve
integral from 1 to 2 integral from 0 to x, xy^2 dydx = 31/15
I verified the manual solution with Wolfram|Alpha as well. But the code gives the output as 3.1.
from scipy.integrate import nquad
def f(x, y):
return x * y**2
def limits_y(x):
return [0, x]
def limits_x():
return [1, 2]
ans,err = nquad(f, [limits_y, limits_x])
print(round(ans,3))
Any idea why? Am I missing something?