mpmath是一个非常棒的库,是进行高精度计算的途径。值得注意的是,这些函数可以从它们更基本的组成部分计算出来。因此,您不必遵守scipy的限制,您可以使用不同的高精度库。下面是最简单的例子:import numpy as np
from scipy.special import *
X = np.random.random(3)
v = 2.000000000
print "Bessel Function J"
print jn(v,X)
print "Modified Bessel Function, Iv"
print ((1j**(-v))*jv(v,1j*X)).real
print iv(v,X)
print "Modified Bessel Function of the second kind, Kv"
print (iv(-v,X)-iv(v,X)) * (np.pi/(2*sin(v*pi)))
print kv(v,X)
print "Modified spherical Bessel Function, in"
print np.sqrt(np.pi/(2*X))*iv(v+0.5,X)
print [sph_in(floor(v),x)[0][-1] for x in X]
print "Modified spherical Bessel Function, kn"
print np.sqrt(np.pi/(2*X))*kv(v+0.5,X)
print [sph_kn(floor(v),x)[0][-1] for x in X]
print "Modified spherical Bessel Function, in"
print np.sqrt(np.pi/(2*X))*iv(v+0.5,X)
print [sph_in(floor(v),x)[0][-1] for x in X]
这就提供了:Bessel Function J
[ 0.01887098 0.00184202 0.08399226]
Modified Bessel Function, Iv
[ 0.01935808 0.00184656 0.09459852]
[ 0.01935808 0.00184656 0.09459852]
Modified Bessel Function of the second kind, Kv
[ 12.61494864 135.05883902 2.40495388]
[ 12.61494865 135.05883903 2.40495388]
Modified spherical Bessel Function, in
[ 0.0103056 0.00098466 0.05003335]
[0.010305631072943869, 0.00098466280846548084, 0.050033450286650107]
Modified spherical Bessel Function, kn
[ 76.86738631 2622.98228411 6.99803515]
[76.867205587011171, 2622.9730878542782, 6.998023749439338]
Modified spherical Bessel Function, in
[ 0.0103056 0.00098466 0.05003335]
[0.010305631072943869, 0.00098466280846548084, 0.050033450286650107]
除非底层数据具有高精度,否则对于要查找的大值,这将失败。