scipy.integrate.

lebedev_rule#

scipy.integrate.lebedev_rule(n)[源代码]#

Lebedev 正交。

计算 Lebedev 正交的采样点和权重 [1] 用于对单位球面上的函数进行积分。

参数:
nint

正交阶数。请参阅“注释”以了解支持的值。

返回:
x形状为 (3, m) 的 ndarray

笛卡尔坐标系中单位球面上的采样点。m 是与指定阶数对应的“度数”;请参阅“注释”。

w形状为 (m,) 的 ndarray

权重

注释

通过将 [2] 的 Matlab 代码翻译为 Python 来实现。

可用的阶数(参数 n)为

3, 5, 7, 9, 11, 13, 15, 17,
19, 21, 23, 25, 27, 29, 31, 35,
41, 47, 53, 59, 65, 71, 77, 83,
89, 95, 101, 107, 113, 119, 125, 131

对应的度数 m

6, 14, 26, 38, 50, 74, 86, 110,
146, 170, 194, 230, 266, 302, 350, 434,
590, 770, 974, 1202, 1454, 1730, 2030, 2354,
2702, 3074, 3470, 3890, 4334, 4802, 5294, 5810

参考文献

[1]

V.I. Lebedev 和 D.N. Laikov。“131 阶代数精度的球体求积公式”。Doklady Mathematics,第 59 卷,第 3 期,1999 年,第 477-481 页。

[2]

R. Parrish。getLebedevSphere。Matlab Central File Exchange。https://www.mathworks.com/matlabcentral/fileexchange/27097-getlebedevsphere

[3]

Bellet, Jean-Baptiste、Matthieu Brachet 和 Jean-Pierre Croisille。“立方体球体上的求积和对称性。”《计算和应用数学杂志》409 (2022): 114142。DOI:10.1016/j.cam.2022.114142

示例

[3] 中给出的一个示例是对半径为 \(1\) 的球体上的 \(f(x, y, z) = \exp(x)\) 进行积分;那里的参考值是 14.7680137457653。显示随着阶数增加,收敛到预期结果

>>> import matplotlib.pyplot as plt
>>> import numpy as np
>>> from scipy.integrate import lebedev_rule
>>>
>>> def f(x):
...     return np.exp(x[0])
>>>
>>> res = []
>>> orders = np.arange(3, 20, 2)
>>> for n in orders:
...     x, w = lebedev_rule(n)
...     res.append(w @ f(x))
>>>
>>> ref = np.full_like(res, 14.7680137457653)
>>> err = abs(res - ref)/abs(ref)
>>> plt.semilogy(orders, err)
>>> plt.xlabel('order $n$')
>>> plt.ylabel('relative error')
>>> plt.title(r'Convergence for $f(x, y, z) = \exp(x)$')
>>> plt.show()
../../_images/scipy-integrate-lebedev_rule-1.png