Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 15 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
[![Aqua QA](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)
[![JET QA](https://img.shields.io/badge/JET.jl-%E2%9C%88%EF%B8%8F-%23aa4444)](https://github.com/aviatesk/JET.jl)

This package provides functions to compute the zeros of the J and Y functions,
and the zeros of their derivatives, where J and Y are Bessel functions of the first and second kind, respectively.

For all functions described below, the order `nu::Real` is a finite number and `n::Integer` is a positive integer.
When `nu isa AbstractFloat`, the returned value has the same type as `nu`. When `nu isa Integer`, the usual
promotion rules apply, so that for most builtin integer types the output type will be `Float64`. However,
when `nu isa BigInt` the output type will be `BigFloat`.

When the output type is `Float64`, the exported functions (`besselj_zero`,
`bessely_zero`, `besselj_deriv_zero`, and `bessely_deriv_zero`) will use lookup tables to rapidly
return function zeros if the order `nu` is one of the first few values of `0, 1, ...` and the enumerator
`n` is one of the first values of `1, 2, 3, ...`. See the individual function docstrings for the actual
This package provides functions to compute the zeros of the J and Y functions, and the zeros of
their derivatives, where J and Y are Bessel functions of the first and second kind, respectively.

For all functions described below, the order `nu::Real` is a finite number and `n::Integer` is a
positive integer. When `nu isa AbstractFloat`, the returned value has the same type as `nu`. When
`nu isa Integer`, the usual promotion rules apply, so that for most builtin integer types the output
type will be `Float64`. However, when `nu isa BigInt` the output type will be `BigFloat`.

When the output type is `Float64`, the exported functions (`besselj_zero`, `bessely_zero`,
`besselj_deriv_zero`, and `bessely_deriv_zero`) will use lookup tables to rapidly return function
zeros if the order `nu` is one of the first few values of `0, 1, ...` and the enumerator `n` is one
of the first values of `1, 2, 3, ...`. See the individual function docstrings for the actual
extents of the lookup tables.

### Exported Functions
Expand All @@ -28,7 +28,7 @@ extents of the lookup tables.
besselj_zero(nu, n)
```

Return the `n`th zero of the Bessel J function of order `nu`.
Return the `n`th zero of the Bessel J function of order `nu`.

#### bessely_zero(nu, n)

Expand All @@ -44,8 +44,7 @@ Return the `n`th zero of the Bessel Y function of order `nu`.
besselj_deriv_zero(nu, n)
```

Return the `n`th nonvanishing zero of the derivative of the Bessel J
function of order `nu`.
Return the `n`th nonvanishing zero of the derivative of the Bessel J function of order `nu`.

#### bessely_deriv_zero(nu, n)

Expand Down Expand Up @@ -81,8 +80,7 @@ Asymptotic formula for the `n`th zero for the Bessel Y function of order `nu`.
FunctionZeros.besselj_deriv_zero_asymptotic(nu, n)
```

Asymptotic formula for the `n`th nonvanishing zero of the derivative of the
Bessel J function of order `nu`.
Asymptotic formula for the `n`th nonvanishing zero of the derivative of the Bessel J function of order `nu`.


#### FunctionZeros.bessely_deriv_zero_asymptotic(nu, n)
Expand All @@ -92,5 +90,3 @@ FunctionZeros.bessely_deriv_zero_asymptotic(nu, n)
```

Asymptotic formula for the `n`th zero of the derivative of the Bessel Y function of order `nu`.


20 changes: 10 additions & 10 deletions src/FunctionZeros.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""
FunctionZeros
This module provides functions to compute the zeros of the J and Y functions,
and the zeros of their derivatives, where J and Y are Bessel functions of the first and second kind, respectively.
and the zeros of their derivatives, where J and Y are Bessel functions of the first and second kind, respectively.
"""
module FunctionZeros
import SpecialFunctions
Expand All @@ -15,7 +15,7 @@ const nupre_max = 1
const npre_max = 500

# Strings used in multiple function docstrings:
const speeddocstr = """For greater speed, table lookup is used for `Float64` outputs when
const speeddocstr = """For greater speed, table lookup is used for `Float64` outputs when
`nu ∈ 0:$nupre_max` and `n ∈ 1:$(npre_max)`."""
const argstr = """## Arguments
- `nu::Real`: The order of the Bessel function.
Expand Down Expand Up @@ -84,7 +84,7 @@ end
_besselj_zero(nu, n)

`n`th zero of the Bessel J function of order `nu`,
for `n` = `1,2,...`.
for `n` = `1,2,...`.

$argstr
"""
Expand All @@ -101,7 +101,7 @@ const jzero_pre = [_besselj_zero(nu, n) for nu in 0:nupre_max, n in 1:npre_max]
besselj_zero(nu, n)

Return the `n`th zero of the Bessel J function of order `nu`,
for `n` = `1,2,...`.
for `n` = `1,2,...`.

$argstr
$speeddocstr
Expand Down Expand Up @@ -146,7 +146,7 @@ const yzero_pre = [_bessely_zero(nu, n) for nu in 0:nupre_max, n in 1:npre_max]
bessely_zero(nu, n)

Return the `n`th zero of the Bessel Y function of order `nu`,
for `n` = `1,2,...`.
for `n` = `1,2,...`.

$argstr
$speeddocstr
Expand Down Expand Up @@ -185,7 +185,7 @@ bessely_deriv_zero_asymptotic(nu, n) = bessel_deriv_zero_asymptotic(nu, n, 2)
"""
bessel_deriv_zero_asymptotic(nu, n, kind=1)

Asymptotic formula for the `n`th zero of the the derivative of Bessel J (Y) function
Asymptotic formula for the `n`th zero of the the derivative of Bessel J (Y) function
of order `nu`. `kind == 1 (2)` for Bessel function of the first (second) kind, J (Y).
"""
function bessel_deriv_zero_asymptotic(nu_in::Real, n::Integer, kind=1)
Expand Down Expand Up @@ -218,11 +218,11 @@ end
_besselj_deriv_zero(nu, n)

Return the `n`th nonvanishing zero of the derivative of Bessel J function of order `nu`,
for `n` = `1,2,...`.
for `n` = `1,2,...`.

$argstr
"""
function _besselj_deriv_zero(nu::Real, n::Integer)
function _besselj_deriv_zero(nu::Real, n::Integer)
# Ref: https://dlmf.nist.gov/10.6.E1
iszero(nu) && (n += 1) # Skip the zero occuring at zero
return Roots.find_zero(bessel_deriv_zero_asymptotic(nu, n, 1)) do x
Expand All @@ -237,7 +237,7 @@ const jderivzero_pre = [_besselj_deriv_zero(nu, n) for nu in 0:nupre_max, n in 1
besselj_deriv_zero(nu, n)

Return the `n`th nonvanishing zero of the derivative of the Bessel J function of order `nu`,
for `n` = `1,2,...`.
for `n` = `1,2,...`.

$argstr
$speeddocstr
Expand Down Expand Up @@ -276,7 +276,7 @@ const yderivzero_pre = [_bessely_deriv_zero(nu, n) for nu in 0:nupre_max, n in 1
bessely_deriv_zero(nu, n)

Return the `n`th zero of the derivative of the Bessel Y function of order `nu`,
for `n` = `1,2,...`.
for `n` = `1,2,...`.

$argstr
$speeddocstr
Expand Down
Loading