与 scipy 集成的不同结果.tplquad [英] different result with scipy integrate.tplquad

查看:75
本文介绍了与 scipy 集成的不同结果.tplquad的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 Matematica 这个积分给了我 3. wolfram alpha使用integrate.tplquad,我得到-3.
这是 Matematica 代码.

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)}]   

我看不出我在使用 ntegrate.tplquad 时做错了什么

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

推荐答案

仔细检查 tplquad 文档字符串;你会看到函数 f 的签名是 f(z, y, x).所以看起来你的被积函数应该是:

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

这篇关于与 scipy 集成的不同结果.tplquad的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆