# 【scipy】用python的库 scipy 求二重(多重)积分

26 篇文章 2 订阅

scipy求一重积分：点击跳转.

sympy求积分：点击跳转.

I = ∫ y = 0 1 / 2 ∫ x = 0 1 − 2 y x y   d x d y . I = \int_{y=0}^{1/2}\int_{x=0}^{1-2y} xy~dxdy .

from scipy.integrate import dblquad
area = dblquad(lambda x, y: x*y, 0, 0.5,
lambda x: 0, lambda x: 1-2*x)
print(area)

结果：(0.010416666666666668, 4.101620128472366e-16)


from scipy import integrate
def f(x, y):
return x*y

def bounds_y():
return [0, 0.5]

def bounds_x(y):
return [0, 1-2*y]


结果：0.010416666666666668, 4.101620128472366e-16)


I = ∫ 1 2 ∫ 2 3 ∫ 0 1 x y z   d x d y d z . I = \int_{1}^{2}\int_{2}^{3}\int_{0}^{1} xyz~dxdydz .

from scipy import integrate
f = lambda z, y, x: x*y*z
print(integrate.tplquad(f, 1, 2, lambda x: 2, lambda x: 3,
lambda x, y: 0, lambda x, y: 1))

结果：(1.8750000000000002, 3.324644794257407e-14)


import scipy.integrate as integrate
def f(x,y,z):
return x*y*z
def bounds_z():
return [1, 2]
def bounds_y(*args):
return [2, 3]
def bounds_x(*args):
return [0, 1]
result = integrate.nquad(f, [bounds_x, bounds_y, bounds_z])
print(result)


结果：(1.8750000000000002, 3.324644794257407e-14)


I = ∫ 0 1 / 2 ∫ 0 3 ∫ 0 3 ∫ 0 3 x y z t   d x d y d z d t . I = \int_{0}^{1/2}\int_{0}^{3}\int_{0}^{3}\int_{0}^{3} xyzt~dxdydzdt .

import scipy.integrate as integrate
def f(x,y,z,t):
return x*y*z*t
def bounds_z(*args):
return [0, 1/2]
def bounds_y(*args):
return [0, 3]
def bounds_x(*args):
return [0, 3]
def bounds_t(*args):
return [0,3]
result = integrate.nquad(f, [bounds_x, bounds_y, bounds_z, bounds_t])
print(result)

结果：(0.005208333333333334, 4.092713794698356e-16)

• 8
点赞
• 42
收藏
• 打赏
• 8
评论
09-18
10-19
09-21 102
12-06 211
02-28 9636
02-19 2177
09-22 1万+
06-14
11-03 1584
12-03 498

### “相关推荐”对你有帮助么？

• 非常没帮助
• 没帮助
• 一般
• 有帮助
• 非常有帮助

kt4ngw

¥2 ¥4 ¥6 ¥10 ¥20

1.余额是钱包充值的虚拟货币，按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载，可以购买VIP、C币套餐、付费专栏及课程。