Search code examples
python-3.xscipybessel-functions

zeros of the derivative of the spherical Bessel function


I make reference to the function in Scipy here. I want to calculate the zeros of the derivative of the function j'_n(x). Any propositions for how to do it ?


Solution

  • Use the built-in scipy function scipy.optimize.brentq to find the roots. An example usage is

    import scipy.optimize
    from scipy.special import spherical_jn
    
    def sphericalBesselBrent(x, n, derivative):
        return spherical_jn(n, x, derivative=derivative)
    
    x0 = scipy.optimize.brentq(sphericalBesselBrent, 0.5, 5, args=(2, True))
    print(x0)
    

    Where we need to define some wrapper function sphericalBesselBrent around the scipy bessel function to match the function template required by brentq. This returns a single root between 0.5 and5. If you need more roots, you would need to iterate over ranges to search for roots. a and b must be different signs.