different result with scipy integrate.tplquad

泄露秘密 提交于 2019-12-02 08:58:13

问题


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

回答1:


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


来源:https://stackoverflow.com/questions/52710223/different-result-with-scipy-integrate-tplquad

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!