Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i implement spherical hankel function of the first kind by scipy/numpy or sympy? [closed]

I knew that there is no builtin sph_hankel1 in scipy then i want to know that how to implement it in the right way?

Additional: Just show me one correct implementation of sph_hankel1 either using of Scipy or Sympy.

like image 252
fronthem Avatar asked Jan 31 '26 15:01

fronthem


2 Answers

Regarding implementing it in SymPy, there is a guide on how to implement special functions here. We would love pull requests for well-known special functions.

For numerical routines, they are implemented in mpmath. It looks like it just uses the definition directly.

like image 60
asmeurer Avatar answered Feb 02 '26 07:02

asmeurer


Although it would be nice if there were an existing routine for calculating the spherical Hankel functions (like there is for the ordinary Hankel functions), they are just a (complex) linear combination of the spherical Bessel functions of the first and second kind so can be easily calculated from existing routines. Since the Hankel functions are complex and depending on your application of them, it can be advantageous to rewrite your expression in terms of the Bessel functions of the first and second kind, ie entirely real quantities, particularly if your final result is real.

like image 20
Craig J Copi Avatar answered Feb 02 '26 07:02

Craig J Copi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!