[SciPy-User] Bessel function of complex order

Pauli Virtanen pav@iki...
Sat Jun 30 16:57:19 CDT 2012

Andreas Pritschet <webmaster <at> hasenkopf2000.net> writes:
> I have noticed in the docs and some "bug reports" that Bessel functions
> in SciPy support only real order. But for my work I require a modified
> Bessel function of second kind of complex(!) order for complex values.
> Is in SciPy a chance of calculating something like
> scipy.special.kv(1j*k,1j), whereby k is an array?

You can use `besselk` from the mpmath library. It's arbitrary-precision
code, and will probably be slower roughly by a factor of 1000 than
equivalent compiled  floating point code. That may be fast enough.

Adding complex-order functions present in Scipy requires either 
(i) someone to dig up a license-compatible special function library
that has them, or (ii) someone with sufficient knowledge to write
such a part of such a library. This is somewhat onerous and fiddly
work, and I'm not going promise when (and if) I would work on it.

BTW, if you know good special function libraries with BSD compatible
licenses, please reply!

Scipy is missing a complex domain implementation of some of
the hypergeometric  functions, which would be required for
expressing the complex-order bessels. The implementation for
hypergeometric functions in mpmath IIRC relies on dynamic
adjustment of precision on the fly, and such code cannot
be simply ported for floating point.

Pauli Virtanen

More information about the SciPy-User mailing list