besselzero.m is the function. Other code is documentation.
This code is valid for abs(order) less than or equal 146222.16674537213 and 370030.762407380 for Bessel function of the first and second kind respectively. It is very fast and flexible too. 2 million zeros (0:10000 orders and 200 roots per order) can be found in 200 seconds on standard laptop. Accuracy is set to a default of 12 significant digits.
This code is based on another submission. I fixed the bugs, improved the documentation, improved the code quality, and improved the speed of the code. If you have problems, let me know. If I have time, I will fix them.
How it works:
the first three roots of any order Bessel can be approximated by a simple equations. These equations were generated using a least squares fit of the roots from orders of n=0:10000. The approximation is used to start the iteration of Halley's method. The 4th and higher roots can be approximated by understanding the roots are regularly spaced for a given order. Once the 2nd and 3rd roots are found, the spacing can be approximated by the distance between the 2nd and 3rd root. Then again Halley's method can be applied to precisely locate the root.Because the algorithm depends on good guesses of the first three zeros, if the guess is to far away then Halley's method will converge to the wrong zero which will subsequently cause any other zero to be incorrectly located. Therefore, a limit is put on Bessel order, abs(n), of 146222.16674537213 and 370030.762407380 for first and second kind respectively. If n is specified above these limits, then an error is thrown.
Jason Nicholson (2023). Bessel Zero Solver (https://www.mathworks.com/matlabcentral/fileexchange/48403-bessel-zero-solver), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Inspired by: Bessel Function Zeros
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!
Fixed typos in description.