Bessel zeros
A crate for finding the zeros (roots) of the Bessel functions and their derivatives.
Quick start
[]
= "1.0"
use bessel_zeros_j;
// First 5 zeros of J_0(x)
let zeros = bessel_zeros_j;
assert!;
Backends
Two backends are available:
| Backend | Module | Order type | Notes |
|---|---|---|---|
AMOS (amos-bessel-rs) |
crate root | any f64-compatible |
supports non-integer orders |
| real-bessel | bessel_zeros::fast |
i32 only |
faster; integer orders only |
Use the crate-root functions when you need non-integer orders (e.g. order = 1.5).
Use the fast module for integer orders when performance matters.
use ;
// AMOS backend — any real order
let zeros = bessel_zeros_j;
// fast backend — integer orders only, but faster
let zeros = bessel_zeros_j;
Available functions
Bessel functions of the first and second kind (Jν(x) and Yν(x)) and their derivatives (Jν'(x) and Yν'(x)) are supported:
| Function | Crate root | fast module |
|---|---|---|
| Jν(x) zeros | bessel_zeros_j(order, n) |
fast::bessel_zeros_j(order, n) |
| Yν(x) zeros | bessel_zeros_y(order, n) |
fast::bessel_zeros_y(order, n) |
| Jν'(x) zeros | bessel_zeros_jp(order, n) |
fast::bessel_zeros_jp(order, n) |
| Yν'(x) zeros | bessel_zeros_yp(order, n) |
fast::bessel_zeros_yp(order, n) |
For custom precision, use the lower-level bessel_zeros / fast::bessel_zeros functions,
which accept a BesselFunType and a precision argument.
use ;
let zeros = bessel_zeros;
no_std Support
bessel-zeros supports #![no_std] environments (requiring alloc for the returned root vectors). When std is disabled, calculations fall back to pure-Rust software floating-point routines via libm, and both amos-bessel-rs and real-bessel backends are compiled in no_std mode.
To use in a no_std project, disable default features:
[]
= { = "1.0", = false }
Algorithm
This crate implements the routine described in:
N. M. Temme, "An Algorithm with ALGOL 60 Program for the Computation of the zeros of the Ordinary Bessel Functions and those of their Derivatives", Journal of Computational Physics, 32, 270–279 (1979)
Inspired by Adam Wyatt's Matlab version of this code.