[SciPy-User] Strange behavior of sph_jn
ZIEGLER Yann (ETU EOT)
yann.ziegler@etu.unistra...
Tue Apr 10 08:49:50 CDT 2012
Hi,
It seems that the bug I have with sph_jn for some values is due to scipy
itself. I finded someone having the same kind of trouble on
projects.scipy.org/scipy (the website seems to have some technical problems
at this time).
If anyone is interested in it, here is the solution I have finded to
circumvent this bug :
Using the definition of Spherical Bessel function involving Bessel function
(http://functions.wolfram.com/Bessel-TypeFunctions/SphericalBesselJ/02/),
I wrote -- nothing extraordinary, this is a 2-lines function -- my own
SphericalBessel function (naive but seemingly correct) for positive or
negative order n and complex argument z :
import numpy as np
from scipy.special import jn
def SphericalBessel(n,z):
zsqrt = np.sqrt(np.abs(z)) * np.exp(np.angle(z)/2)
return np.sqrt(np.pi/2) / zsqrt * jn(n+0.5, z)
Yann
More information about the SciPy-User
mailing list