【发布时间】:2021-09-12 06:07:39
【问题描述】:
hcubature 不断为我返回零。
我有一个多变量函数,我想对一个变量进行积分。作为测试,我使用quadgk,它只能用于1个变量(硬编码其他变量),它可以工作。
但是,当使用 hcubature 时,我的积分返回零。
这是我最小的非工作示例
psi_1D_PIB(x, n, L) = sqrt(2/L) * sin(n * π * x / L)
psi_conj_PIB(x, n, L) = conj(psi_1D_PIB(x, n, L)) * psi_1D_PIB(x, n, L)
psi_conj_PIB(v) = psi_conj_PIB(v...) # as per hcubature documentation, send an array
println(hcubature(psi_conj_PIB, (1.,1, 5.), (5.,1,5.))) # integrate x from 1 to 5, n from 1 to 1, and L from 5 to 5.
# first tuple is LH bounds, second is RH integration bounds
输出为0.0, 0.0) 缺少的左括号似乎不是错字
使用guadgk 来计算这个本质上是单变量积分,
psi_1D_PIB(x) = sqrt(2/5) * sin(1 * π * x / 5)
psi_conj_PIB(x) = conj(psi_1D_PIB(x)) * psi_1D_PIB(x)
println(quadgk(psi_conj_PIB, 1., 5.))
输出是(0.9513653457281316, 2.5028679129235343e-10)
【问题讨论】:
-
很确定
hcubature没问题,我午夜后的微积分被拍了。
标签: julia numerical-integration