Bessel functions

Bessels.besseljFunction
besselj(ν::Real, x::Real)
besselj(ν::AbstractRange, x::Real)

Returns the Bessel function, $J_ν(x)$, of the first kind and order ν.

\[J_{\nu}(x) = \sum_{m=0}^{\infty} \frac{(-1)^m}{m!\Gamma(m+\nu+1)}(\frac{x}{2})^{2m+\nu}\]

Routine supports single and double precision (e.g., Float32 or Float64) real arguments.

For ν isa AbstractRange, returns a vector of type float(x) using recurrence to compute $J_ν(x)$ at many orders as long as the conditions ν[1] >= 0 and step(ν) == 1 are met. Consider the in-place version besselj! to avoid allocation.

Examples

julia> besselj(2, 1.5)
0.2320876721442147

julia> besselj(3.2, 2.5)
0.17888479721039752

julia> besselj(1:3, 2.5)
3-element Vector{Float64}:
 0.4970941024642743
 0.44605905843961735
 0.2166003910391135

External links: DLMF, Wikipedia

See also: besselj!, besselj0(x), besselj1(x)

source
Bessels.besselj!Function
Bessels.besselj!(out::DenseVector{T}, ν::AbstractRange, x::T)

Computes the Bessel function, $j_ν(x)$, of the first kind at many orders ν in-place using recurrence. The conditions ν[1] >= 0 and step(ν) == 1 must be met.

Examples

julia> nu = 1:3; x = 1.5; out = zeros(typeof(x), length(nu));

julia> Bessels.besselj!(out, nu, x)
3-element Vector{Float64}:
 0.5579365079100995
 0.2320876721442147
 0.06096395114113963

See also: besselj(ν, x)

source
Bessels.besselyFunction
bessely(ν::Real, x::Real)
bessely(ν::AbstractRange, x::Real)

Returns the Bessel function, $Y_ν(x)$, of the second kind and order ν.

\[Y_{\nu}(x) = \frac{J_{\nu}(x) \cos(\nu \pi) - J_{-\nu}(x)}{\sin(\nu \pi)}\]

Routine supports single and double precision (e.g., Float32 or Float64) real arguments.

For ν isa AbstractRange, returns a vector of type float(x) using recurrence to compute $Y_ν(x)$ at many orders as long as the conditions ν[1] >= 0 and step(ν) == 1 are met. Consider the in-place version besselj! to avoid allocation.

Examples

julia> bessely(2, 1.5)
-0.9321937597629739

julia> bessely(3.2, 2.5)
-0.8425784476035085

julia> bessely(1:3, 2.5)
3-element Vector{Float64}:
  0.1459181379667858
 -0.38133584924180347
 -0.7560554967536713

External links: DLMF, Wikipedia

See also: bessely!, bessely0(x), bessely1(x)

source
Bessels.bessely!Function
Bessels.bessely!(out::DenseVector{T}, ν::AbstractRange, x::T)

Computes the Bessel function, $Y_ν(x)$, of the second kind at many orders ν in-place using recurrence. The conditions ν[1] >= 0 and step(ν) == 1 must be met.

Examples

julia> nu = 1:3; x = 1.5; out = zeros(typeof(x), length(nu));

julia> Bessels.bessely!(out, nu, x)
3-element Vector{Float64}:
 -0.41230862697391135
 -0.9321937597629739
 -2.0735413990606855

See also: bessely(ν, x)

source
Bessels.besseljyFunction
Bessels.besseljy(ν, x::T) where T <: Float64

Returns the Bessel function of the first $J_{ν}(x)$ and second $Y_{ν}(x)$ kind for order ν.

This method may be faster than calling besselj(ν, x) and bessely(ν, x) separately depending on argument range. Results may be slightly different than calling individual functions in some domains due to using different algorithms.

Examples

julia> jn, yn = Bessels.besseljy(1.8, 1.2)
(0.2086667754797278, -1.0931173556626879)

See also: besselh, besselj(nu,x)), bessely(nu,x))

source

Modified Bessel functions

Bessels.besseliFunction
besseli(ν::Real, x::Real)
besseli(ν::AbstractRange, x::Real)

Returns the modified Bessel function, $I_ν(x)$, of the first kind and order ν.

\[I_{\nu}(x) = \sum_{m=0}^{\infty} \frac{1}{m!\Gamma(m+\nu+1)}(\frac{x}{2})^{2m+\nu}\]

Routine supports single and double precision (e.g., Float32 or Float64) real arguments.

For ν isa AbstractRange, returns a vector of type float(x) using recurrence to compute $I_ν(x)$ at many orders as long as the conditions ν[1] >= 0 and step(ν) == 1 are met. Consider the in-place version besseli! to avoid allocation.

Examples

julia> besseli(2, 1.5)
0.3378346183356807

julia> besseli(3.2, 2.5)
0.3772632469352918

julia> besseli(1:3, 2.5)
3-element Vector{Float64}:
 2.5167162452886984
 1.2764661478191641
 0.47437040877803555

External links: DLMF, Wikipedia

See also: besseli!, besseli0(x), besseli1(x), besselix(nu,x))

source
Bessels.besseli!Function
Bessels.besseli!(out::DenseVector{T}, ν::AbstractRange, x::T)

Computes the modified Bessel function, $I_ν(x)$, of the first kind at many orders ν in-place using recurrence. The conditions ν[1] >= 0 and step(ν) == 1 must be met.

Examples

julia> nu = 1:3; x = 1.5; out = zeros(typeof(x), length(nu));

julia> Bessels.besseli!(out, nu, x)
3-element Vector{Float64}:
 0.9816664285779074
 0.3378346183356807
 0.0807741130160923

See also: besseli(ν, x)

source
Bessels.besselixFunction
besselix(nu, x::T) where T <: Union{Float32, Float64}

Scaled modified Bessel function of the first kind of order nu, $I_{nu}(x)*e^{-x}$. Nu must be real.

source
Bessels.besselkFunction
besselk(ν::Real, x::Real)
besselk(ν::AbstractRange, x::Real)

Returns the modified Bessel function, $K_ν(x)$, of the second kind and order ν.

\[K_{\nu}(x) = \frac{\pi}{2} \frac{I_{-\nu}(x) - I_{\nu}(x)}{\sin(\nu \pi)}\]

Routine supports single and double precision (e.g., Float32 or Float64) real arguments.

For ν isa AbstractRange, returns a vector of type float(x) using recurrence to compute $K_ν(x)$ at many orders as long as the conditions ν[1] >= 0 and step(ν) == 1 are met. Consider the in-place version besselk! to avoid allocation.

Examples

julia> besselk(2, 1.5)
0.5836559632566508

julia> besselk(3.2, 2.5)
0.3244950563641161

julia> besselk(1:3, 2.5)
3-element Vector{Float64}:
 0.07389081634774707
 0.12146020627856384
 0.26822714639344925

External links: DLMF, Wikipedia

See also: besselk!, besselk0(x), besselk1(x), besselkx(nu,x))

source
Bessels.besselk!Function
Bessels.besselk!(out::DenseVector{T}, ν::AbstractRange, x::T)

Computes the modified Bessel function, $K_ν(x)$, of the second kind at many orders ν in-place using recurrence. The conditions ν[1] >= 0 and step(ν) == 1 must be met.

Examples

julia> nu = 1:3; x = 1.5; out = zeros(typeof(x), length(nu));

julia> Bessels.besselk!(out, nu, x)
3-element Vector{Float64}:
 0.2773878004568438
 0.5836559632566508
 1.8338037024745792

See also: besselk(ν, x)

source
Bessels.besselkxFunction
besselkx(x::T) where T <: Union{Float32, Float64}

Scaled modified Bessel function of the second kind of order nu, $K_{nu}(x)*e^{x}$.

source

Hankel functions

Bessels.besselhFunction
besselh(nu, [k=1,] x)

Returns the Bessel function of the third kind of order nu (the Hankel function).

\[H^{(1)}_{\nu}(x) = J_{\nu}(x) + i Y_{\nu}(x) H^{(2)}_{\nu}(x) = J_{\nu}(x) - i Y_{\nu}(x)\]

k must be 1 or 2, selecting hankelh1 or hankelh2, respectively.

Examples

julia> besselh(1.2, 1, 9.2)
0.2513215427211038 + 0.08073652619125624im

See also: Bessels.besseljy, besselj(nu,x)), bessely(nu,x))

source
Bessels.hankelh1Function
hankelh1(nu, x)

Bessel function of the third kind of order nu, $H^{(1)}_\nu(x)$.

source
Bessels.hankelh2Function
hankelh2(nu, x)

Bessel function of the third kind of order nu, $H^{(2)}_\nu(x)$.

source

Spherical Bessel functions

Bessels.sphericalbesseljFunction
sphericalbesselj(ν, x)

Spherical bessel function of the first kind of order ν, $j_ν(x)$. This is the non-singular solution to the radial part of the Helmholz equation in spherical coordinates.

\[j_{\nu}(x) = \sqrt(\frac{\pi}{2x}) J_{\nu + 1/2}(x)\]

where $J_{\nu}$ is the Bessel function of the first kind. Routine supports single and double precision (e.g., Float32, Float64) for real arguments.

Examples

julia> sphericalbesselj(1, 1.2)
0.34528456985779027

julia> sphericalbesselj(1.5, 1.2)
0.18231344932382995

External links: DLMF, Wikipedia

See also: besselj, sphericalbessely

source
Bessels.sphericalbesselyFunction
sphericalbessely(ν, x)

Spherical bessel function of the second kind of order ν, $y_ν(x)$. This is the non-singular solution to the radial part of the Helmholz equation in spherical coordinates. Sometimes known as a spherical Neumann function.

\[y_{\nu}(x) = \sqrt(\frac{\pi}{2x}) Y_{\nu + 1/2}(x)\]

where $Y_{\nu}$ is the Bessel function of the second kind. Routine supports single and double precision (e.g., Float32, Float64) for real arguments.

Examples

julia> sphericalbessely(1, 1.2)
-1.028336567803712

julia> sphericalbessely(1.5, 1.2)
-1.4453716277410136

External links: DLMF, Wikipedia

See also: bessely, sphericalbesselj

source
Bessels.sphericalbesseliFunction
Bessels.sphericalbesseli(ν, x)

Returns the modified spherical bessel function of the first kind of order ν, $i_ν(x)$.

\[i_{\nu}(x) = \sqrt(\frac{\pi}{2x}) I_{\nu + 1/2}(x)\]

where $I_{\nu}$ is the modified Bessel function of the first kind. Routine supports single and double precision (e.g., Float32, Float64) for real arguments.

Examples

julia> Bessels.sphericalbesseli(1, 1.2)
0.4606425870674146

julia> Bessels.sphericalbesseli(1.5, 1.2)
0.23179256391926525

External links: DLMF, Wikipedia

See also: besseli, Bessels.sphericalbesselk

source
Bessels.sphericalbesselkFunction
Bessels.sphericalbesselk(ν, x)

Returns the modified spherical bessel function of the second kind of order ν, $k_ν(x)$.

\[k_{\nu}(x) = \sqrt(\frac{\pi}{2x}) K_{\nu + 1/2}(x)\]

where $K_{\nu}$ is the modified Bessel function of the second kind. Routine supports single and double precision (e.g., Float32, Float64) for real arguments.

Examples

julia> Bessels.sphericalbesselk(1, 1.2)
0.46015782375475334

julia> Bessels.sphericalbesselk(1.5, 1.2)
0.7595606983594666

External links: DLMF, Wikipedia

See also: besselk, Bessels.sphericalbesseli

source

Airy functions

Bessels.airyaiFunction
airyai(z)

Returns the Airy function of the first kind, $\operatorname{Ai}(z)$, which is the solution to the Airy differential equation $f''(z) - z f(z) = 0$.

\[\operatorname{Ai}(z) = \frac{\sqrt{3}}{2 \pi} \int_{0}^^{\infty} \exp{-\frac{t^3}{3} - \frac{z^3}{3t^3}} dt\]

Routine supports single and double precision (e.g., Float32, Float64, ComplexF64) for real and complex arguments.

Examples

julia> airyai(1.2)
0.10612576226331255

julia> airyai(1.2 + 1.4im)
-0.03254458873613304 - 0.14708163733976673im

External links: DLMF, Wikipedia

See also: airyaiprime, airybi

source
Bessels.airyaiprimeFunction
airyaiprime(z)

Returns the derivative of the Airy function of the first kind, $\operatorname{Ai}'(z)$. Routine supports single and double precision (e.g., Float32, Float64, ComplexF64) for real and complex arguments.

Examples

julia> airyaiprime(1.2)
-0.13278537855722622

julia> airyaiprime(1.2 + 1.4im)
-0.02884977394212135 + 0.21117856532576215im

External links: DLMF, Wikipedia

See also: airyai, airybi

source
Bessels.airybiFunction
airybi(z)

Returns the Airy function of the second kind, $\operatorname{Bi}(z)$, which is the second solution to the Airy differential equation $f''(z) - z f(z) = 0$. Routine supports single and double precision (e.g., Float32, Float64, ComplexF64) for real and complex arguments.

Examples

julia> airybi(1.2)
1.4211336756103483

julia> airybi(1.2 + 1.4im)
0.3150484065220768 + 0.7138432162853446im

External links: DLMF, Wikipedia

See also: airybiprime, airyai

source
Bessels.airybiprimeFunction
airybiprime(z)

Returns the derivative of the Airy function of the second kind, $\operatorname{Bi}'(z)$. Routine supports single and double precision (e.g., Float32, Float64, ComplexF64) for real and complex arguments.

Examples

julia> airybiprime(1.2)
1.221231398704895

julia> airybiprime(1.2 + 1.4im)
-0.5250248310153249 + 0.9612736841097036im

External links: DLMF, Wikipedia

See also: airybi, airyai

source

Gamma functions

Bessels.gammaFunction
gamma(x::T) where T <: Union{Float16, Float32, Float64}

Returns the gamma function, $Γ(x)$, for real x.

\[\Gamma(x) = \int_x^\infty e^{-t} t^{x-1} dt \,\]

External links: DLMF, Wikipedia

source