My question relates to using spherical Bessel functions in Python.

If my ODE contains a spherical Bessel function of the form $$j_\ell(tx)$$ and similarly $$y_\ell(tx)$$

for given values of $t$ and $x$.

I used the following:

from scipy.special import spherical_jn(n, z, derivative)
from scipy.special import spherical_yn(n, z, derivative)

I thought I could maybe define jn as follows:

def Jn(tx,n):
    return (sqrt(pi/(2*(t*x))*jn(n+0.5,t*x))

And then just input it into my ODE.

Any help here is appreciated. I can post the ODE if required.

  • $\begingroup$ I think it depends on how you want to solve the ODE... with your own method, i.e. coding by yourself, or if you want to use an ODE solver available in python as odeint? $\endgroup$
    – VoB
    May 2, 2020 at 15:15
  • $\begingroup$ I would like to code it myself. Should I post the ODE for you to view perhaps? $\endgroup$
    – David
    May 2, 2020 at 15:35
  • $\begingroup$ Well, if you have to code it by yourself, it should be fine if you write it by yourself. Also, check that your implementation's results agrees with python's ones. $\endgroup$
    – VoB
    May 2, 2020 at 16:15
  • $\begingroup$ I don't understand what you mean with "I thought I could maybe define jn as follows...and then just input it into my own ODE" Are you asking a hypothetical question? Or have you tried and gotten something unexpected? $\endgroup$ May 2, 2020 at 18:13


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.