【问题标题】:Triple integration using using Python使用 Python 进行三重集成
【发布时间】:2013-06-26 11:24:14
【问题描述】:

我一直在尝试使用 scipy.integrate.tplquadrature 求解方程,但不完全理解符号,因此不知道如何求解以下方程。任何帮助将非常感激。

谢谢,

【问题讨论】:

标签: python scipy integration


【解决方案1】:

在您的示例中,它给出了零积分结果。我为inf使用了高价值1.e22

from scipy import exp, pi
inf = 1.e22
from scipy.integrate import tplquad
func = lambda x,y,z: x**2 * exp(-x**2) * exp(-0.5*y*z/x)
x1,x2 = 0, pi
y1,y2 = lambda x: 0, lambda x: inf
z1,z2 = lambda x,y: 0, lambda x,y: inf
print tplquad( func, x1, x2, y1, y2, z1, z2 )
#(0.0, 0.0)

这是一个例子to calculate the volume of a sphere:

import scipy
from scipy.integrate import quad, dblquad, tplquad
from numpy import *
# limits for radius
r1 = 0.
r2 = 1.
# limits for theta
t1 = 0
t2 = 2*pi
# limits for phi
p1 = 0
p2 = pi

def diff_volume(p,t,r):
    return r**2*sin(p)

volume = tplquad(diff_volume, r1, r2, lambda r:   t1, lambda r:   t2,
                                      lambda r,t: p1, lambda r,t: p2)[0]

【讨论】:

  • 是否可以在 3D 中生成正交或打印它们的方向和权重?
猜你喜欢
  • 1970-01-01
  • 2016-11-13
  • 2021-04-16
  • 2012-08-23
  • 2017-04-06
  • 1970-01-01
  • 2020-04-21
  • 1970-01-01
  • 2021-05-09
相关资源
最近更新 更多