Search code examples
pythonscipywolfram-mathematica

different result with scipy integrate.tplquad


With Matematica this integral gives me 3. wolfram alpha With integrate.tplquad I get -3.
This is Matematica code.

Integrate[1-x, {(0,2),(0,3-1.5*x),(0,6-3*x -2*y)}]   

I can't see what I am doing wrong with ntegrate.tplquad

f = lambda x,y,z: 1-x   

x1, x2 = 0,2

y1, y2 = lambda x : 0 , lambda x:3-1.5*x

z1, z2  = lambda x,y:0, lambda x,y: 6 -3*x -2*y

print(integrate.tplquad(f,x1,x2, y1, y2, z1, z2)[0])
-3.0

Solution

  • Double-check the tplquad docstring; you'll see that the signature of the function f is f(z, y, x). So it looks like your integrand should be:

       f = lambda x, y, z: 1 - z